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


Java LinkedMultiValueMap类代码示例

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


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

示例1: send

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
private void send(String subject, String to, String toEmail, String body) {
    final String url = "https://api.mailgun.net/v3/" +
        env.getProperty("mailgun.domain") + "/messages";

    final MultiValueMap<String, String> args = new LinkedMultiValueMap<>();
    args.put("subject", singletonList(subject));
    args.put("from",  singletonList(env.getProperty("service.email.sitename") +
              " <" +  env.getProperty("service.email.sender") + ">"));
    args.put("to", singletonList(to + " <" + toEmail + ">"));
    args.put("html", singletonList(body));

    final ResponseEntity<MailGunResponse> response =
        mailgun.postForEntity(url, args, MailGunResponse.class);

    if (!response.getStatusCode().is2xxSuccessful()) {
        throw new RuntimeException(
            "Error delivering mail. Message: " +
            response.getBody().getMessage()
        );
    }
}
 
开发者ID:membaza,项目名称:users-service,代码行数:22,代码来源:EmailServiceImpl.java

示例2: getAnswer

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
public static String getAnswer(RestTemplate restTemplate, String question) {
    String url = "http://www.tuling123.com/openapi/api";
    HttpHeaders headers = new HttpHeaders();
    headers.add("Ocp-Apim-Subscription-Key", "3f5a37d9698744f3b40c89e2f0c94fb1");
    headers.add("Content-Type", "application/x-www-form-urlencoded");


    MultiValueMap<String, String> bodyMap = new LinkedMultiValueMap<>();
    bodyMap.add("key", "e2e33efb4efb4e5794b48a18578384ee");
    bodyMap.add("info", question);


    HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(bodyMap, headers);
    String result = restTemplate.postForObject(url, requestEntity, String.class);
    return JsonPath.read(result, "$.text");
}
 
开发者ID:xjtushilei,项目名称:knowledge-forest-dialogue-recommendation,代码行数:17,代码来源:Tuling123.java

示例3: ableToUploadFileWithoutAnnotation

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Test
public void ableToUploadFileWithoutAnnotation() throws IOException {
  String file1Content = "hello world";
  String file2Content = "bonjour";
  String username = "mike";

  MultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
  map.add("file1", new FileSystemResource(newFile(file1Content).getAbsolutePath()));
  map.add("file2", new FileSystemResource(newFile(file2Content).getAbsolutePath()));
  map.add("name", username);

  HttpHeaders headers = new HttpHeaders();
  headers.setContentType(MediaType.MULTIPART_FORM_DATA);
  String result = restTemplate.postForObject(
      codeFirstUrl + "uploadWithoutAnnotation",
      new HttpEntity<>(map, headers),
      String.class);

  assertThat(result, is(file1Content + file2Content + username));
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:21,代码来源:SpringMvcIntegrationTestBase.java

示例4: findConnectionsToUsers

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void findConnectionsToUsers() {
    connectionFactoryRegistry.addConnectionFactory(new TestTwitterConnectionFactory());
    insertTwitterConnection();
    insertFacebookConnection();
    insertFacebookConnection2();
    MultiValueMap<String, String> providerUsers = new LinkedMultiValueMap<>();
    providerUsers.add("facebook", "10");
    providerUsers.add("facebook", "9");
    providerUsers.add("twitter", "1");
    MultiValueMap<String, Connection<?>> connectionsForUsers = connectionRepository.findConnectionsToUsers(providerUsers);
    assertEquals(2, connectionsForUsers.size());
    String providerId=connectionsForUsers.getFirst("facebook").getKey().getProviderUserId();
    assertTrue("10".equals(providerId) || "9".equals(providerId) );
    assertFacebookConnection((Connection<TestFacebookApi>) connectionRepository.getConnection(new ConnectionKey("facebook", "9")));
    assertTwitterConnection((Connection<TestTwitterApi>) connectionsForUsers.getFirst("twitter"));
}
 
开发者ID:deepu105,项目名称:spring-io,代码行数:19,代码来源:CustomSocialUsersConnectionRepositoryIntTest.java

示例5: findAllConnections

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findAllConnections() {
    List<SocialUserConnection> socialUserConnections = socialUserConnectionRepository
                    .findAllByUserIdOrderByProviderIdAscRankAsc(userId);
    List<Connection<?>> connections = socialUserConnectionsToConnections(socialUserConnections);
    MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
    Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds();
    for (String registeredProviderId : registeredProviderIds) {
        connectionsByProviderId.put(registeredProviderId, Collections.emptyList());
    }
    for (Connection<?> connection : connections) {
        String providerId = connection.getKey().getProviderId();
        if (connectionsByProviderId.get(providerId) == null || connectionsByProviderId.get(providerId).size() == 0) {
            connectionsByProviderId.put(providerId, new LinkedList<>());
        }
        connectionsByProviderId.add(providerId, connection);
    }
    return connectionsByProviderId;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:20,代码来源:CustomSocialConnectionRepository.java

示例6: findConnectionsToUsers

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findConnectionsToUsers(
                MultiValueMap<String, String> providerUserIdsByProviderId) {
    if (providerUserIdsByProviderId == null || providerUserIdsByProviderId.isEmpty()) {
        throw new IllegalArgumentException("Unable to execute find: no providerUsers provided");
    }

    MultiValueMap<String, Connection<?>> connectionsForUsers = new LinkedMultiValueMap<>();
    for (Map.Entry<String, List<String>> entry : providerUserIdsByProviderId.entrySet()) {
        String providerId = entry.getKey();
        List<String> providerUserIds = entry.getValue();
        List<Connection<?>> connections = providerUserIdsToConnections(providerId, providerUserIds);
        connections.forEach(connection -> connectionsForUsers.add(providerId, connection));
    }
    return connectionsForUsers;
}
 
开发者ID:xm-online,项目名称:xm-uaa,代码行数:17,代码来源:CustomSocialConnectionRepository.java

示例7: findAllConnections

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Override
public MultiValueMap<String, Connection<?>> findAllConnections() {
    List<SocialUserConnection> socialUserConnections = socialUserConnectionRepository.findAllByUserIdOrderByProviderIdAscRankAsc(userId);
    List<Connection<?>> connections = socialUserConnectionsToConnections(socialUserConnections);
    MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
    Set<String> registeredProviderIds = connectionFactoryLocator.registeredProviderIds();
    for (String registeredProviderId : registeredProviderIds) {
        connectionsByProviderId.put(registeredProviderId, Collections.emptyList());
    }
    for (Connection<?> connection : connections) {
        String providerId = connection.getKey().getProviderId();
        if (connectionsByProviderId.get(providerId).size() == 0) {
            connectionsByProviderId.put(providerId, new LinkedList<>());
        }
        connectionsByProviderId.add(providerId, connection);
    }
    return connectionsByProviderId;
}
 
开发者ID:AppertaFoundation,项目名称:Code4Health-Platform,代码行数:19,代码来源:CustomSocialConnectionRepository.java

示例8: testDeleteUserSocialConnection

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Test
public void testDeleteUserSocialConnection() throws Exception {
    // Setup
    Connection<?> connection = createConnection("@LOGIN",
        "[email protected]",
        "FIRST_NAME",
        "LAST_NAME",
        "IMAGE_URL",
        "PROVIDER");
    socialService.createSocialUser(connection, "fr");
    MultiValueMap<String, Connection<?>> connectionsByProviderId = new LinkedMultiValueMap<>();
    connectionsByProviderId.put("PROVIDER", null);
    when(mockConnectionRepository.findAllConnections()).thenReturn(connectionsByProviderId);

    // Exercise
    socialService.deleteUserSocialConnection("@LOGIN");

    // Verify
    verify(mockConnectionRepository, times(1)).removeConnections("PROVIDER");
}
 
开发者ID:Microsoft,项目名称:MTC_Labrat,代码行数:21,代码来源:SocialServiceIntTest.java

示例9: buildResponseEntity

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
private HttpEntity<MultiValueMap<String, String>> buildResponseEntity(
    Submission submission, HttpHeaders headers) {
  logger.debug("Building response entity");
  MultiValueMap<String, String> map = new LinkedMultiValueMap<>();

  try {
    map.add("test_output", new ObjectMapper().writeValueAsString(
        submission.getTestOutput()));
  } catch (JsonProcessingException ex) {
    logger.debug("POJO deserialization failed");
  }
  map.add("stdout", submission.getStdout());
  map.add("stderr", submission.getStderr());
  map.add("validations", submission.getValidations());
  map.add("vm_log", submission.getVmLog());
  map.add("token", submission.getId().toString());
  map.add("status", submission.getStatus().toString());
  map.add("exit_code", submission.getExitCode().toString());

  return new HttpEntity<>(map, headers);
}
 
开发者ID:tdd-pingis,项目名称:tdd-pingpong,代码行数:22,代码来源:FakeSandboxRestService.java

示例10: ableToPostDate

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
@Test
public void ableToPostDate() throws Exception {
  ZonedDateTime date = ZonedDateTime.now().truncatedTo(SECONDS);
  MultiValueMap<String, String> body = new LinkedMultiValueMap<>();
  body.add("date", RestObjectMapper.INSTANCE.convertToString(Date.from(date.toInstant())));

  HttpHeaders headers = new HttpHeaders();
  headers.add(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE);

  int seconds = 1;
  for (String url : urls) {
    Date result = restTemplate.postForObject(url + "addDate?seconds={seconds}",
        new HttpEntity<>(body, headers),
        Date.class,
        seconds);

    assertEquals(Date.from(date.plusSeconds(seconds).toInstant()), result);
  }
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:20,代码来源:JaxrsIntegrationTestBase.java

示例11: send

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
private void send(String subject, String to, String toEmail, String body) {
    final String url = "https://api.mailgun.net/v3/" +
        env.getProperty("mailgun.domain") + "/messages";

    final MultiValueMap<String, String> args = new LinkedMultiValueMap<>();
    args.put("subject", singletonList(subject));
    args.put("from",  singletonList(env.getProperty("service.email.sitename") +
        " <" +  env.getProperty("service.email.sender") + ">"));
    args.put("to", singletonList(to + " <" + toEmail + ">"));
    args.put("html", singletonList(body));

    final ResponseEntity<MailGunResponse> response =
        mailgun.postForEntity(url, args, MailGunResponse.class);

    if (!response.getStatusCode().is2xxSuccessful()) {
        throw new MailDeliveryException(
            "Error delivering mail. Message: " +
                response.getBody().getMessage()
        );
    }
}
 
开发者ID:membaza,项目名称:email-service,代码行数:22,代码来源:SenderService.java

示例12: main

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
  RestTemplate template = new RestTemplate();
  template.getMessageConverters().add(new MappingJackson2HttpMessageConverter());
  MultiValueMap<String, String> headers = new LinkedMultiValueMap<>();
  headers.add("X-Tenant-Name", "default");

  RequestEntity<String> requestEntity = new RequestEntity<String>(headers, HttpMethod.GET,
      new URI("http://127.0.0.1:9980/registry/v3/microservices"));
  ResponseEntity<String> stringResponseEntity = template.exchange(requestEntity, String.class);
  System.out.println(stringResponseEntity.getBody());
  ResponseEntity<MicroserviceArray> microseriveResponseEntity = template
      .exchange(requestEntity, MicroserviceArray.class);
  MicroserviceArray microserives = microseriveResponseEntity.getBody();
  System.out.println(microserives.getServices().get(1).getServiceId());

  // instance
  headers.add("X-ConsumerId", microserives.getServices().get(1).getServiceId());
  requestEntity = new RequestEntity<String>(headers, HttpMethod.GET,
      new URI("http://127.0.0.1:9980/registry/v3/microservices/" + microserives.getServices().get(1).getServiceId()
          + "/instances"));
  ResponseEntity<String> microserviceInstanceResponseEntity = template.exchange(requestEntity, String.class);
  System.out.println(microserviceInstanceResponseEntity.getBody());
}
 
开发者ID:apache,项目名称:incubator-servicecomb-java-chassis,代码行数:24,代码来源:ServiceCenterExample.java

示例13: apiAuthorizationJwtPost

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
/**
 * 
 * 
 * <p><b>200</b> - Success
 * @param model The model parameter
 * @return JwtToken
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public JwtToken apiAuthorizationJwtPost(LoginModel model) throws RestClientException {
    Object postBody = model;
    
    String path = UriComponentsBuilder.fromPath("/api/authorization/jwt").build().toUriString();
    
    final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    final HttpHeaders headerParams = new HttpHeaders();
    final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

    final String[] accepts = { 
        "text/plain", "application/json", "text/json"
    };
    final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
    final String[] contentTypes = { 
        "application/json-patch+json", "application/json", "text/json", "application/_*+json"
    };
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

    String[] authNames = new String[] {  };

    ParameterizedTypeReference<JwtToken> returnType = new ParameterizedTypeReference<JwtToken>() {};
    return apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
 
开发者ID:jopache,项目名称:Settings,代码行数:32,代码来源:AuthorizationApi.java

示例14: apiAuthorizationLoginPost

import org.springframework.util.LinkedMultiValueMap; //导入依赖的package包/类
/**
 * 
 * 
 * <p><b>200</b> - Success
 * @param model The model parameter
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public void apiAuthorizationLoginPost(LoginModel model) throws RestClientException {
    Object postBody = model;
    
    String path = UriComponentsBuilder.fromPath("/api/authorization/login").build().toUriString();
    
    final MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<String, String>();
    final HttpHeaders headerParams = new HttpHeaders();
    final MultiValueMap<String, Object> formParams = new LinkedMultiValueMap<String, Object>();

    final String[] accepts = { };
    final List<MediaType> accept = apiClient.selectHeaderAccept(accepts);
    final String[] contentTypes = { 
        "application/json-patch+json", "application/json", "text/json", "application/_*+json"
    };
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

    String[] authNames = new String[] {  };

    ParameterizedTypeReference<Void> returnType = new ParameterizedTypeReference<Void>() {};
    apiClient.invokeAPI(path, HttpMethod.POST, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
 
开发者ID:jopache,项目名称:Settings,代码行数:29,代码来源:AuthorizationApi.java

示例15: 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


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