當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。