本文整理汇总了Java中org.hamcrest.collection.IsMapContaining类的典型用法代码示例。如果您正苦于以下问题:Java IsMapContaining类的具体用法?Java IsMapContaining怎么用?Java IsMapContaining使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IsMapContaining类属于org.hamcrest.collection包,在下文中一共展示了IsMapContaining类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldGetMapValue
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例2: testAnnotations
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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));
}
示例3: matches
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:20,代码来源:Metadata.java
示例4: matches
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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;
}
示例5: initWithPayload
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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);
}
示例6: teardownWithPayload
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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");
}
示例7: shouldGetClaims
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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")));
}
示例8: shouldHaveTree
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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)));
}
示例9: testOutputConversionToMap
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例10: testInvalidOutputConversion
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例11: testNoModificationIfNoFormMatches
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例12: testFormIsSelectedByMethodAndURL
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例13: testNoModificationToExplicitValue
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例14: testFormIsSelectedByExplicitSubmit
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}
示例15: testNoModificationIfAmbiguous
import org.hamcrest.collection.IsMapContaining; //导入依赖的package包/类
@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"));
}