@Test
  public void sessionIMChatAccept8()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received a chat message");

    receiveMessageStatusURL = INVALID;

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("I am good"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser4Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    try {
      Thread.sleep(1000);
    } catch (InterruptedException e) {
    }
    Setup.endTest();
  }
  @Test
  public void sessionIMChatAccept23()
      throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 3 has received chat closed notification");

    System.out.println("sessionID=" + sessionID);
    System.out.println("receiveSessionID=" + receiveSessionID);

    RestAssured.authentication = RestAssured.DEFAULT_AUTH;
    String url = (Setup.channelURL[3].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType",
                    Matchers.hasItem("SessionEnded"),
                "notificationList.chatEventNotification.sessionId", Matchers.hasItem(sessionID),
                "notificationList.chatEventNotification.link[0].rel",
                    Matchers.hasItem("ChatSessionInformation"))
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());
    Setup.endTest();
  }
  @Test
  public void adhocIMChat6() throws JsonGenerationException, JsonMappingException, IOException {
    Setup.startTest("Checking that User 1 has received a chat message");

    receiveMessageStatusURL = INVALID;
    String url = (Setup.channelURL[1].split("username\\=")[0]) + "username="******"notificationList.messageNotification.chatMessage.text",
                    Matchers.hasItem("how are you"),
                "notificationList.messageNotification.sessionId", Matchers.hasItem("adhoc"),
                "notificationList.messageNotification.messageId", Matchers.notNullValue(),
                "notificationList.messageNotification.senderAddress",
                    Matchers.hasItem(Setup.TestUser2Contact),
                "notificationList.messageNotification.link", Matchers.notNullValue())
            .post(url);
    System.out.println("Response = " + response.getStatusCode() + " / " + response.asString());

    receiveMessageStatusURL =
        response.jsonPath().getString("notificationList.messageNotification[0].link[0].href");
    System.out.println("message status URL = " + receiveMessageStatusURL);
    Setup.endTest();
  }
  @Test
  public void testStateFileCanBeWritten() throws Exception {
    final MetricsLimiterStateManager out =
        new MetricsLimiterStateManager.Builder().setStateFile(STATE_FILE).build(_marks);

    out.writeState();

    Assert.assertTrue(Files.exists(STATE_FILE));

    final List<String> lines = Files.readAllLines(STATE_FILE, StandardCharsets.UTF_8);

    Assert.assertEquals(2, lines.size());
    Assert.assertThat(
        lines,
        Matchers.allOf(
            Matchers.hasItem(Matchers.containsString(METRIC_A)),
            Matchers.hasItem(Matchers.containsString(METRIC_B))));
    if (lines.get(0).contains(METRIC_A)) {
      Assert.assertThat(lines.get(0), Matchers.containsString(_time1AsString));
      Assert.assertThat(lines.get(0), Matchers.containsString(" " + Integer.toString(6) + " "));
      Assert.assertThat(lines.get(1), Matchers.containsString(_time2AsString));
      Assert.assertThat(lines.get(1), Matchers.containsString(" " + Integer.toString(1) + " "));

    } else {
      Assert.assertThat(lines.get(1), Matchers.containsString(_time1AsString));
      Assert.assertThat(lines.get(1), Matchers.containsString(" " + Integer.toString(6) + " "));
      Assert.assertThat(lines.get(0), Matchers.containsString(_time2AsString));
      Assert.assertThat(lines.get(0), Matchers.containsString(" " + Integer.toString(1) + " "));
    }
  }
 /**
  * RtReleases can remove a release.
  *
  * @throws Exception if any problem inside
  */
 @Test
 public void canRemoveRelease() throws Exception {
   final Releases releases = repo.releases();
   final Release release = releases.create(RandomStringUtils.randomAlphanumeric(Tv.TEN));
   MatcherAssert.assertThat(releases.iterate(), Matchers.hasItem(release));
   releases.remove(release.number());
   MatcherAssert.assertThat(releases.iterate(), Matchers.not(Matchers.hasItem(release)));
 }
  @Test
  public void compilerAndPreprocessorAreAlwaysReturnedFromGetInputsAfterBuildingLocally()
      throws IOException {
    ProjectFilesystem filesystem = new FakeProjectFilesystem();

    SourcePath preprocessor = new PathSourcePath(filesystem, Paths.get("preprocessor"));
    Tool preprocessorTool = new CommandTool.Builder().addInput(preprocessor).build();

    SourcePath compiler = new PathSourcePath(filesystem, Paths.get("compiler"));
    Tool compilerTool = new CommandTool.Builder().addInput(compiler).build();

    SourcePathResolver pathResolver =
        new SourcePathResolver(
            new BuildRuleResolver(TargetGraph.EMPTY, new BuildTargetNodeToBuildRuleTransformer()));
    BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
    BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).build();

    CxxPreprocessAndCompile cxxPreprocess =
        CxxPreprocessAndCompile.preprocess(
            params,
            pathResolver,
            new PreprocessorDelegate(
                pathResolver,
                DEFAULT_SANITIZER,
                DEFAULT_WORKING_DIR,
                new DefaultPreprocessor(preprocessorTool),
                ImmutableList.<String>of(),
                ImmutableList.<String>of(),
                DEFAULT_INCLUDE_ROOTS,
                DEFAULT_SYSTEM_INCLUDE_ROOTS,
                DEFAULT_HEADER_MAPS,
                DEFAULT_FRAMEWORK_ROOTS,
                DEFAULT_FRAMEWORK_PATH_SEARCH_PATH_FUNCTION,
                Optional.<SourcePath>absent(),
                DEFAULT_INCLUDES),
            DEFAULT_OUTPUT,
            DEFAULT_INPUT,
            DEFAULT_INPUT_TYPE,
            DEFAULT_SANITIZER);
    assertThat(cxxPreprocess.getInputsAfterBuildingLocally(), Matchers.hasItem(preprocessor));

    CxxPreprocessAndCompile cxxCompile =
        CxxPreprocessAndCompile.compile(
            params,
            pathResolver,
            new DefaultCompiler(compilerTool),
            ImmutableList.<String>of(),
            ImmutableList.<String>of(),
            DEFAULT_OUTPUT,
            DEFAULT_INPUT,
            DEFAULT_INPUT_TYPE,
            DEFAULT_SANITIZER);
    assertThat(cxxCompile.getInputsAfterBuildingLocally(), Matchers.hasItem(compiler));
  }
  @Test
  public void checkGetProperties() throws ComponentLookupException {
    List<String> result =
        ((AbstractSimpleController) this.mocker.getComponentUnderTest()).getProperties();

    Assert.assertEquals(4, result.size());
    Assert.assertThat(result, Matchers.hasItem(STATUS_KEY));
    Assert.assertThat(result, Matchers.hasItem("solved__pubmed_id"));
    Assert.assertThat(result, Matchers.hasItem("solved__gene_id"));
    Assert.assertThat(result, Matchers.hasItem("solved__notes"));
  }
  private static void assertRelProvidersSetUp(ApplicationContext context) {

    Map<String, RelProvider> discoverers = context.getBeansOfType(RelProvider.class);
    assertThat(
        discoverers.values(),
        Matchers.<RelProvider>hasItem(instanceOf(DelegatingRelProvider.class)));
  }
Beispiel #9
0
  @Test
  public void testArgsWithLocationMacroAffectDependenciesAndExpands() throws Exception {
    BuildRuleResolver resolver =
        new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
    SourcePathResolver pathResolver = new SourcePathResolver(resolver);

    BuildRule shBinaryRule =
        new ShBinaryBuilder(BuildTargetFactory.newInstance("//:my_exe"))
            .setMain(new FakeSourcePath("bin/exe"))
            .build(resolver);

    BuildRule exportFileRule =
        ExportFileBuilder.newExportFileBuilder(BuildTargetFactory.newInstance("//:file"))
            .setSrc(new FakeSourcePath("file.txt"))
            .build(resolver);

    WorkerToolBuilder workerToolBuilder =
        WorkerToolBuilder.newWorkerToolBuilder(BuildTargetFactory.newInstance("//:worker_rule"))
            .setExe(shBinaryRule.getBuildTarget())
            .setArgs("--input $(location //:file)");
    WorkerTool workerTool = (WorkerTool) workerToolBuilder.build(resolver);

    assertThat(
        workerToolBuilder.findImplicitDeps(), Matchers.hasItem(exportFileRule.getBuildTarget()));
    assertThat(workerTool.getDeps(), Matchers.hasItems(shBinaryRule, exportFileRule));
    assertThat(workerTool.getRuntimeDeps(), Matchers.hasItems(shBinaryRule, exportFileRule));
    assertThat(
        workerTool.getArgs(),
        Matchers.containsString(
            pathResolver
                .getAbsolutePath(new BuildTargetSourcePath(exportFileRule.getBuildTarget()))
                .toString()));
  }
 public ExecutionFailure assertThatCause(final Matcher<String> matcher) {
   List<Throwable> causes = new ArrayList<Throwable>();
   extractCauses(failure, causes);
   assertThat(causes, Matchers.<Throwable>hasItem(hasMessage(matcher)));
   outputFailure.assertThatCause(matcher);
   return this;
 }
  private static void assertEntityLinksSetUp(ApplicationContext context) {

    Map<String, EntityLinks> discoverers = context.getBeansOfType(EntityLinks.class);
    assertThat(
        discoverers.values(),
        Matchers.<EntityLinks>hasItem(instanceOf(DelegatingEntityLinks.class)));
  }
Beispiel #12
0
 /**
  * MkBase can start a bout and talk in it.
  *
  * @throws Exception If there is some problem inside
  */
 @Test
 public void startsBoutAndTalks() throws Exception {
   final Messages messages = new MkBase().randomBout().messages();
   messages.post("How are you doing?");
   MatcherAssert.assertThat(
       messages.iterate(),
       Matchers.hasItem(new Message.HasText(Matchers.containsString("are you"))));
 }
 @Test
 public void adhocIMChat3() {
   Setup.startTest("Checking IM notifications for user 1");
   String url = (Setup.channelURL[1].split("username\\=")[0]) + "username="******"notificationList.chatEventNotification.eventType", Matchers.hasItem("Accepted"),
               "notificationList.chatEventNotification.sessionId", Matchers.hasItem("adhoc"))
           .post(url);
   System.out.println(
       "Response = " + notifications1.getStatusCode() + " / " + notifications1.asString());
   Setup.endTest();
 }
 @Test
 public void compilerFlags() throws Exception {
   BuildTarget target = BuildTargetFactory.newInstance("//:rule");
   String flag = "-compiler-flag";
   HaskellBinaryBuilder builder =
       new HaskellBinaryBuilder(target).setCompilerFlags(ImmutableList.of(flag));
   BuildRuleResolver resolver =
       new BuildRuleResolver(
           TargetGraphFactory.newInstance(builder.build()),
           new DefaultTargetNodeToBuildRuleTransformer());
   builder.build(resolver);
   BuildTarget compileTarget =
       HaskellDescriptionUtils.getCompileBuildTarget(
           target, CxxPlatformUtils.DEFAULT_PLATFORM, Linker.LinkableDepType.STATIC);
   HaskellCompileRule rule = resolver.getRuleWithType(compileTarget, HaskellCompileRule.class);
   assertThat(rule.getFlags(), Matchers.hasItem(flag));
 }
Beispiel #15
0
  /**
   * Make sure we can get a valid metadata manager.
   *
   * @throws MetadataProviderException on exception
   */
  @Test
  public void canGetMetadata() throws MetadataProviderException {
    final SAMLProperties properties = Mockito.mock(SAMLProperties.class);
    this.config.setSamlProperties(properties);

    final String metadataUrl = UUID.randomUUID().toString();
    final SAMLProperties.Idp idp = Mockito.mock(SAMLProperties.Idp.class);
    Mockito.when(idp.getServiceProviderMetadataURL()).thenReturn(metadataUrl);
    Mockito.when(properties.getIdp()).thenReturn(idp);

    final ExtendedMetadataDelegate extendedMetadataDelegate =
        Mockito.mock(ExtendedMetadataDelegate.class);

    final CachingMetadataManager metadataManager = this.config.metadata(extendedMetadataDelegate);
    Assert.assertNotNull(metadataManager);
    Assert.assertThat(metadataManager.getAvailableProviders().size(), Matchers.is(1));
    Assert.assertThat(
        metadataManager.getAvailableProviders(), Matchers.hasItem(extendedMetadataDelegate));
  }
 /**
  * QueryValve can fetch data from AWS.
  *
  * @throws Exception If some problem inside
  */
 @Test
 @SuppressWarnings("unchecked")
 public void fetchesData() throws Exception {
   final Valve valve = new QueryValve();
   final Credentials credentials = Mockito.mock(Credentials.class);
   final ImmutableMap<String, AttributeValue> item =
       new ImmutableMap.Builder<String, AttributeValue>().build();
   final AmazonDynamoDB aws = Mockito.mock(AmazonDynamoDB.class);
   Mockito.doReturn(aws).when(credentials).aws();
   Mockito.doReturn(
           new QueryResult()
               .withItems(Collections.<Map<String, AttributeValue>>singletonList(item))
               .withConsumedCapacity(new ConsumedCapacity().withCapacityUnits(1.0d)))
       .when(aws)
       .query(Mockito.any(QueryRequest.class));
   final Dosage dosage =
       valve.fetch(credentials, "table", new Conditions(), new ArrayList<String>(0));
   MatcherAssert.assertThat(dosage.hasNext(), Matchers.is(false));
   MatcherAssert.assertThat(dosage.items(), Matchers.hasItem(item));
 }
Beispiel #17
0
 private void assertHasListItemNamed(final Collection<IPath> result, final String name) {
   assertThat("source dirs content", result, Matchers.hasItem(new Path(name)));
 }
Beispiel #18
0
 private void hasListNoItemNamed(
     final ErlProjectLayout info, final Collection<IPath> result, final String string) {
   assertThat("list has item", result, Matchers.not(Matchers.hasItem(new Path(string))));
 }