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

项目:javaOIDCMsg    文件:JsonNodeClaimTest.java   
@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"));
}
项目:metrics-aggregator-daemon    文件:JsonToRecordParserV2dTest.java   
@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));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:Metadata.java   
@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;
}
项目:spring-boot-concourse    文件:Metadata.java   
@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;
}
项目:contestparser    文件:ConfigurationMetadataMatchers.java   
@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;
}
项目:hsm-java    文件:EventHandlingTest.java   
@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);
}
项目:hsm-java    文件:EventHandlingTest.java   
@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");
}
项目:java-jwt    文件:JsonNodeClaimTest.java   
@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"));
}
项目:javaOIDCMsg    文件:ClaimsHolderTest.java   
@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")));
}
项目:javaOIDCMsg    文件:BasicHeaderTest.java   
@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)));
}
项目:swblocks-decisiontree    文件:DomainSerialiserTest.java   
@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"));
}
项目:swblocks-decisiontree    文件:DomainSerialiserTest.java   
@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"));
}
项目:jmeter-formman    文件:TestHTTPFormManager.java   
@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"));
}
项目:jmeter-formman    文件:TestHTTPFormManager.java   
@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"));
}
项目:jmeter-formman    文件:TestHTTPFormManager.java   
@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"));
}
项目:jmeter-formman    文件:TestHTTPFormManager.java   
@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"));
}
项目:jmeter-formman    文件:TestHTTPFormManager.java   
@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"));
}
项目:metrics-aggregator-daemon    文件:JsonToRecordParserV2cTest.java   
@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"));
}
项目:Auth0.Android    文件:BaseRequestTest.java   
@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"));
}
项目:Auth0.Android    文件:BaseRequestTest.java   
@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"));
}
项目:Auth0.Android    文件:BaseRequestTest.java   
@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"));
}
项目:beam    文件:BeamFnDataWriteRunnerTest.java   
@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.");
}
项目:beam    文件:BoundedSourceRunnerTest.java   
@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.");
}
项目:beam    文件:BeamFnDataReadRunnerTest.java   
@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.");
}
项目:beam    文件:FnApiDoFnRunnerTest.java   
@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.");
}
项目:Chateau    文件:MapMatchers.java   
@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()]);
}
项目:spring-cloud-stream-app-starters    文件:PmmlProcessorIntegrationTests.java   
@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")));
}
项目:spring-cloud-stream-app-starters    文件:PmmlProcessorIntegrationTests.java   
@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")));
}
项目:spring-cloud-dataflow    文件:AppDeploymentRequestCreatorTests.java   
@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")));
}
项目:spring-cloud-dataflow    文件:AppDeploymentRequestCreatorTests.java   
@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"));
}
项目:spring-cloud-dataflow    文件:AppDeploymentRequestCreatorTests.java   
@Test
public void testShorthandsAcceptRelaxedVariations() {
    StreamAppDefinition appDefinition = new StreamAppDefinition.Builder().setRegisteredAppName("my-app")
            .setProperty("someLongProperty", "yy") // Use camelCase here
            .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.some-long-property", "yy"));

}
项目:haligate-core    文件:TraversalTest.java   
@Test
  public void contentEncodingWorks( ) throws IOException
  {
      final Client client = Haligate.defaultClient( );
      @SuppressWarnings( "serial" )
final Map< String, String > content = client.from( rootUri ).follow( "movies", "movie[name:The Matrix]" ).asObject( new TypeToken< Map< String, String > >( ) { } );

      assertThat( content, IsMapContaining.hasKey( "aka" ) );
      assertThat( content.get( "aka" ), equalTo( "Матрица" ) );
  }
项目:java-jwt    文件:ClaimsHolderTest.java   
@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")));
}
项目:java-jwt    文件:BasicHeaderTest.java   
@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)));
}
项目:consul-api    文件:ConsulClientTest.java   
private void serviceRegisterTest(ConsulClient consulClient) {
    NewService newService = new NewService();
    String serviceName = "abc";
    newService.setName(serviceName);
    consulClient.agentServiceRegister(newService);

    Response<Map<String, Service>> agentServicesResponse = consulClient.getAgentServices();
    Map<String, Service> services = agentServicesResponse.getValue();
    assertThat(services, IsMapContaining.hasKey(serviceName));
}
项目:SciGraph    文件:CypherUtilTest.java   
@Test
public void flattenMap() {
  Multimap<String, Object> multiMap = HashMultimap.create();
  multiMap.put("foo", "bar");
  multiMap.put("foo", "baz");
  assertThat(CypherUtil.flattenMap(multiMap), IsMapContaining.hasKey("foo"));
}
项目:Lock.Android    文件:DatabaseSignUpEventTest.java   
private void assertValidMetadata(Map<String, Object> map) {
    assertThat(map, is(notNullValue()));
    assertThat(map, IsMapContaining.hasKey("user_metadata"));
    Map<String, String> resultMetadata = (Map<String, String>) map.get("user_metadata");
    assertThat(resultMetadata, IsMapContaining.hasEntry("key", "value"));
    assertThat(resultMetadata, IsMapContaining.hasEntry("abc", "123"));
}
项目:spring-data-solr    文件:MappingSolrConverterTests.java   
@Test
public void testReadOverlappingWildcradsShouldPlaceStringInMultipleMatchingFields() {
    SolrDocument document = new SolrDocument();
    document.addField("some_key_s", "value_1");

    BeanWithOverlappingWildcards target = converter.read(BeanWithOverlappingWildcards.class, document);
    Assert.assertThat(target.justAString, IsNull.nullValue(String.class));
    Assert.assertThat(target.keys, IsMapContaining.hasEntry("some_key_s", "value_1"));
    Assert.assertThat(target.strings, IsMapContaining.hasEntry("some_key_s", "value_1"));
}
项目:spring-data-solr    文件:MappingSolrConverterTests.java   
@Test
public void testReadOverlappingWildcradsShouldPlaceStringInOnlyOneMatchingFieldWhenNoFullMatch() {
    SolrDocument document = new SolrDocument();
    document.addField("some_different_s", "value_1");

    BeanWithOverlappingWildcards target = converter.read(BeanWithOverlappingWildcards.class, document);
    Assert.assertThat(target.justAString, IsNull.nullValue(String.class));
    Assert.assertThat(target.keys, IsNull.nullValue(Map.class));
    Assert.assertThat(target.strings, IsMapContaining.hasEntry("some_different_s", "value_1"));
}
项目:spring-data-solr    文件:UpdateToSolrInputDocumentConverterTests.java   
@Test
@SuppressWarnings("unchecked")
public void testConvertFieldWithEmtpyCollectionsAddsNullValueForUpdate() {
    PartialUpdate update = new PartialUpdate("id", "1");
    update.add("field_1", Collections.emptyList());

    SolrInputDocument document = converter.convert(update);
    Assert.assertThat((Map<String, Object>)document.getFieldValue("field_1"), IsMapContaining.hasEntry("set", null));
}