当前位置: 首页>>代码示例>>Java>>正文


Java LinkedMultiValueMap.add方法代码示例

本文整理汇总了Java中org.springframework.util.LinkedMultiValueMap.add方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedMultiValueMap.add方法的具体用法?Java LinkedMultiValueMap.add怎么用?Java LinkedMultiValueMap.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.util.LinkedMultiValueMap的用法示例。


在下文中一共展示了LinkedMultiValueMap.add方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildUnauthorizedResponseEntity

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
/**
 * Build unauthorized response entity.
 *
 * @param code the code
 * @return the response entity
 */
private static ResponseEntity buildUnauthorizedResponseEntity(final String code) {
    final LinkedMultiValueMap<String, String> map = new LinkedMultiValueMap<>(1);
    map.add(OAuth20Constants.ERROR, code);
    final String value = OAuth20Utils.jsonify(map);
    return new ResponseEntity<>(value, HttpStatus.UNAUTHORIZED);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:13,代码来源:OAuth20UserProfileControllerController.java

示例2: testSocialConnections

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
@WithMockUser("user123")
public void testSocialConnections() throws Exception {
	LinkedMultiValueMap<String, Connection<?>> connections = new LinkedMultiValueMap<>();
	connections.add(connection.getKey().getProviderId(), connection);
	when(connectionRepository.findAllConnections()).thenReturn(connections);
	MockHttpServletRequestBuilder request = get("/api/profile/socials")
		.contentType(MediaType.APPLICATION_JSON);
	MockHttpServletResponse response = mockMvc.perform(request)
		.andDo(document("user-profile-socials-list"))
		.andReturn()
		.getResponse();
	assertThat(response.getStatus()).isEqualTo(200);
	JsonNode jsonResponse = objectMapper.readTree(response.getContentAsByteArray());
	assertThat(jsonResponse.isObject()).isTrue();
	assertThat(jsonResponse.has(PROVIDER_ID)).isTrue();
	assertThat(jsonResponse.get(PROVIDER_ID).isObject()).isTrue();
	assertThat(jsonResponse.get(PROVIDER_ID).get("imageUrl").textValue()).isEqualTo(connection.getImageUrl());
	verify(connectionRepository).findAllConnections();
}
 
开发者ID:codenergic,项目名称:theskeleton,代码行数:21,代码来源:ProfileSocialRestControllerTest.java

示例3: testUpdateConnectorWithoutIconViaMultipart

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void testUpdateConnectorWithoutIconViaMultipart() throws IOException {
    final Connector initialConnector = dataManager.fetch(Connector.class, "twitter");

    final Connector connectorWithNewdescription = new Connector.Builder().createFrom(initialConnector)
        .description("Updated!").build();

    final LinkedMultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
    multipartData.add("connector", connectorWithNewdescription);

    final ResponseEntity<Void> updated = put("/api/v1/connectors/twitter",
        multipartData, Void.class, tokenRule.validToken(), HttpStatus.NO_CONTENT,
        multipartHeaders());

    final ResponseEntity<Connector> updatedConnector = get("/api/v1/connectors/twitter", Connector.class);

    assertThat(updatedConnector.getBody().getId()).isPresent();
    assertThat(updatedConnector.getBody().getDescription()).isNotBlank().isEqualTo("Updated!");
    assertThat(updatedConnector.getBody().getIcon()).isNotBlank().isEqualTo(initialConnector.getIcon());
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:21,代码来源:ConnectorsITCase.java

示例4: should_post_media

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void should_post_media() throws Exception {
    // given
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
    map.add("file", new ClassPathResource("Duke-Istanbul.png"));
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.MULTIPART_FORM_DATA);

    // when
    ResponseEntity<Media> result = testRestTemplate
            .withBasicAuth("1", "1")
            .exchange("/v1/media",
                    HttpMethod.POST,
                    new HttpEntity<>(map, headers),
                    Media.class);
    // then
    assertThat(result.getStatusCode()).isEqualTo(HttpStatus.CREATED);
    assertThat(extractIdFromURI(result.getHeaders().getLocation())).isNotNull();
    assertThat(result.getBody()).isNotNull();
}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:21,代码来源:MediaControllerIT.java

示例5: testStream

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void testStream() throws IOException {
    String s = ((Zg2proRestTemplate) rt.getRestTemplate()).postForPath(TEST_URL_FILE_UPLOAD,
            originalFile, String.class);
    assertThat(s).isEqualTo("ok");

    LinkedMultiValueMap httpHeaders = new LinkedMultiValueMap();
    httpHeaders.add("XX-AUTH-TOKEN", UUID.randomUUID().toString());
    ((Zg2proRestTemplate) rt.getRestTemplate()).setFilesStreamingOperationsHttpHeaders(null);
    ((Zg2proRestTemplate) rt.getRestTemplate()).setFilesStreamingOperationsHttpHeaders(httpHeaders);

    Path sp = ((Zg2proRestTemplate) rt.getRestTemplate()).getForObject(TEST_URL_FILE_DOWNLOAD,
            "target/test-content.tmp");
    byte[] newFile = Files.readAllBytes(sp);
    Files.delete(sp);
    byte[] oldFile = Files.readAllBytes(originalFile);
    assertThat(oldFile).isEqualTo(newFile);
}
 
开发者ID:zg2pro,项目名称:spring-rest-basis,代码行数:19,代码来源:StreamingTest.java

示例6: test_for_issue

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
public void test_for_issue() throws Exception {
    ParserConfig parserConfig = new ParserConfig();
    parserConfig.setAutoTypeSupport(true);
    LinkedMultiValueMap<String, String> result = new LinkedMultiValueMap();
    result.add("test", "11111");
    String test = JSON.toJSONString(result, SerializerFeature.WriteClassName);
    JSON.parseObject(test, Object.class, parserConfig, JSON.DEFAULT_PARSER_FEATURE);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:9,代码来源:Issue1240.java

示例7: testUpdateIcon

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void testUpdateIcon() throws IOException {
    final LinkedMultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
    multipartData.add("icon", new InputStreamResource(getClass().getResourceAsStream("test-image.png")));

    final ResponseEntity<Connector> updated = post("/api/v1/connectors/twitter/icon",
        multipartData, Connector.class, tokenRule.validToken(), HttpStatus.OK,
        multipartHeaders());

    assertThat(updated.getBody().getId()).isPresent();
    assertThat(updated.getBody().getIcon()).isNotBlank().startsWith("db:");

    final ResponseEntity<ByteArrayResource> got = get("/api/v1/connectors/twitter/icon", ByteArrayResource.class);
    assertThat(got.getHeaders().getFirst("Content-Type")).isEqualTo("image/png");

    try (ImageInputStream iis = ImageIO.createImageInputStream(got.getBody().getInputStream());) {
        final Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
        if (readers.hasNext()) {
            final ImageReader reader = readers.next();
            try {
                reader.setInput(iis);
                final Dimension dimensions = new Dimension(reader.getWidth(0), reader.getHeight(0));
                assertThat(dimensions.getHeight()).isEqualTo(106d).as("Wrong image height");
                assertThat(dimensions.getWidth()).isEqualTo(106d).as("Wrong image width");
            } finally {
                reader.dispose();
            }
        }
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:31,代码来源:ConnectorsITCase.java

示例8: testWriteMultipart

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void testWriteMultipart() throws IOException {
    LinkedMultiValueMap<String, String> parts = new LinkedMultiValueMap<>();
    parts.add("first", "value");
    parts.add("second", "value");
    multipartMixedConverter.write(parts, MediaType.MULTIPART_FORM_DATA, httpOutputMessage);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:8,代码来源:MutipartMixedConverterUnitTest.java

示例9: buildUnauthorizedResponseEntity

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
private static ResponseEntity buildUnauthorizedResponseEntity(String code) {
	LinkedMultiValueMap map = new LinkedMultiValueMap(1);
	map.add("error", code);
	String value = OAuth20Utils.jsonify(map);
	return new ResponseEntity(value, HttpStatus.UNAUTHORIZED);
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:7,代码来源:OAuth20UserProfileControllerController.java

示例10: should_return_duke

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void should_return_duke() throws Exception {
    // given
    LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
    ClassPathResource dukeResource = new ClassPathResource("Duke-Istanbul.png");
    map.add("file", dukeResource);
    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.MULTIPART_FORM_DATA);

    // when
    ResponseEntity<Media> result = testRestTemplate
            .withBasicAuth("1", "1")
            .exchange("/v1/media",
                    HttpMethod.POST,
                    new HttpEntity<>(map, headers),
                    Media.class);

    // then
    RestTemplate restTemplate = getRawRestTemplate();

    ResponseEntity<byte[]> responseEntity = restTemplate
            .exchange(result.getBody().getUrl(),
                    HttpMethod.GET,
                    HttpEntity.EMPTY,
                    byte[].class);

    assertThat(responseEntity.getStatusCode()).isEqualTo(HttpStatus.OK);
    assertThat(responseEntity.getBody()).isEqualTo(readAllBytes(get(dukeResource.getURI())));

}
 
开发者ID:JUGIstanbul,项目名称:second-opinion-api,代码行数:31,代码来源:MediaDownloadControllerIT.java

示例11: multipartBody

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
private MultiValueMap<String, Object> multipartBody(final ConnectorSettings connectorSettings, final InputStream icon) {
    final LinkedMultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
    multipartData.add("connectorSettings", connectorSettings);
    multipartData.add("icon", new InputStreamResource(icon));
    return multipartData;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:7,代码来源:CustomConnectorITCase.java

示例12: multipartBodyForInfo

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
private MultiValueMap<String, Object> multipartBodyForInfo(ConnectorSettings connectorSettings, InputStream is) throws IOException {
    LinkedMultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
    multipartData.add("connectorSettings", connectorSettings);
    multipartData.add("specification", Okio.buffer(Okio.source(is)).readUtf8());
    return multipartData;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:7,代码来源:CustomSwaggerConnectorITCase.java

示例13: testUpdateConnectorAndIconViaMultipart

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
@Test
public void testUpdateConnectorAndIconViaMultipart() throws IOException {
    final Connector initialConnector = dataManager.fetch(Connector.class, "twitter");

    assertThat(initialConnector.getIcon()).isNotBlank().doesNotStartWith("db:");

    final Connector connectorWithNewdescription = new Connector.Builder().createFrom(initialConnector)
        .description("Updated!").build();

    final LinkedMultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
    multipartData.add("connector", connectorWithNewdescription);
    multipartData.add("icon", new InputStreamResource(getClass().getResourceAsStream("test-image.png")));

    final ResponseEntity<Void> updated = put("/api/v1/connectors/twitter",
        multipartData, Void.class, tokenRule.validToken(), HttpStatus.NO_CONTENT,
        multipartHeaders());

    final ResponseEntity<Connector> updatedConnector = get("/api/v1/connectors/twitter", Connector.class);

    assertThat(updatedConnector.getBody().getId()).isPresent();
    assertThat(updatedConnector.getBody().getIcon()).isNotBlank().startsWith("db:");
    assertThat(updatedConnector.getBody().getDescription()).isNotBlank().isEqualTo("Updated!");

    final ResponseEntity<ByteArrayResource> got = get("/api/v1/connectors/twitter/icon", ByteArrayResource.class);
    assertThat(got.getHeaders().getFirst("Content-Type")).isEqualTo("image/png");

    try (ImageInputStream iis = ImageIO.createImageInputStream(got.getBody().getInputStream());) {
        final Iterator<ImageReader> readers = ImageIO.getImageReaders(iis);
        if (readers.hasNext()) {
            final ImageReader reader = readers.next();
            try {
                reader.setInput(iis);
                final Dimension dimensions = new Dimension(reader.getWidth(0), reader.getHeight(0));
                assertThat(dimensions.getHeight()).isEqualTo(106d).as("Wrong image height");
                assertThat(dimensions.getWidth()).isEqualTo(106d).as("Wrong image width");
            } finally {
                reader.dispose();
            }
        }
    }
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:42,代码来源:ConnectorsITCase.java

示例14: multipartBody

import org.springframework.util.LinkedMultiValueMap; //导入方法依赖的package包/类
private MultiValueMap<String, Object> multipartBody(byte[] data) {
    LinkedMultiValueMap<String, Object> multipartData = new LinkedMultiValueMap<>();
    multipartData.add("file", new InputStreamResource(new ByteArrayInputStream(data)));
    return multipartData;
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:6,代码来源:ExtensionsITCase.java


注:本文中的org.springframework.util.LinkedMultiValueMap.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。