Example #1
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()));
  }
Example #2
0
  @SuppressWarnings("unchecked")
  public static <T> Matcher<Iterable<T>> hasIds(Class<T> expectedType, String... expectedIds) {
    List<Matcher<? super T>> matchers = createMatchers(expectedIds);

    Matcher<? super T>[] matcherArray = new Matcher[expectedIds.length];
    return Matchers.hasItems(matchers.toArray(matcherArray));
  }
 @Test
 @SuppressWarnings("unchecked")
 public void findByTitleContaining() {
   Pageable pageable = new PageRequest(0, 1);
   Page<Episode> page = repository.findByTitleContaining("testEpisode", pageable);
   assertEquals("testEpisode1", page.getContent().get(0).getTitle());
   assertThat(page.getContent(), hasSize(1));
   assertThat(page, Matchers.<Episode>hasItems(hasProperty("title", is("testEpisode1"))));
 }
  @SneakyThrows
  private void fluxoListarExcluirRenomearSalvarSalvarPublicar(
      String id1, String id2, String id3, String id4, String id5) {
    String id3r = id3 + " r";
    String id4r = id4 + " r";
    String id5r = id5 + " r";

    api.listar().andExpect(status().isOk());

    api.salvarCarta(id(id1), carta1(id1));
    api.salvarCarta(id(id2), carta1(id2));
    api.salvarCarta(id(id3), carta1(id3));
    api.salvarCarta(id(id4), carta1(id4));
    api.salvarCarta(id(id5), carta1(id5));

    api.excluirPagina(SERVICO, id(id1)).andExpect(status().isOk());
    api.excluirPagina(SERVICO, id(id2)).andExpect(status().isOk());
    api.renomearCarta(id(id3), id(id3r)).andExpect(status().isOk());
    api.renomearCarta(id(id4), id(id4r)).andExpect(status().isOk());
    api.renomearCarta(id(id5), id(id5r)).andExpect(status().isOk());

    api.salvarCarta(id(id1), carta1(id1)).andExpect(status().is3xxRedirection());
    api.salvarCarta(id(id2), carta1(id2)).andExpect(status().is3xxRedirection());
    api.salvarCarta(id(id3r), carta2(id3r)).andExpect(status().is3xxRedirection());
    api.salvarCarta(id(id4r), carta2(id4r)).andExpect(status().is3xxRedirection());
    api.salvarCarta(id(id5r), carta2(id5r)).andExpect(status().is3xxRedirection());

    api.publicarCarta(id(id1)).andExpect(status().isOk());
    api.publicarCarta(id(id2)).andExpect(status().isOk());
    api.publicarCarta(id(id3r)).andExpect(status().isOk());
    api.publicarCarta(id(id4r)).andExpect(status().isOk());
    api.publicarCarta(id(id4r)).andExpect(status().isOk());

    api.listar()
        .andExpect(
            jsonPath("$[*].id")
                .value(Matchers.hasItems(id(id1), id(id2), id(id3r), id(id4r), id(id5r))));
  }
  @Test
  public void transform_ShouldReturnAuditTrailEntryWithDataOfEvent() {
    testEvent.setStringField("foo");
    testEvent.setIntField(76);
    testEvent.setObjectField(null);

    AuditTrailEntry ae = transformer.transform(testEvent);
    assertThat(ae.getWorkflowModelElement(), is(NAME));

    List<Attribute> atts = ae.getData().getAttribute();
    assertThat(atts.size(), is(5));

    Matcher<Data.Attribute> stringName = hasProperty("name", is("stringField"));
    Matcher<Attribute> stringValue = hasProperty("value", is("foo"));
    @SuppressWarnings("unchecked")
    Matcher<Attribute> stringM = allOf(stringName, stringValue);

    Matcher<Attribute> intName = hasProperty("name", is("intField"));
    Matcher<Attribute> intValue = hasProperty("value", is("76"));
    @SuppressWarnings("unchecked")
    Matcher<Attribute> intM = allOf(intName, intValue);

    Matcher<Attribute> objName = hasProperty("name", is("objectField"));
    Matcher<Attribute> objValue = hasProperty("value", is("null"));
    @SuppressWarnings("unchecked")
    Matcher<Attribute> objM = allOf(objName, objValue);

    Matcher<Attribute> className = hasProperty("name", is("class"));
    Matcher<Attribute> classValue =
        hasProperty("value", is("class " + testEvent.getClass().getName()));
    @SuppressWarnings("unchecked")
    Matcher<Attribute> classM = allOf(className, classValue);

    @SuppressWarnings("unchecked")
    Matcher<Iterable<Attribute>> hasItems = Matchers.hasItems(stringM, intM, objM, classM);
    assertThat(atts, hasItems);
  }