package handlers;
import adapter.MockAdapter;
import com.github.masahitojp.botan.Botan;
import com.github.masahitojp.botan.brain.LocalBrain;
import com.github.masahitojp.botan.exception.BotanException;
import handlers.lgtm.LGTMHandlers;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import utils.HandlersTestUtils;
import utils.pattern.InvocationRegexPattern;
import utils.pattern.NotInvocationRegexPattern;
import utils.pattern.RegexTestPattern;
import java.util.Arrays;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
public class LGTMHandlersTest {
Botan botan;
@Before
public void setUp() throws BotanException {
botan = new Botan.BotanBuilder()
.setAdapter(new MockAdapter())
.setBrain(new LocalBrain())
.setMessageHandlers(new LGTMHandlers())
.build();
botan.start();
}
@After
public void tearDown() {
botan.stop();
}
@Test
public void handlersRegistrationTest() {
assertThat(botan.getHandlers().size(), is(1));
}
@Test
public void regex() {
new HandlersTestUtils().regexTest(
botan,
Arrays.asList(
new InvocationRegexPattern("botan lgtm"),
new InvocationRegexPattern("botan LGTM"),
new NotInvocationRegexPattern("botan lgtmi")
)
);
}
}