本文整理汇总了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);
}
示例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();
}
示例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());
}
示例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();
}
示例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);
}
示例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);
}
示例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();
}
}
}
}
示例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);
}
示例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);
}
示例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())));
}
示例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;
}
示例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;
}
示例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();
}
}
}
}
示例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;
}