Пример #1
0
 /** Test that WindowAndTrigger namespaces are prefixed by the related Window namespace. */
 @Test
 public void testIntervalWindowPrefixing() {
   StateNamespace window = StateNamespaces.window(intervalCoder, intervalWindow(1000, 87392));
   StateNamespace windowAndTrigger =
       StateNamespaces.windowAndTrigger(intervalCoder, intervalWindow(1000, 87392), 57);
   assertThat(windowAndTrigger.stringKey(), Matchers.startsWith(window.stringKey()));
   assertThat(
       StateNamespaces.global().stringKey(),
       Matchers.not(Matchers.startsWith(window.stringKey())));
 }
Пример #2
0
 /** Test that WindowAndTrigger namespaces are prefixed by the related Window namespace. */
 @Test
 public void testGlobalWindowPrefixing() {
   StateNamespace window =
       StateNamespaces.window(GlobalWindow.Coder.INSTANCE, GlobalWindow.INSTANCE);
   StateNamespace windowAndTrigger =
       StateNamespaces.windowAndTrigger(GlobalWindow.Coder.INSTANCE, GlobalWindow.INSTANCE, 57);
   assertThat(windowAndTrigger.stringKey(), Matchers.startsWith(window.stringKey()));
   assertThat(
       StateNamespaces.global().stringKey(),
       Matchers.not(Matchers.startsWith(window.stringKey())));
 }
Пример #3
0
 /**
  * RtRepoCommits can compare two commits and return result in patch mode.
  *
  * @throws Exception if there is no github key provided
  */
 @Test
 public final void compareCommitsPatch() throws Exception {
   final String patch = RtRepoCommitsITCase.repo().commits().patch("5339b8e35b", "9b2e6efde9");
   MatcherAssert.assertThat(
       patch, Matchers.startsWith("From 9b2e6efde94fabec5876dc481b38811e8b4e992f"));
   MatcherAssert.assertThat(
       patch, Matchers.containsString("Issue #430 RepoCommit interface was added"));
 }
Пример #4
0
  @Test
  public void testHelpVersion() {
    Main.instance = new Main();
    Bot bot = new Bot("test", new Server("localhost"));
    bot.loadMessagePlugin(new Help());

    Message message = new Message(bot, "testchannel", "testsender", new MessageParser("!help"));
    bot.onMockMessage(message);

    Assert.assertThat(
        message.getReplies().firstElement(), Matchers.startsWith("Hi. I support these commands"));
  }
  private void assertIsNotGzipCompressed(String filename, int filesize) throws Exception {
    GzipTester tester = new GzipTester(testingdir, compressionType);

    File testfile =
        tester.prepareServerFile(testServlet.getSimpleName() + "-" + filename, filesize);

    FilterHolder holder = tester.setContentServlet(testServlet);
    holder.setInitParameter("mimeTypes", "text/plain");

    try {
      tester.start();
      HttpTester.Response response =
          tester.assertIsResponseNotGzipCompressed(
              "GET", testfile.getName(), filesize, HttpStatus.OK_200);
      Assert.assertThat(response.get("ETAG"), Matchers.startsWith("W/etag-"));
    } finally {
      tester.stop();
    }
  }
 private Matcher<String> stringStartsWith(String prefix) {
   return org.hamcrest.Matchers.startsWith(prefix);
 }
 public static ByTagAndWithText ByTagStartingWithText(final String tag, final String text) {
   return new ByTagAndWithText(tag, Matchers.startsWith(text));
 }
Пример #8
0
 /**
  * MkGitignores can fetch single gitignore template.
  *
  * @throws Exception if some problem inside
  */
 @Test
 public void canFetchSingleRawTemplate() throws Exception {
   final Gitignores gitignores = new MkGithub().gitignores();
   MatcherAssert.assertThat(gitignores.template("Java"), Matchers.startsWith("*.class"));
 }
Пример #9
0
 /**
  * RtRepoCommits can compare two commits and return result in diff mode.
  *
  * @throws Exception if there is no github key provided
  */
 @Test
 public final void compareCommitsDiff() throws Exception {
   final String diff = RtRepoCommitsITCase.repo().commits().diff("2b3814e", "b828dfa");
   MatcherAssert.assertThat(diff, Matchers.startsWith("diff --git"));
 }