@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());
}
java类org.hamcrest.collection.IsEmptyCollection的实例源码
ElasticSearchIndexManualTest.java 文件源码
项目:openmrs-contrib-addonindex
阅读 19
收藏 0
点赞 0
评论 0
AsyncResourceDisposerTest.java 文件源码
项目:resource-disposer-plugin
阅读 21
收藏 0
点赞 0
评论 0
@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));
}
TestFloydWarshallShortestPath.java 文件源码
项目:crack-the-code
阅读 24
收藏 0
点赞 0
评论 0
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;
}
}
}
TestShortestPathDAG.java 文件源码
项目:crack-the-code
阅读 20
收藏 0
点赞 0
评论 0
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;
}
}
}
TestDijkstraShortestPath.java 文件源码
项目:crack-the-code
阅读 24
收藏 0
点赞 0
评论 0
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;
}
}
}
AsciiDocRuleSetReaderTest.java 文件源码
项目:jqa-core-framework
阅读 21
收藏 0
点赞 0
评论 0
@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());
}
AbstractMysqlSource.java 文件源码
项目:datacollector
阅读 22
收藏 0
点赞 0
评论 0
@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");
}
AbstractMysqlSource.java 文件源码
项目:datacollector
阅读 26
收藏 0
点赞 0
评论 0
@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));
}
AbstractMysqlSource.java 文件源码
项目:datacollector
阅读 19
收藏 0
点赞 0
评论 0
@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()));
}
OTStateManagerTest.java 文件源码
项目:datakernel
阅读 24
收藏 0
点赞 0
评论 0
@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());
}
OTStateManagerTest.java 文件源码
项目:datakernel
阅读 22
收藏 0
点赞 0
评论 0
@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());
}
CubeOTTest.java 文件源码
项目:datakernel
阅读 24
收藏 0
点赞 0
评论 0
@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));
}
MutableTreeNodeTest.java 文件源码
项目:statistics
阅读 22
收藏 0
点赞 0
评论 0
@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));
}
PassThroughStatisticTest.java 文件源码
项目:statistics
阅读 25
收藏 0
点赞 0
评论 0
@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());
}
ITestSolrRepositoryOperations.java 文件源码
项目:spring-data-solr
阅读 21
收藏 0
点赞 0
评论 0
@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>"));
}
}
}
}
ITestSolrRepositoryOperations.java 文件源码
项目:spring-data-solr
阅读 26
收藏 0
点赞 0
评论 0
@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>"));
}
}
}
}
ITestSolrRepositoryOperations.java 文件源码
项目:spring-data-solr
阅读 24
收藏 0
点赞 0
评论 0
@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>"));
}
}
}
}
}
PayloadDeserializerTest.java 文件源码
项目:javaOIDCMsg
阅读 23
收藏 0
点赞 0
评论 0
@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()));
}
ClaimImplTest.java 文件源码
项目:JWTDecode.Android
阅读 22
收藏 0
点赞 0
评论 0
@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)));
}
ClaimImplTest.java 文件源码
项目:JWTDecode.Android
阅读 21
收藏 0
点赞 0
评论 0
@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)));
}
JWTTest.java 文件源码
项目:JWTDecode.Android
阅读 20
收藏 0
点赞 0
评论 0
@Test
public void shouldGetEmptyListAudienceIfMissing() throws Exception {
JWT jwt = new JWT("eyJhbGciOiJIUzI1NiJ9.e30.something");
assertThat(jwt, is(notNullValue()));
Assert.assertThat(jwt.getAudience(), IsEmptyCollection.<String>empty());
}
TestBellmanFordShortestPath.java 文件源码
项目:crack-the-code
阅读 25
收藏 0
点赞 0
评论 0
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;
}
}
}
AsciiDocRuleSetReaderTest.java 文件源码
项目:jqa-core-framework
阅读 20
收藏 0
点赞 0
评论 0
@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()));
}
AuthenticationJsonWebTokenTest.java 文件源码
项目:auth0-spring-security-api
阅读 22
收藏 0
点赞 0
评论 0
@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()));
}
AuthenticationJsonWebTokenTest.java 文件源码
项目:auth0-spring-security-api
阅读 24
收藏 0
点赞 0
评论 0
@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()));
}
PreAuthenticatedAuthenticationJsonWebTokenTest.java 文件源码
项目:auth0-spring-security-api
阅读 24
收藏 0
点赞 0
评论 0
@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()));
}
PreAuthenticatedAuthenticationJsonWebTokenTest.java 文件源码
项目:auth0-spring-security-api
阅读 27
收藏 0
点赞 0
评论 0
@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()));
}
FinishedBuildWithChangesTest.java 文件源码
项目:SinCity
阅读 20
收藏 0
点赞 0
评论 0
@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));
}
AbstractMysqlSource.java 文件源码
项目:datacollector
阅读 33
收藏 0
点赞 0
评论 0
@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)));
}
AbstractMysqlSource.java 文件源码
项目:datacollector
阅读 21
收藏 0
点赞 0
评论 0
@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));
}