Java 类org.hamcrest.collection.IsEmptyCollection 实例源码

项目:openmrs-contrib-addonindex    文件:ElasticSearchIndexManualTest.java   
@Test
public void testGetByModulePackage() throws Exception {
    SearchResult result = client.execute(new Search.Builder(new SearchSourceBuilder()
            .size(1)
            .query(QueryBuilders.matchQuery("modulePackage", "testing-mod")).toString())
            .addIndex(AddOnInfoAndVersions.ES_INDEX)
            .build());
    SearchResult resultNotFound = client.execute(new Search.Builder(new SearchSourceBuilder()
            .size(1)
            .query(QueryBuilders.matchQuery("modulePackage", "fake-mod")).toString())
            .addIndex(AddOnInfoAndVersions.ES_INDEX)
            .build());
    List<AddOnInfoAndVersions> searchResult = result.getHits(AddOnInfoAndVersions.class).stream()
            .map(sr -> sr.source)
            .collect(Collectors.toList());
    List<AddOnInfoAndVersions> searchResultNotFound = resultNotFound.getHits(AddOnInfoAndVersions.class).stream()
            .map(sr -> sr.source)
            .collect(Collectors.toList());
    assertNotNull(searchResult);
    assertThat(searchResultNotFound, IsEmptyCollection.empty());
    System.out.println("Module Package Name: "+searchResult.get(0).getModulePackage());
}
项目:resource-disposer-plugin    文件:AsyncResourceDisposerTest.java   
@Test
public void neverDispose() throws Throwable {
    final IOException error = new IOException("to be thrown");

    Disposable disposable = spy(new ThrowDisposable(error));

    @SuppressWarnings("deprecation")
    AsyncResourceDisposer.WorkItem item = disposer.disposeAndWait(disposable).get();

    Set<AsyncResourceDisposer.WorkItem> remaining = disposer.getBacklog();
    assertEquals(1, remaining.size());
    assertThat(remaining.iterator().next(), equalTo(item));
    assertEquals(error, ((Disposable.State.Thrown) item.getLastState()).getCause());

    verify(disposable).dispose();
    assertThat(disposer.getBacklog(), not(IsEmptyCollection.<AsyncResourceDisposer.WorkItem>empty()));

    int itemId = item.getId();
    HtmlPage page = j.createWebClient().goTo(disposer.getUrl());
    page = page.getFormByName("stop-tracking-" + itemId).getInputByName("submit").click();
    assertThat(page.getWebResponse().getContentAsString(), containsString(disposer.getDisplayName())); // Redirected back

    assertThat(disposer.getBacklog(), emptyCollectionOf(AsyncResourceDisposer.WorkItem.class));
}
项目:crack-the-code    文件:TestFloydWarshallShortestPath.java   
private void assertShortestPath(String[] input) {
    for (String line : input) {
        String[] values = line.split(" ");
        switch (values[0]) {
            case "shortestPath":
                String[] expected = values[3].split(",");
                if (expected[0].equals("empty")) {
                    assertThat(floydWarshall.getShortestPathTo(values[1], values[2]), IsEmptyCollection.empty());
                } else {
                    assertThat(floydWarshall.getShortestPathTo(values[1], values[2]), contains(expected));
                }
                break;
            case "shortestDistance":
                Integer expectedDistance = null;
                if (values[3].equals("infinity")) {
                    expectedDistance = Integer.MAX_VALUE;
                } else if (values[3].equals("-infinity")) {
                    expectedDistance = Integer.MIN_VALUE;
                } else {
                    expectedDistance = Integer.parseInt(values[3]);
                }
                assertThat(floydWarshall.getShortestDistanceTo(values[1], values[2]), is(expectedDistance));
                break;
        }
    }
}
项目:crack-the-code    文件:TestShortestPathDAG.java   
private void assertShortestPath(String[] input) {
    for (String line : input) {
        String[] values = line.split(" ");
        switch (values[0]) {
            case "compute":
                shortestPathDAG.computeShortestPath(values[1]);
                break;
            case "shortestPath":
                String[] expected = values[2].split(",");
                if (expected[0].equals("empty")) {
                    assertThat(shortestPathDAG.getShortestPathTo(values[1]), IsEmptyCollection.empty());
                } else {
                    assertThat(shortestPathDAG.getShortestPathTo(values[1]), contains(expected));
                }
                break;
            case "shortestDistance":
                Integer expectedDistance = Integer.MAX_VALUE;
                if (!values[2].equals("infinity")) {
                    expectedDistance = Integer.parseInt(values[2]);
                }
                assertThat(shortestPathDAG.getShortestDistanceTo(values[1]), is(expectedDistance));
                break;
        }
    }
}
项目:crack-the-code    文件:TestDijkstraShortestPath.java   
private void assertShortestPath(String[] input) {
    for (String line : input) {
        String[] values = line.split(" ");
        switch (values[0]) {
            case "compute":
                dijkstra.computeShortestPath(values[1]);
                break;
            case "shortestPath":
                String[] expected = values[2].split(",");
                if (expected[0].equals("empty")) {
                    assertThat(dijkstra.getShortestPathTo(values[1]), IsEmptyCollection.empty());
                } else {
                    assertThat(dijkstra.getShortestPathTo(values[1]), contains(expected));
                }
                break;
            case "shortestDistance":
                Integer expectedDistance = Integer.MAX_VALUE;
                if (!values[2].equals("infinity")) {
                    expectedDistance = Integer.parseInt(values[2]);
                }
                assertThat(dijkstra.getShortestDistanceTo(values[1]), is(expectedDistance));
                break;
        }
    }
}
项目:jqa-core-framework    文件:AsciiDocRuleSetReaderTest.java   
@Test
public void scriptRules() throws Exception {
    RuleSet ruleSet = RuleSetTestHelper.readRuleSet("/javascript-rules.adoc");
    ConceptBucket concepts = ruleSet.getConceptBucket();
    assertThat(concepts.size(), equalTo(1));

    Concept concept1 = concepts.getById("concept:JavaScript");
    assertThat(concept1.getId(), equalTo("concept:JavaScript"));
    assertThat(concept1.getDescription(), containsString("Demonstrates a concept using JavaScript."));
    assertThat(concept1.getRequiresConcepts().keySet(), IsEmptyCollection.<String> empty());

    Executable executable = concept1.getExecutable();
    assertThat(executable, instanceOf(ScriptExecutable.class));

    ScriptExecutable scriptExecutable = (ScriptExecutable) executable;
    assertThat(scriptExecutable, notNullValue());
    assertThat(scriptExecutable.getLanguage(), equalTo("javascript"));
    assertThat(scriptExecutable.getSource(), CoreMatchers.containsString("var row = new java.util.HashMap();"));
    assertEquals(Collections.emptyMap(), concept1.getRequiresConcepts());
}
项目:datacollector    文件:AbstractMysqlSource.java   
@Test
public void shouldIncludeAndIgnoreTables() throws Exception {
  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  config.includeTables = "test.foo,t%.foo2";
  config.ignoreTables = "test.foo";
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");
  execute(ds, "INSERT INTO foo2 VALUES (1, 2, 3)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, hasSize(1));
  assertThat(records.get(0).get("/Table").getValueAsString(), is("foo2"));
  execute(ds, "TRUNCATE foo");
  execute(ds, "TRUNCATE foo2");
}
项目:datacollector    文件:AbstractMysqlSource.java   
@Test
public void shouldIgnoreEmptyFilters() throws Exception {
  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  config.includeTables = "";
  config.ignoreTables = "";
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");
  execute(ds, "INSERT INTO foo2 VALUES (1, 2, 3)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, hasSize(2));
}
项目:datacollector    文件:AbstractMysqlSource.java   
@Test
public void shouldReturnCorrectOffsetForFilteredOutEvents() throws Exception {
  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  config.ignoreTables = "test.foo";
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "INSERT INTO foo (bar) VALUES (1)");

  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  List<Record> records = output.getRecords().get(LANE);
  assertThat(records, is(empty()));
  assertThat(output.getNewOffset(), not(isEmptyString()));
}
项目:datakernel    文件:OTStateManagerTest.java   
@Test
public void testRebaseConflictResolving() throws OTTransformException {
    List<Integer> commitIdSequence = IntStream.rangeClosed(0, 2).boxed().collect(toList());
    OTRemote<Integer, TestOp> remote = create(of(commitIdSequence), comparator);
    TestOpState testOpState = new TestOpState();
    OTAlgorithms<Integer, TestOp> algorithms = new OTAlgorithms<>(eventloop, system, remote, comparator);
    OTStateManager<Integer, TestOp> stateManager = new OTStateManager<>(eventloop, algorithms, testOpState);

    createRootAndStartManager(remote, stateManager);

    remote.createCommitId()
            .thenCompose(id -> remote.push(asList(ofCommit(id, 0, asList(set(0, 10))))))
            .thenCompose($ -> stateManager.fetch());
    eventloop.run();

    assertEquals(0, testOpState.getValue());

    stateManager.add(set(0, 15));
    stateManager.rebase();

    eventloop.run();
    assertEquals(10, testOpState.getValue());
    assertThat(stateManager.getWorkingDiffs(), IsEmptyCollection.empty());
}
项目:datakernel    文件:OTStateManagerTest.java   
@Test
public void testRebaseConflictResolving3() throws OTTransformException {
    List<Integer> commitIdSequence = IntStream.rangeClosed(0, 2).boxed().collect(toList());
    OTRemote<Integer, TestOp> otRemote = create(of(commitIdSequence), comparator);
    TestOpState testOpState = new TestOpState();
    OTAlgorithms<Integer, TestOp> algorithms = new OTAlgorithms<>(eventloop, system, otRemote, comparator);
    OTStateManager<Integer, TestOp> stateManager = new OTStateManager<>(eventloop, algorithms, testOpState);

    createRootAndStartManager(otRemote, stateManager);

    otRemote.createCommitId()
            .thenCompose(id -> otRemote.push(asList(ofCommit(id, 0, asList(set(0, 10))))))
            .thenCompose($ -> stateManager.fetch());
    eventloop.run();

    assertEquals(0, testOpState.getValue());

    stateManager.add(add(5));
    stateManager.rebase();

    eventloop.run();
    assertEquals(10, testOpState.getValue());
    assertThat(stateManager.getWorkingDiffs(), IsEmptyCollection.empty());
}
项目:datakernel    文件:CubeOTTest.java   
@Test
public void test() throws OTTransformException {
    LogFile logFile = new LogFile("file", 1);
    List<String> fields = asList("field1", "field2");
    LogDiff<CubeDiff> changesLeft = LogDiff.of(
            singletonMap("clicks", positionDiff(logFile, 0, 10)),
            cubeDiff("key", chunk(1, fields, ofArray("str", 10), ofArray("str", 20), 15)));

    LogDiff<CubeDiff> changesRight = LogDiff.of(
            singletonMap("clicks", positionDiff(logFile, 0, 20)),
            cubeDiff("key", chunk(1, fields, ofArray("str", 10), ofArray("str", 25), 30)));
    TransformResult<LogDiff<CubeDiff>> transform = logSystem.transform(changesLeft, changesRight);

    assertTrue(transform.hasConflict());
    assertEquals(ConflictResolution.RIGHT, transform.resolution);
    assertThat(transform.right, IsEmptyCollection.empty());

    LogDiff<CubeDiff> result = LogDiff.of(
            singletonMap("clicks", positionDiff(logFile, 10, 20)),
            cubeDiff("key", addedChunks(changesRight.diffs), addedChunks(changesLeft.diffs)));

    assertEquals(1, transform.left.size());
    assertEquals(result, transform.left.get(0));
}
项目:statistics    文件:MutableTreeNodeTest.java   
@Test
public void testCleanDisconnects() {
  MutableTreeNode test = new MutableTreeNode(null);

  MutableTreeNode child = new MutableTreeNode(null);
  MutableTreeNode parent = new MutableTreeNode(null);

  test.addChild(child);
  parent.addChild(test);
  parent.addChild(child);

  test.clean();

  assertThat(test.getChildren(), IsEmptyCollection.empty());
  assertThat(test.getAncestors(), IsEmptyCollection.empty());

  assertThat(parent.getChildren(), hasSize(1));
  assertThat(parent.getChildren(), IsIterableContainingInOrder.contains(child));

  assertThat(child.getAncestors(), hasSize(1));
  assertThat(child.getAncestors(), IsIterableContainingInOrder.contains(parent));
}
项目:statistics    文件:PassThroughStatisticTest.java   
@Test
public void testClean() {
  StatisticsManager.createPassThroughStatistic(this, "mystat",
      Collections.emptySet(), COUNTER, () -> 12);

  assertTrue(PassThroughStatistic.hasStatisticsFor(this));

  StatisticsManager.nodeFor(this).clean();

  assertFalse(PassThroughStatistic.hasStatisticsFor(this));

  StatisticsManager manager = new StatisticsManager();
  manager.root(this);

  Query query = queryBuilder().descendants().filter(context(attributes(hasAttribute("name", "mystat")))).build();
  Set<TreeNode> nodes = manager.query(query);
  assertThat(nodes, IsEmptyCollection.empty());
}
项目:spring-data-solr    文件:ITestSolrRepositoryOperations.java   
@Test
public void testQueryWithHighlight() {
    HighlightPage<ProductBean> page = repo.findByNameHighlightAll("na", new PageRequest(0, 10));
    Assert.assertEquals(3, page.getNumberOfElements());

    for (ProductBean product : page) {
        List<Highlight> highlights = page.getHighlights(product);
        Assert.assertThat(highlights, IsNot.not(IsEmptyCollection.empty()));
        for (Highlight highlight : highlights) {
            Assert.assertEquals("name", highlight.getField().getName());
            Assert.assertThat(highlight.getSnipplets(), IsNot.not(IsEmptyCollection.empty()));
            for (String s : highlight.getSnipplets()) {
                Assert.assertTrue("expected to find <em>name</em> but was \"" + s + "\"", s.contains("<em>name</em>"));
            }
        }
    }
}
项目:spring-data-solr    文件:ITestSolrRepositoryOperations.java   
@Test
public void testHighlightWithPrefixPostfix() {
    HighlightPage<ProductBean> page = repo.findByNameHighlightAllWithPreAndPostfix("na", new PageRequest(0, 10));
    Assert.assertEquals(3, page.getNumberOfElements());

    for (ProductBean product : page) {
        List<Highlight> highlights = page.getHighlights(product);
        Assert.assertThat(highlights, IsNot.not(IsEmptyCollection.empty()));
        for (Highlight highlight : highlights) {
            Assert.assertEquals("name", highlight.getField().getName());
            Assert.assertThat(highlight.getSnipplets(), IsNot.not(IsEmptyCollection.empty()));
            for (String s : highlight.getSnipplets()) {
                Assert.assertTrue("expected to find <b>name</b> but was \"" + s + "\"", s.contains("<b>name</b>"));
            }
        }
    }
}
项目:spring-data-solr    文件:ITestSolrRepositoryOperations.java   
@Test
public void testHighlightWithFields() {
    ProductBean beanWithText = createProductBean("withName", 5, true);
    beanWithText.setDescription("some text with name in it");
    repo.save(beanWithText);

    HighlightPage<ProductBean> page = repo.findByNameHighlightAllLimitToFields("na", new PageRequest(0, 10));
    Assert.assertEquals(4, page.getNumberOfElements());

    for (ProductBean product : page) {
        List<Highlight> highlights = page.getHighlights(product);
        if (!product.getId().equals(beanWithText.getId())) {
            Assert.assertThat(highlights, IsEmptyCollection.empty());
        } else {
            Assert.assertThat(highlights, IsNot.not(IsEmptyCollection.empty()));
            for (Highlight highlight : highlights) {
                Assert.assertEquals("description", highlight.getField().getName());
                Assert.assertThat(highlight.getSnipplets(), IsNot.not(IsEmptyCollection.empty()));
                for (String s : highlight.getSnipplets()) {
                    Assert.assertTrue("expected to find <em>name</em> but was \"" + s + "\"", s.contains("<em>name</em>"));
                }
            }
        }
    }
}
项目:javaOIDCMsg    文件:PayloadDeserializerTest.java   
@Test
public void shouldGetEmptyStringArrayWhenParsingEmptyTextNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    TextNode textNode = new TextNode("");
    tree.put("key", textNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsEmptyCollection.empty()));
}
项目:JWTDecode.Android    文件:ClaimImplTest.java   
@Test
public void shouldGetEmptyListIfNullValue() throws Exception {
    JsonElement value = gson.toJsonTree(null);
    ClaimImpl claim = new ClaimImpl(value);

    assertThat(claim.asList(String.class), is(notNullValue()));
    assertThat(claim.asList(String.class), is(IsEmptyCollection.emptyCollectionOf(String.class)));
}
项目:JWTDecode.Android    文件:ClaimImplTest.java   
@Test
public void shouldGetEmptyListIfNonArrayValue() throws Exception {
    JsonElement value = gson.toJsonTree(1);
    ClaimImpl claim = new ClaimImpl(value);

    assertThat(claim.asList(String.class), is(notNullValue()));
    assertThat(claim.asList(String.class), is(IsEmptyCollection.emptyCollectionOf(String.class)));
}
项目:JWTDecode.Android    文件:JWTTest.java   
@Test
public void shouldGetEmptyListAudienceIfMissing() throws Exception {
    JWT jwt = new JWT("eyJhbGciOiJIUzI1NiJ9.e30.something");
    assertThat(jwt, is(notNullValue()));

    Assert.assertThat(jwt.getAudience(), IsEmptyCollection.<String>empty());
}
项目:crack-the-code    文件:TestBellmanFordShortestPath.java   
private void assertShortestPath(String[] input) {
    for (String line : input) {
        String[] values = line.split(" ");
        switch (values[0]) {
            case "compute":
                bellmanFord.computeShortestPath(values[1]);
                break;
            case "shortestPath":
                String[] expected = values[2].split(",");
                if (expected[0].equals("empty")) {
                    assertThat(bellmanFord.getShortestPathTo(values[1]), IsEmptyCollection.empty());
                } else {
                    assertThat(bellmanFord.getShortestPathTo(values[1]), contains(expected));
                }
                break;
            case "shortestDistance":
                Integer expectedDistance = null;
                if (values[2].equals("infinity")) {
                    expectedDistance = Integer.MAX_VALUE;
                } else if (values[2].equals("-infinity")) {
                    expectedDistance = Integer.MIN_VALUE;
                } else {
                    expectedDistance = Integer.parseInt(values[2]);
                }
                assertThat(bellmanFord.getShortestDistanceTo(values[1]), is(expectedDistance));
                break;
        }
    }
}
项目:jqa-core-framework    文件:AsciiDocRuleSetReaderTest.java   
@Test
public void cypherRules() throws Exception {
    RuleSet ruleSet = RuleSetTestHelper.readRuleSet("/junit-without-assert.adoc");
    ConceptBucket concepts = ruleSet.getConceptBucket();
    assertThat(concepts.size(), equalTo(2));

    Concept concept1 = concepts.getById("junit4:TestClassOrMethod");
    assertThat(concept1.getId(), equalTo("junit4:TestClassOrMethod"));
    assertThat(concept1.getDescription(), CoreMatchers.containsString("labels them and their containing classes with `:Test` and `:Junit4`."));

    Executable executable1 = concept1.getExecutable();
    assertThat(executable1, instanceOf(CypherExecutable.class));
    assertThat(((CypherExecutable) executable1).getStatement(), containsString("c:Test:Junit4, m:Test:Junit4"));
    assertThat(concept1.getRequiresConcepts().keySet(), IsEmptyCollection.<String> empty());

    Concept concept2 = concepts.getById("junit4:AssertMethod");
    assertThat(concept2.getId(), containsString("junit4:AssertMethod"));
    assertThat(concept2.getDescription(), containsString("Labels all assertion methods declared by `org.junit.Assert` with `:Assert`."));

    Executable executable2 = concept2.getExecutable();
    assertThat(executable2, instanceOf(CypherExecutable.class));
    assertThat(((CypherExecutable) executable2).getStatement(), containsString("and assertMethod.signature =~ 'void assert.*'"));
    assertThat(concept2.getRequiresConcepts().keySet(), IsEmptyCollection.<String> empty());

    ConstraintBucket constraints = ruleSet.getConstraintBucket();
    assertThat(constraints.size(), equalTo(1));

    Constraint constraint = constraints.getById("junit4:TestMethodWithoutAssertion");
    assertThat(constraint.getId(), containsString("junit4:TestMethodWithoutAssertion"));
    assertThat(constraint.getDescription(), containsString("All test methods must perform assertions."));
    assertEquals("junit4:TestMethodWithoutAssertion", constraint.getId());
    assertEquals("All test methods must perform assertions.", constraint.getDescription());

    Executable constraintExecutable = constraint.getExecutable();
    assertThat(constraintExecutable, instanceOf(CypherExecutable.class));
    assertThat(((CypherExecutable) constraintExecutable).getStatement(), containsString("not (testMethod)-[:INVOKES*]->(:Method:Assert)"));

    assertThat(ruleSet.getConceptBucket().getIds(), containsInAnyOrder(constraint.getRequiresConcepts().keySet().toArray()));
}
项目:auth0-spring-security-api    文件:AuthenticationJsonWebTokenTest.java   
@Test
public void shouldGetEmptyAuthoritiesOnMissingScopeClaim() throws Exception {
    String token = JWT.create()
            .sign(hmacAlgorithm);

    AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
项目:auth0-spring-security-api    文件:AuthenticationJsonWebTokenTest.java   
@Test
public void shouldGetEmptyAuthoritiesOnEmptyScopeClaim() throws Exception {
    String token = JWT.create()
            .withClaim("scope", "   ")
            .sign(hmacAlgorithm);

    AuthenticationJsonWebToken auth = new AuthenticationJsonWebToken(token, verifier);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
项目:auth0-spring-security-api    文件:PreAuthenticatedAuthenticationJsonWebTokenTest.java   
@Test
public void shouldGetEmptyAuthoritiesOnMissingScopeClaim() throws Exception {
    String token = JWT.create()
            .sign(hmacAlgorithm);

    PreAuthenticatedAuthenticationJsonWebToken auth = usingToken(token);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
项目:auth0-spring-security-api    文件:PreAuthenticatedAuthenticationJsonWebTokenTest.java   
@Test
public void shouldAlwaysGetEmptyAuthorities() throws Exception {
    String token = JWT.create()
            .withClaim("scope", "read:users add:users")
            .sign(hmacAlgorithm);

    PreAuthenticatedAuthenticationJsonWebToken auth = usingToken(token);
    assertThat(auth, is(notNullValue()));
    assertThat(auth.getAuthorities(), is(notNullValue()));
    assertThat(auth.getAuthorities(), is(IsEmptyCollection.empty()));
}
项目:SinCity    文件:FinishedBuildWithChangesTest.java   
@Test
public void test02RepeatedBuild() {

    /*
        Scenario: build1 and build2 run in sequence (e.g. VCS-triggered), then build3 runs with no changes in it
        (e.g. triggered manually by a user).

                    time --------->
        change 1 -> build1
        change 2
        change 3 ->        build2 build3
     */

    // arrange
    mockery.checking(new Expectations() {{
        oneOf(build3).getContainingChanges(); will(returnValue(new ArrayList<SVcsModification>()));
        oneOf(build2).getContainingChanges(); will(returnValue(Arrays.asList(change3, change2)));
        oneOf(build1).getContainingChanges(); will(returnValue(Collections.singletonList(change1)));
    }});

    // act
    List<FinishedBuildWithChanges> list = FinishedBuildWithChanges.getListFromBuildType(buildType);

    // assert
    mockery.assertIsSatisfied();

    assertThat(list.get(0).getBuild(), is(build3));
    assertThat(list.get(0).getLastChange(), is(change3));
    assertThat(list.get(0).getChangeDelta(), IsEmptyCollection.empty());
    assertThat(list.get(1).getBuild(), is(build2));
    assertThat(list.get(1).getLastChange(), is(change3));
    assertThat(list.get(1).getChangeDelta(), IsIterableContainingInOrder.contains(Arrays.asList(change3, change2).toArray()));
    assertThat(list.get(2).getBuild(), is(build1));
    assertThat(list.get(2).getLastChange(), is(change1));
    assertThat(list.get(2).getChangeDelta(), IsIterableContainingInOrder.contains(change1));

}
项目:datacollector    文件:AbstractMysqlSource.java   
@Test
public void shouldStartFromCurrent() throws Exception {
  execute(ds, "INSERT INTO foo (bar) VALUES (1)");

  MysqlSourceConfig config = createConfig("root");
  config.startFromBeginning = false;
  MysqlSource source = createMysqlSource(config);
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, MAX_BATCH_SIZE);
  List<Record> records = new ArrayList<>();

  while (!output.getRecords().get(LANE).isEmpty()) {
    records.addAll(output.getRecords().get(LANE));
    output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  }
  assertThat(records, is(IsEmptyCollection.<Record>empty()));

  // add one more
  execute(ds, "INSERT INTO foo (bar) VALUES (2)");
  output = runner.runProduce(output.getNewOffset(), MAX_BATCH_SIZE);
  records.addAll(output.getRecords().get(LANE));

  Record found = null;
  for (Record record : records) {
    if (record.get("/Table").getValueAsString().equals("foo")) {
      found = record;
      break;
    }
  }
  assertThat(found, notNullValue());
  assertThat(found.get("/Data/bar"), is(create(2)));
}
项目:datacollector    文件:AbstractMysqlSource.java   
@Test
public void shouldSendAllEventRecordsDiscardingbatchSize() throws Exception {
  int count = 100;
  for (int i = 0; i < count; i++) {
    execute(ds, String.format("INSERT INTO foo (bar) VALUES (%d)", i));
  }

  MysqlSourceConfig config = createConfig("root");
  MysqlSource source = createMysqlSource(config);
  runner = new SourceRunner.Builder(MysqlDSource.class, source)
      .addOutputLane(LANE)
      .build();
  runner.runInit();

  final String lastSourceOffset = null;
  StageRunner.Output output = runner.runProduce(lastSourceOffset, count);
  assertThat(output.getRecords().get(LANE), is(IsEmptyCollection.<Record>empty()));

  execute(ds, "DELETE FROM foo");

  output = runner.runProduce(output.getNewOffset(), count / 2);

  List<Record> records = new ArrayList<>();
  records.addAll(output.getRecords().get(LANE));

  assertThat(records, hasSize(count));
}
项目:statistics    文件:ContextRootingTest.java   
@Test
public void testRootRemoval() {
  ContextManager manager = new ContextManager();

  Object root = new NoAnnotations();
  manager.root(root);
  manager.uproot(root);

  Collection<TreeNode> roots = manager.query(queryBuilder().children().build());

  assertThat(roots, IsEmptyCollection.empty());
}
项目:statistics    文件:ContextRootingTest.java   
@Test
public void testDoubleRootRemoval() {
  ContextManager manager = new ContextManager();

  Object root = new NoAnnotations();
  manager.root(root);
  manager.root(root);
  manager.uproot(root);

  Collection<TreeNode> roots = manager.query(queryBuilder().children().build());

  assertThat(roots, IsEmptyCollection.empty());
}
项目:statistics    文件:FilterTest.java   
@Test
public void testAlwaysFailMatcher() {
  Set<TreeNode> input = new HashSet<>();
  input.add(createTreeNode(A.class));
  input.add(createTreeNode(B.class));

  assertThat(buildQuery(new Matcher<TreeNode>() {
    @Override
    protected boolean matchesSafely(TreeNode object) {
      return false;
    }
  }).execute(input), IsEmptyCollection.empty());
}
项目:statistics    文件:DescendantsTest.java   
@Test
public void testMultipleNodesWithNoDescendants() {
  Set<TreeNode> nodes = new HashSet<>();
  nodes.add(createTreeNode(A.class));
  nodes.add(createTreeNode(B.class));
  assertThat(query.execute(nodes), IsEmptyCollection.empty());
}
项目:statistics    文件:ChildrenTest.java   
@Test
public void testMultipleNodesWithNoChildren() {
  Set<TreeNode> nodes = new HashSet<>();
  nodes.add(createTreeNode(A.class));
  nodes.add(createTreeNode(B.class));
  assertThat(query.execute(nodes), IsEmptyCollection.empty());
}
项目:statistics    文件:StatisticSamplerTest.java   
@Test
public void testLongPeriodSampler() throws InterruptedException {
  StatisticArchive<Integer> archive = new StatisticArchive<>(1);
  StatisticSampler<Integer> sampler = new StatisticSampler<>(1L, TimeUnit.HOURS, counter(() -> {
    throw new AssertionError();
  }), archive);
  try {
    sampler.start();
    TimeUnit.SECONDS.sleep(1);
    assertThat(archive.getArchive(), IsEmptyCollection.empty());
  } finally {
    sampler.shutdown();
  }
}
项目:hapi-fhir    文件:XmlParserDstu3Test.java   
/**
 * See #216
 */
@Test
public void testParseMalformedIdentifierDstu2() {

    // This was changed from 0.5 to 1.0.0

    String out = "<Patient xmlns=\"http://hl7.org/fhir\">\n" +
        "   <identifier>\n" +
        "      <type value=\"MRN\"/>\n" +
        "      <system value=\"SYS\"/>\n" +
        "      <value value=\"VAL\"/>\n" +
        "   </identifier>\n" +
        "</Patient>";

    IParserErrorHandler errorHandler = mock(IParserErrorHandler.class);

    IParser p = ourCtx.newXmlParser();
    p.setParserErrorHandler(errorHandler);

    Patient patient = p.parseResource(Patient.class, out);
    assertThat(patient.getIdentifier().get(0).getType().getCoding(), IsEmptyCollection.empty());

    ArgumentCaptor<String> capt = ArgumentCaptor.forClass(String.class);
    verify(errorHandler, times(1)).unknownAttribute(any(IParseLocation.class), capt.capture());

    assertEquals("value", capt.getValue());
}
项目:hapi-fhir    文件:XmlParserDstu2_1Test.java   
/**
 * See #216
 */
@Test
public void testParseMalformedIdentifierDstu2() {

    // This was changed from 0.5 to 1.0.0

    //@formatter:off
    String out = "<Patient xmlns=\"http://hl7.org/fhir\">\n" + 
            "   <identifier>\n" + 
            "      <type value=\"MRN\"/>\n" + 
            "      <system value=\"SYS\"/>\n" + 
            "      <value value=\"VAL\"/>\n" + 
            "   </identifier>\n" + 
            "</Patient>";
    //@formatter:on

    IParserErrorHandler errorHandler = mock(IParserErrorHandler.class);

    IParser p = ourCtx.newXmlParser();
    p.setParserErrorHandler(errorHandler);

    Patient patient = p.parseResource(Patient.class, out);
    assertThat(patient.getIdentifier().get(0).getType().getCoding(), IsEmptyCollection.empty());

    ArgumentCaptor<String> capt = ArgumentCaptor.forClass(String.class);
    verify(errorHandler, times(1)).unknownAttribute(any(IParseLocation.class), capt.capture());

    assertEquals("value", capt.getValue());
}
项目:hapi-fhir    文件:XmlParserDstu2Test.java   
/**
 * See #216
 */
@Test
public void testParseMalformedIdentifierDstu2() {

    // This was changed from 0.5 to 1.0.0

    //@formatter:off
    String out = "<Patient xmlns=\"http://hl7.org/fhir\">\n" + 
            "   <identifier>\n" + 
            "      <type value=\"MRN\"/>\n" + 
            "      <system value=\"SYS\"/>\n" + 
            "      <value value=\"VAL\"/>\n" + 
            "   </identifier>\n" + 
            "</Patient>";
    //@formatter:on

    IParserErrorHandler errorHandler = mock(IParserErrorHandler.class);

    IParser p = ourCtx.newXmlParser();
    p.setParserErrorHandler(errorHandler);

    Patient patient = p.parseResource(Patient.class, out);
    assertThat(patient.getIdentifier().get(0).getType().getValueAsEnum(), IsEmptyCollection.empty());

    ArgumentCaptor<String> capt = ArgumentCaptor.forClass(String.class);
    verify(errorHandler, times(1)).unknownAttribute(any(IParseLocation.class), capt.capture());

    assertEquals("value", capt.getValue());
}
项目:java-jwt    文件:PayloadDeserializerTest.java   
@Test
public void shouldGetEmptyStringArrayWhenParsingEmptyTextNode() throws Exception {
    Map<String, JsonNode> tree = new HashMap<>();
    TextNode textNode = new TextNode("");
    tree.put("key", textNode);

    List<String> values = deserializer.getStringOrArray(tree, "key");
    assertThat(values, is(notNullValue()));
    assertThat(values, is(IsEmptyCollection.empty()));
}