@Test
public void shouldGetMapValue() throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("text", "extraValue");
map.put("number", 12);
map.put("boolean", true);
map.put("object", Collections.singletonMap("something", "else"));
JsonNode value = mapper.valueToTree(map);
Claim claim = claimFromNode(value);
assertThat(claim, is(notNullValue()));
Map<String, Object> backMap = claim.asMap();
assertThat(backMap, is(notNullValue()));
assertThat(backMap, hasEntry("text", (Object) "extraValue"));
assertThat(backMap, hasEntry("number", (Object) 12));
assertThat(backMap, hasEntry("boolean", (Object) true));
assertThat(backMap, hasKey("object"));
assertThat((Map<String, Object>) backMap.get("object"), IsMapContaining.hasEntry("something", (Object) "else"));
}
java类org.hamcrest.collection.IsMapContaining的实例源码
JsonNodeClaimTest.java 文件源码
项目:javaOIDCMsg
阅读 35
收藏 0
点赞 0
评论 0
JsonToRecordParserV2dTest.java 文件源码
项目:metrics-aggregator-daemon
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void testAnnotations() throws ParsingException, IOException {
final Record record = parseRecord("QueryLogParserV2dTest/testAnnotations.json");
Assert.assertNotNull(record);
Assert.assertEquals(DateTime.parse("2014-03-24T12:15:41.010Z"), record.getTime());
Assert.assertNotNull(record.getAnnotations());
Assert.assertEquals(2, record.getAnnotations().size());
Assert.assertThat(record.getAnnotations(), IsMapContaining.hasEntry("method", "POST"));
Assert.assertThat(record.getAnnotations(), IsMapContaining.hasEntry("request_id", "c5251254-8f7c-4c21-95da-270eb66e100b"));
Assert.assertEquals(3, record.getDimensions().size());
Assert.assertEquals("MyHost", record.getDimensions().get(Key.HOST_DIMENSION_KEY));
Assert.assertEquals("MyService", record.getDimensions().get(Key.SERVICE_DIMENSION_KEY));
Assert.assertEquals("MyCluster", record.getDimensions().get(Key.CLUSTER_DIMENSION_KEY));
}
Metadata.java 文件源码
项目:https-github.com-g0t4-jenkins2-course-spring-boot
阅读 22
收藏 0
点赞 0
评论 0
@Override
public boolean matches(ItemHint hint) {
if (this.index + 1 > hint.getProviders().size()) {
return false;
}
ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
if (this.name != null && !this.name.equals(valueProvider.getName())) {
return false;
}
if (this.parameters != null) {
for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
.matches(valueProvider.getParameters())) {
return false;
}
}
}
return true;
}
Metadata.java 文件源码
项目:spring-boot-concourse
阅读 33
收藏 0
点赞 0
评论 0
@Override
public boolean matches(ItemHint hint) {
if (this.index + 1 > hint.getProviders().size()) {
return false;
}
ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
if (this.name != null && !this.name.equals(valueProvider.getName())) {
return false;
}
if (this.parameters != null) {
for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
.matches(valueProvider.getParameters())) {
return false;
}
}
}
return true;
}
ConfigurationMetadataMatchers.java 文件源码
项目:contestparser
阅读 23
收藏 0
点赞 0
评论 0
@Override
public boolean matches(Object item) {
ItemHint hint = (ItemHint) item;
if (this.index + 1 > hint.getProviders().size()) {
return false;
}
ItemHint.ValueProvider valueProvider = hint.getProviders().get(this.index);
if (this.name != null && !this.name.equals(valueProvider.getName())) {
return false;
}
if (this.parameters != null) {
for (Map.Entry<String, Object> entry : this.parameters.entrySet()) {
if (!IsMapContaining.hasEntry(entry.getKey(), entry.getValue())
.matches(valueProvider.getParameters())) {
return false;
}
}
}
return true;
}
EventHandlingTest.java 文件源码
项目:hsm-java
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void initWithPayload() {
// given
Action a1Enter = new Action() {
@Override
public void run() {
// then
assertThat(mPayload, IsMapContaining.hasKey("foo"));
}
};
State a1 = new State("a1").onEnter(a1Enter);
StateMachine sm = new StateMachine(a1);
Map<String, Object> payload = new HashMap<String, Object>();
payload.put("foo", "bar");
// when
sm.init(payload);
}
EventHandlingTest.java 文件源码
项目:hsm-java
阅读 29
收藏 0
点赞 0
评论 0
@Test
public void teardownWithPayload() {
// when
State a1 = new State("a1");
State a = new Sub("a", a1);
State b1 = new State("b1").onEnter(new Action() {
@Override
public void run() {
assertThat(mPayload, IsMapContaining.hasKey("foo"));
}
});
a1.addHandler("T1", b1, TransitionKind.External).onExit(new Action() {
@Override
public void run() {
mPayload.put("foo", "bar");
}
});
State b = new Sub("b", a, b1);
StateMachine sm = new StateMachine(b);
sm.init();
sm.handleEvent("T1");
}
JsonNodeClaimTest.java 文件源码
项目:java-jwt
阅读 34
收藏 0
点赞 0
评论 0
@Test
public void shouldGetMapValue() throws Exception {
Map<String, Object> map = new HashMap<>();
map.put("text", "extraValue");
map.put("number", 12);
map.put("boolean", true);
map.put("object", Collections.singletonMap("something", "else"));
JsonNode value = mapper.valueToTree(map);
Claim claim = claimFromNode(value);
assertThat(claim, is(notNullValue()));
Map<String, Object> backMap = claim.asMap();
assertThat(backMap, is(notNullValue()));
assertThat(backMap, hasEntry("text", (Object) "extraValue"));
assertThat(backMap, hasEntry("number", (Object) 12));
assertThat(backMap, hasEntry("boolean", (Object) true));
assertThat(backMap, hasKey("object"));
assertThat((Map<String, Object>) backMap.get("object"), IsMapContaining.hasEntry("something", (Object) "else"));
}
ClaimsHolderTest.java 文件源码
项目:javaOIDCMsg
阅读 25
收藏 0
点赞 0
评论 0
@SuppressWarnings("RedundantCast")
@Test
public void shouldGetClaims() throws Exception {
HashMap<String, Object> claims = new HashMap<>();
claims.put("iss", "auth0");
ClaimsHolder holder = new ClaimsHolder(claims);
assertThat(holder, is(notNullValue()));
assertThat(holder.getClaims(), is(notNullValue()));
assertThat(holder.getClaims(), is(instanceOf(Map.class)));
assertThat(holder.getClaims(), is(IsMapContaining.hasEntry("iss", (Object) "auth0")));
}
BasicHeaderTest.java 文件源码
项目:javaOIDCMsg
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void shouldHaveTree() throws Exception {
HashMap<String, JsonNode> map = new HashMap<>();
JsonNode node = NullNode.getInstance();
map.put("key", node);
BasicHeader header = new BasicHeader(null, null, null, null, map);
assertThat(header.getTree(), is(notNullValue()));
assertThat(header.getTree(), is(IsMapContaining.hasEntry("key", node)));
}
DomainSerialiserTest.java 文件源码
项目:swblocks-decisiontree
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testOutputConversionToMap() {
final List<String> outputlist = new ArrayList<>();
outputlist.add("Driver1:Value1");
outputlist.add("Driver2:Value2");
outputlist.add("Driver3:Value3");
final Map<String, String> outputMap = DomainSerialiser.convertOutputs(outputlist);
assertEquals(3, outputMap.size());
assertThat(outputMap, IsMapContaining.hasEntry("Driver1", "Value1"));
assertThat(outputMap, IsMapContaining.hasEntry("Driver2", "Value2"));
assertThat(outputMap, IsMapContaining.hasEntry("Driver3", "Value3"));
}
DomainSerialiserTest.java 文件源码
项目:swblocks-decisiontree
阅读 29
收藏 0
点赞 0
评论 0
@Test
public void testInvalidOutputConversion() {
final List<String> outputlist = new ArrayList<>();
outputlist.add("Driver1:Value1");
outputlist.add("Driver2Value2");
outputlist.add("Driver3:Value3");
final Map<String, String> outputMap = DomainSerialiser.convertOutputs(outputlist);
assertEquals(2, outputMap.size());
assertThat(outputMap, IsMapContaining.hasEntry("Driver1", "Value1"));
assertThat(outputMap, IsMapContaining.hasEntry("Driver3", "Value3"));
}
TestHTTPFormManager.java 文件源码
项目:jmeter-formman
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void testNoModificationIfNoFormMatches() throws Exception {
instance.log.info("testNoModificationIfNoFormMatches");
sampler.setPath("/base/no-match");
sampler.addArgument("name", "value");
instance.process();
Map<String, String> args = sampler.getArguments().getArgumentsAsMap();
assertThat(args.size(), is(1));
assertThat(args, IsMapContaining.hasEntry("name", "value"));
}
TestHTTPFormManager.java 文件源码
项目:jmeter-formman
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void testFormIsSelectedByMethodAndURL() throws Exception {
instance.log.info("testFormIsSelectedByMethodAndURL");
sampler.setMethod("GET");
instance.process();
Map<String, String> args = sampler.getArguments().getArgumentsAsMap();
assertThat(args.size(), is(1));
assertThat(args, IsMapContaining.hasEntry("hidden_input", "hidden_value3"));
}
TestHTTPFormManager.java 文件源码
项目:jmeter-formman
阅读 26
收藏 0
点赞 0
评论 0
@Test
public void testNoModificationToExplicitValue() throws Exception {
instance.log.info("testNoModificationToExplicitValue");
sampler.setPath("/other-form");
sampler.addArgument("text_input", "explicit_value");
instance.process();
Map<String, String> args = sampler.getArguments().getArgumentsAsMap();
assertThat(args.size(), is(2));
assertThat(args, IsMapContaining.hasEntry("hidden_input", "hidden_value"));
assertThat(args, IsMapContaining.hasEntry("text_input", "explicit_value"));
}
TestHTTPFormManager.java 文件源码
项目:jmeter-formman
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void testFormIsSelectedByExplicitSubmit() throws Exception {
instance.log.info("testFormIsSelectedByExplicitSubmit");
sampler.addArgument("submit", "submit_value3");
instance.process();
Map<String, String> args = sampler.getArguments().getArgumentsAsMap();
assertThat(args.size(), is(2));
assertThat(args, IsMapContaining.hasEntry("submit", "submit_value3"));
assertThat(args, IsMapContaining.hasEntry("hidden_input", "hidden_value2"));
}
TestHTTPFormManager.java 文件源码
项目:jmeter-formman
阅读 30
收藏 0
点赞 0
评论 0
@Test
public void testNoModificationIfAmbiguous() throws Exception {
instance.log.info("testNoModificationIfAmbiguous");
sampler.addArgument("submit", "submit_value2");
instance.process();
Map<String, String> args = sampler.getArguments().getArgumentsAsMap();
assertThat(args.size(), is(1));
assertThat(args, IsMapContaining.hasEntry("submit", "submit_value2"));
}
JsonToRecordParserV2cTest.java 文件源码
项目:metrics-aggregator-daemon
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void testAnnotations() throws ParsingException, IOException {
final Record record = parseRecord("QueryLogParserV2cTest/testAnnotations.json");
Assert.assertNotNull(record);
Assert.assertEquals(3, record.getDimensions().size());
Assert.assertEquals("MyHost", record.getDimensions().get(Key.HOST_DIMENSION_KEY));
Assert.assertEquals("MyService", record.getDimensions().get(Key.SERVICE_DIMENSION_KEY));
Assert.assertEquals("MyCluster", record.getDimensions().get(Key.CLUSTER_DIMENSION_KEY));
Assert.assertEquals(2, record.getAnnotations().size());
Assert.assertThat(record.getAnnotations(), IsMapContaining.hasEntry("method", "POST"));
Assert.assertThat(record.getAnnotations(), IsMapContaining.hasEntry("request_id", "c5251254-8f7c-4c21-95da-270eb66e100b"));
}
BaseRequestTest.java 文件源码
项目:Auth0.Android
阅读 27
收藏 0
点赞 0
评论 0
@Test
public void shouldAddASingleParameter() throws Exception {
baseRequest.addParameter("name", "value");
final Map<String, Object> result = parameterBuilder.asDictionary();
assertThat(result, IsMapWithSize.aMapWithSize(1));
assertThat(result, IsMapContaining.hasEntry("name", (Object) "value"));
}
BaseRequestTest.java 文件源码
项目:Auth0.Android
阅读 36
收藏 0
点赞 0
评论 0
@Test
public void shouldAddParameters() throws Exception {
Map<String, Object> params = new HashMap<>();
params.put("name", "value");
params.put("asd", "123");
baseRequest.addParameters(params);
final Map<String, Object> result = parameterBuilder.asDictionary();
assertThat(result, IsMapWithSize.aMapWithSize(2));
assertThat(result, IsMapContaining.hasEntry("name", (Object) "value"));
assertThat(result, IsMapContaining.hasEntry("asd", (Object) "123"));
}
BaseRequestTest.java 文件源码
项目:Auth0.Android
阅读 33
收藏 0
点赞 0
评论 0
@Test
public void shouldParseUnsuccessfulJsonResponse() throws Exception {
String payload = "{key: \"value\", asd: \"123\"}";
final Response response = createJsonResponse(payload, 401);
baseRequest.parseUnsuccessfulResponse(response);
verify(errorBuilder).from(mapCaptor.capture());
assertThat(mapCaptor.getValue(), IsMapContaining.hasEntry("key", (Object) "value"));
assertThat(mapCaptor.getValue(), IsMapContaining.hasEntry("asd", (Object) "123"));
}
BeamFnDataWriteRunnerTest.java 文件源码
项目:beam
阅读 29
收藏 0
点赞 0
评论 0
@Test
public void testRegistration() {
for (Registrar registrar :
ServiceLoader.load(Registrar.class)) {
if (registrar instanceof BeamFnDataWriteRunner.Registrar) {
assertThat(
registrar.getPTransformRunnerFactories(),
IsMapContaining.hasKey(RemoteGrpcPortWrite.URN));
return;
}
}
fail("Expected registrar not found.");
}
BoundedSourceRunnerTest.java 文件源码
项目:beam
阅读 23
收藏 0
点赞 0
评论 0
@Test
public void testRegistration() {
for (Registrar registrar :
ServiceLoader.load(Registrar.class)) {
if (registrar instanceof BoundedSourceRunner.Registrar) {
assertThat(registrar.getPTransformRunnerFactories(), IsMapContaining.hasKey(URN));
return;
}
}
fail("Expected registrar not found.");
}
BeamFnDataReadRunnerTest.java 文件源码
项目:beam
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void testRegistration() {
for (Registrar registrar :
ServiceLoader.load(Registrar.class)) {
if (registrar instanceof BeamFnDataReadRunner.Registrar) {
assertThat(
registrar.getPTransformRunnerFactories(),
IsMapContaining.hasKey(RemoteGrpcPortRead.URN));
return;
}
}
fail("Expected registrar not found.");
}
FnApiDoFnRunnerTest.java 文件源码
项目:beam
阅读 21
收藏 0
点赞 0
评论 0
@Test
public void testRegistration() {
for (Registrar registrar :
ServiceLoader.load(Registrar.class)) {
if (registrar instanceof FnApiDoFnRunner.Registrar) {
assertThat(registrar.getPTransformRunnerFactories(),
IsMapContaining.hasKey(ParDoTranslation.CUSTOM_JAVA_DO_FN_URN));
return;
}
}
fail("Expected registrar not found.");
}
MapMatchers.java 文件源码
项目:Chateau
阅读 22
收藏 0
点赞 0
评论 0
@SuppressWarnings("unchecked")
private static <K, V> Matcher<Map<? extends K, ? extends V>>[] buildMatcherArray(Map<K, V> map) {
List<Matcher<Map<? extends K, ? extends V>>> entries = new ArrayList<>();
for (K key : map.keySet()) {
entries.add(IsMapContaining.hasEntry(key, map.get(key)));
}
return entries.toArray(new Matcher[entries.size()]);
}
PmmlProcessorIntegrationTests.java 文件源码
项目:spring-cloud-stream-app-starters
阅读 30
收藏 0
点赞 0
评论 0
@Test
public void testEvaluation() {
Map<String, String> payload = new HashMap<>();
payload.put("sepalLength", "6.4");
payload.put("sepalWidth", "3.2");
payload.put("petalLength", "4.5");
payload.put("petalWidth", "1.5");
channels.input().send(MessageBuilder.withPayload(payload).build());
assertThat(messageCollector.forChannel(channels.output()),
receivesPayloadThat(IsMapContaining.hasEntry("predictedSpecies", "versicolor")));
}
PmmlProcessorIntegrationTests.java 文件源码
项目:spring-cloud-stream-app-starters
阅读 28
收藏 0
点赞 0
评论 0
@Test
public void testEvaluation() {
Map<String, Object> payload = new HashMap<>();
Map<String, String> sepal = new HashMap<>();
Map<String, String> petal = new HashMap<>();
payload.put("Sepal", sepal);
payload.put("Petal", petal);
sepal.put("Length", "6.4");
sepal.put("Width", "3.2");
petal.put("Length", "4.5");
petal.put("Width", "1.5");
channels.input().send(MessageBuilder.withPayload(payload).build());
assertThat(messageCollector.forChannel(channels.output()), receivesPayloadThat(IsMapContaining.hasEntry("Predicted_Species", "versicolor")));
}
AppDeploymentRequestCreatorTests.java 文件源码
项目:spring-cloud-dataflow
阅读 25
收藏 0
点赞 0
评论 0
@Test
public void testRequalifyShortWhiteListedProperty() {
StreamAppDefinition appDefinition = new StreamAppDefinition.Builder().setRegisteredAppName("my-app")
.setProperty("timezone", "GMT+2").build("streamname");
Resource app = new ClassPathResource("/apps/whitelist-source");
AppDefinition modified = this.appDeploymentRequestCreator.mergeAndExpandAppProperties(appDefinition, app,
new HashMap<>());
org.junit.Assert.assertThat(modified.getProperties(), IsMapContaining.hasEntry("date.timezone", "GMT+2"));
org.junit.Assert.assertThat(modified.getProperties(), not(IsMapContaining.hasKey("timezone")));
}
AppDeploymentRequestCreatorTests.java 文件源码
项目:spring-cloud-dataflow
阅读 24
收藏 0
点赞 0
评论 0
@Test
public void testSameNamePropertiesOKAsLongAsNotUsedAsShorthand() {
StreamAppDefinition appDefinition = new StreamAppDefinition.Builder().setRegisteredAppName("my-app")
.setProperty("time.format", "hh").setProperty("date.format", "yy").build("streamname");
Resource app = new ClassPathResource("/apps/whitelist-source");
AppDefinition modified = this.appDeploymentRequestCreator.mergeAndExpandAppProperties(appDefinition, app,
new HashMap<>());
org.junit.Assert.assertThat(modified.getProperties(), IsMapContaining.hasEntry("date.format", "yy"));
org.junit.Assert.assertThat(modified.getProperties(), IsMapContaining.hasEntry("time.format", "hh"));
}