コード例 #1
0
  @Test
  public void testGetCandidateRulesByIncludedLabels() throws CmdLineException {
    TestRule rule1 =
        new FakeTestRule(
            BuildRuleType.JAVA_TEST,
            ImmutableSet.of("windows", "linux"),
            BuildTargetFactory.newInstance("//:for"),
            ImmutableSortedSet.<BuildRule>of(),
            ImmutableSet.<BuildTargetPattern>of());

    TestRule rule2 =
        new FakeTestRule(
            BuildRuleType.JAVA_TEST,
            ImmutableSet.of("android"),
            BuildTargetFactory.newInstance("//:teh"),
            ImmutableSortedSet.<BuildRule>of(rule1),
            ImmutableSet.<BuildTargetPattern>of());

    TestRule rule3 =
        new FakeTestRule(
            BuildRuleType.JAVA_TEST,
            ImmutableSet.of("windows"),
            BuildTargetFactory.newInstance("//:lulz"),
            ImmutableSortedSet.<BuildRule>of(rule2),
            ImmutableSet.<BuildTargetPattern>of());

    Iterable<TestRule> rules = Lists.newArrayList(rule1, rule2, rule3);
    DependencyGraph graph = createDependencyGraphFromBuildRules(rules);
    TestCommandOptions options = getOptions("--include", "linux", "windows");

    Iterable<TestRule> result =
        TestCommand.getCandidateRulesByIncludedLabels(graph, options.getIncludedLabels());
    assertThat(result, IsIterableContainingInAnyOrder.containsInAnyOrder(rule1, rule3));
  }
 private void assertionsForPlatformEntityAndChildVideoGameEntity(
     String expectedPlatformName,
     String expectedVideoGameName1,
     String expectedVideoGameName2,
     Date expectedDateReleased,
     PlatformEntity savedPlatformEntity) {
   assertThat(savedPlatformEntity.getPlatformName(), is(expectedPlatformName));
   assertThat(
       savedPlatformEntity.getVideoGameEntities(),
       IsIterableContainingInAnyOrder.<VideoGameEntity>containsInAnyOrder(
           hasProperty("videoGameName", is(expectedVideoGameName1)),
           hasProperty("dateReleased", is(expectedDateReleased))));
   assertThat(
       savedPlatformEntity.getVideoGameEntities(),
       IsIterableContainingInAnyOrder.<VideoGameEntity>containsInAnyOrder(
           hasProperty("videoGameName", is(expectedVideoGameName2)),
           hasProperty("dateReleased", is(expectedDateReleased))));
 }
コード例 #3
0
  @Test
  public void testCriteriaMet_itemsInList() {
    // setup
    Transaction transaction =
        TransactionTestUtils.createTransaction(
            toothBrush, milkCarton, toothBrush, chips, toothBrush, toothBrush);
    Set<Integer> alreadyClaimedProducts = Sets.newHashSet(1, 3);

    // test
    boolean result = promotionElement.criteriaMet(transaction, alreadyClaimedProducts);

    // verify
    assertThat(result, is(false));
    assertThat(alreadyClaimedProducts, IsIterableContainingInAnyOrder.containsInAnyOrder(1, 3));
  }
コード例 #4
0
  private void testCriteriaMet(
      String reason, Transaction transaction, boolean expected, Integer... ids) {
    // setup
    Set<Integer> alreadyClaimedProducts = Sets.newHashSet();

    // test
    boolean result = promotionElement.criteriaMet(transaction, alreadyClaimedProducts);

    // verify
    checkThat(reason, result, equalTo(expected));
    if (expected) {
      checkThat(
          reason, alreadyClaimedProducts, IsIterableContainingInAnyOrder.containsInAnyOrder(ids));
    } else {
      checkThat(reason, alreadyClaimedProducts, IsCollectionWithSize.hasSize(0));
    }
  }
コード例 #5
0
ファイル: TestPun.java プロジェクト: CINERGI/SciGraph
  @Test
  public void testPun() {
    Node i = getNode("http://example.org/i");
    Node j = getNode("http://example.org/j");
    Node k = getNode("http://example.org/k");

    RelationshipType p = DynamicRelationshipType.withName("p");
    Relationship relationship = getOnlyElement(GraphUtil.getRelationships(i, j, p));
    assertThat("OPE edge should start with the subject.", relationship.getStartNode(), is(i));
    assertThat("OPE edge should end with the target.", relationship.getEndNode(), is(j));
    relationship =
        getOnlyElement(GraphUtil.getRelationships(i, k, OwlRelationships.RDFS_SUBCLASS_OF));
    assertThat("Subclass edge should start with i.", relationship.getStartNode(), is(i));
    assertThat("Subclass edge should end with k.", relationship.getEndNode(), is(k));
    assertThat(
        "i is both a class an a named individual",
        i.getLabels(),
        is(
            IsIterableContainingInAnyOrder.containsInAnyOrder(
                OwlLabels.OWL_CLASS, OwlLabels.OWL_NAMED_INDIVIDUAL)));
  }