Java 类org.springframework.core.ParameterizedTypeReference 实例源码

项目:OAuth-2.0-Cookbook    文件:UserInfoService.java   
public Map<String, String> getUserInfoFor(OAuth2AccessToken accessToken) {
    RestTemplate restTemplate = new RestTemplate();

    RequestEntity<Void> requestEntity = new RequestEntity<>(
            getHeader(accessToken.getValue()),
            HttpMethod.GET,
            URI.create(properties.getUserInfoUri())
    );

    ParameterizedTypeReference<Map<String, String>> typeRef =
            new ParameterizedTypeReference<Map<String, String>>() {};
    ResponseEntity<Map<String, String>> result = restTemplate.exchange(
            requestEntity, typeRef);

    if (result.getStatusCode().is2xxSuccessful()) {
        return result.getBody();
    }

    throw new RuntimeException("It wasn't possible to retrieve userInfo");
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:CommentHelper.java   
@HystrixCommand(fallbackMethod = "defaultComments")
public List<Comment> getComments(Image image, String sessionId) {

    ResponseEntity<List<Comment>> results = restTemplate.exchange(
        "http://COMMENTS/comments/{imageId}",
        HttpMethod.GET,
        new HttpEntity<>(new HttpHeaders() {{
            String credentials = imagesConfiguration.getCommentsUser() + ":" +
                imagesConfiguration.getCommentsPassword();
            String token = new String(Base64Utils.encode(credentials.getBytes()));
            set(AUTHORIZATION, "Basic " + token);
            set("Cookie", "SESSION=" + sessionId);
        }}),
        new ParameterizedTypeReference<List<Comment>>() {},
        image.getId());
    return results.getBody();
}
项目:CityPower-Build-Sample    文件:IncidentServiceImpl.java   
@Override
public CompletableFuture<List<IncidentBean>> getAllIncidentsAsync() {
    CompletableFuture<List<IncidentBean>> cf = new CompletableFuture<>();
    CompletableFuture.runAsync(() -> {
        LOG.info("Performing get {} web service", applicationProperties.getIncidentApiUrl() +"/incidents");
        final String restUri = applicationProperties.getIncidentApiUrl() +"/incidents";
        ResponseEntity<Resources<IncidentBean>> response = restTemplate.exchange(restUri, HttpMethod.GET, null,
                new ParameterizedTypeReference<Resources<IncidentBean>>() {});
        //            LOG.info("Total Incidents {}", response.getBody().size());
        Resources<IncidentBean> beanResources = response.getBody();
        Collection<IncidentBean> beanCol = beanResources.getContent();
        ArrayList<IncidentBean> beanList= new ArrayList<IncidentBean>(beanCol);
        cf.complete( beanList );
        LOG.info("Done getting incidents");
    });
    return cf;
}
项目:Settings    文件:ApplicationsApi.java   
/**
 * 
 * 
 * <p><b>200</b> - Success
 * @param applicationName The applicationName parameter
 * @return HierarchicalModel
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public HierarchicalModel apiApplicationsByApplicationNameGet(String applicationName) throws RestClientException {
    Object postBody = null;

    // verify the required parameter 'applicationName' is set
    if (applicationName == null) {
        throw new HttpClientErrorException(HttpStatus.BAD_REQUEST, "Missing the required parameter 'applicationName' when calling apiApplicationsByApplicationNameGet");
    }

    // create path and map variables
    final Map<String, Object> uriVariables = new HashMap<String, Object>();
    uriVariables.put("applicationName", applicationName);
    String path = UriComponentsBuilder.fromPath("/api/applications/{applicationName}").buildAndExpand(uriVariables).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 = { };
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

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

    ParameterizedTypeReference<HierarchicalModel> returnType = new ParameterizedTypeReference<HierarchicalModel>() {};
    return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
项目:second-opinion-api    文件:CaseControllerIT.java   
@Test
public void should_return_cases_as_empty_list_if_patient_not_exist() {
    //Given
    long patientId = 123123;

    //When
    ResponseEntity<List<Case>> response = testRestTemplate.
            withBasicAuth("1","1").
            exchange("/v1/cases?patientId="+patientId,
                    HttpMethod.GET,
                    null,
                    new ParameterizedTypeReference<List<Case>>() {
                    });
    List<Case> cases = response.getBody();

    //Then
    assertThat(cases).isNotNull();
    assertThat(cases).isEmpty();
}
项目:logistimo-web-service    文件:GetFilteredApprovalsCommand.java   
@Override
protected RestResponsePage<Approval> run() throws Exception {
  try {
    ParameterizedTypeReference<RestResponsePage<Approval>>
        responsetype =
        new ParameterizedTypeReference<RestResponsePage<Approval>>() {
        };
    ResponseEntity<RestResponsePage<Approval>>
        result =
        restTemplate
            .exchange(uriBuilder.build().encode().toUri(), HttpMethod.POST,
                new HttpEntity<>(approvalFilters), responsetype);
    return result.getBody();
  } catch (HttpClientErrorException exception) {
    throw new HystrixBadRequestException(exception.getMessage(),
        new HttpBadRequestException(ErrorResponse.getErrorResponse(exception), exception));
  }
}
项目:spring-boot-vue-simple-sample    文件:JsonSampleControllerTest.java   
@Test
public void testSimple() throws Exception {

    final Map<String, Object> body = new HashMap<>();
    body.put("foo", "Hello, world!");
    body.put("bar", 12345);
    body.put("baz", "2017-02-10");
    body.put("qux", Collections.emptyList());

    final RequestEntity<Map<String, Object>> requestEntity = RequestEntity
            .post(new UriTemplate(url).expand(port))
            .contentType(MediaType.APPLICATION_JSON)
            .accept(MediaType.APPLICATION_JSON)
            .body(body);
    final ParameterizedTypeReference<Map<String, Object>> responseType = new ParameterizedTypeReference<Map<String, Object>>() {
    };
    final ResponseEntity<Map<String, Object>> response = restTemplate.exchange(requestEntity,
            responseType);

    assertThat(response.getBody(), is(body));
}
项目:spring-credhub    文件:CredHubTemplateDetailUnitTestsBase.java   
@SuppressWarnings("deprecation")
void verifyGetByName(ResponseEntity<CredentialDetailsData<T>> expectedResponse) {
    when(restTemplate.exchange(eq(NAME_URL_QUERY_CURRENT), eq(GET), isNull(HttpEntity.class),
            isA(ParameterizedTypeReference.class), eq(NAME.getName())))
            .thenReturn(expectedResponse);

    if (!expectedResponse.getStatusCode().equals(OK)) {
        try {
            credHubTemplate.getByName(NAME, String.class);
            fail("Exception should have been thrown");
        }
        catch (CredHubException e) {
            assertThat(e.getMessage(),
                    containsString(expectedResponse.getStatusCode().toString()));
        }
    }
    else {
        CredentialDetails<T> response = credHubTemplate.getByName(NAME, getType());

        assertDataResponseContainsExpectedCredential(expectedResponse, response);
    }
}
项目:spring-cloud-skipper    文件:DefaultSkipperClient.java   
@Override
public Resources<PackageMetadata> search(String name, boolean details) {
    ParameterizedTypeReference<Resources<PackageMetadata>> typeReference =
            new ParameterizedTypeReference<Resources<PackageMetadata>>() {  };
    Traverson.TraversalBuilder traversalBuilder = this.traverson.follow("packageMetadata");
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("size", 2000);
    if (StringUtils.hasText(name)) {
        parameters.put("name", name);
        traversalBuilder.follow("search", "findByNameContainingIgnoreCase");
    }
    if (!details) {
        parameters.put("projection", "summary");
        parameters.put("sort", "name,asc");
        // TODO semver sort..
    }
    return traversalBuilder.withTemplateParameters(parameters).toObject(typeReference);
}
项目:spring-credhub    文件:CredHubTemplateDetailUnitTestsBase.java   
void verifyGenerate(ResponseEntity<CredentialDetails<T>> expectedResponse) {
    ParametersRequest<P> request = getGenerateRequest();

    when(restTemplate.exchange(eq(BASE_URL_PATH), eq(POST),
            eq(new HttpEntity<>(request)), isA(ParameterizedTypeReference.class)))
                    .thenReturn(expectedResponse);

    if (!expectedResponse.getStatusCode().equals(HttpStatus.OK)) {
        try {
            credHubTemplate.generate(request);
            fail("Exception should have been thrown");
        }
        catch (CredHubException e) {
            assertThat(e.getMessage(), containsString(expectedResponse.getStatusCode().toString()));
        }
    }
    else {
        CredentialDetails<T> response = credHubTemplate.generate(request);

        assertDetailsResponseContainsExpectedCredential(expectedResponse, response);
    }
}
项目:spring-credhub    文件:CredHubTemplate.java   
@Override
public <T, P> CredentialDetails<T> generate(final ParametersRequest<P> parametersRequest) {
    Assert.notNull(parametersRequest, "parametersRequest must not be null");

    final ParameterizedTypeReference<CredentialDetails<T>> ref =
            new ParameterizedTypeReference<CredentialDetails<T>>() {};

    return doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
        @Override
        public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
            ResponseEntity<CredentialDetails<T>> response =
                    restOperations.exchange(BASE_URL_PATH, POST,
                            new HttpEntity<ParametersRequest<P>>(parametersRequest), ref);

            throwExceptionOnError(response);

            return response.getBody();
        }
    });
}
项目:spring-credhub    文件:CredHubTemplateDetailUnitTestsBase.java   
void verifyRegenerate(ResponseEntity<CredentialDetails<T>> expectedResponse) {
    Map<String, Object> request = new HashMap<String, Object>() {{
            put("name", NAME.getName());
    }};

    when(restTemplate.exchange(eq(REGENERATE_URL_PATH), eq(POST),
            eq(new HttpEntity<>(request)), isA(ParameterizedTypeReference.class)))
                    .thenReturn(expectedResponse);

    if (!expectedResponse.getStatusCode().equals(HttpStatus.OK)) {
        try {
            credHubTemplate.regenerate(NAME);
            fail("Exception should have been thrown");
        }
        catch (CredHubException e) {
            assertThat(e.getMessage(), containsString(expectedResponse.getStatusCode().toString()));
        }
    }
    else {
        CredentialDetails<T> response = credHubTemplate.regenerate(NAME);

        assertDetailsResponseContainsExpectedCredential(expectedResponse, response);
    }
}
项目:spring-credhub    文件:CredHubTemplateDetailUnitTestsBase.java   
void verifyWrite(ResponseEntity<CredentialDetails<T>> expectedResponse) {
    CredentialRequest<T> request = getWriteRequest();

    when(restTemplate.exchange(eq(BASE_URL_PATH), eq(PUT),
            eq(new HttpEntity<>(request)), isA(ParameterizedTypeReference.class)))
                    .thenReturn(expectedResponse);

    if (!expectedResponse.getStatusCode().equals(HttpStatus.OK)) {
        try {
            credHubTemplate.write(request);
            fail("Exception should have been thrown");
        }
        catch (CredHubException e) {
            assertThat(e.getMessage(), containsString(expectedResponse.getStatusCode().toString()));
        }
    }
    else {
        CredentialDetails<T> response = credHubTemplate.write(request);

        assertDetailsResponseContainsExpectedCredential(expectedResponse, response);
    }
}
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:HomeController.java   
@GetMapping("/")
public Mono<String> index(Model model) {
    model.addAttribute("images",
        imageService
            .findAllImages()
            .map(image -> new HashMap<String, Object>() {{
                put("id", image.getId());
                put("name", image.getName());
                put("comments",
                    // tag::comments[]
                    restTemplate.exchange(
                        "http://COMMENTS/comments/{imageId}",
                        HttpMethod.GET,
                        null,
                        new ParameterizedTypeReference<List<Comment>>() {},
                        image.getId()).getBody());
                // end::comments[]
            }})
    );
    return Mono.just("index");
}
项目:meparty    文件:RestApiProxyInvocationHandler.java   
RestResponse<Object> doRestExchange(RestExchangeProperties properties)
    throws IOException, HttpStatusCodeException {

  ResponseEntity<String> responseEntity = restTemplate.exchange(properties.getUrl(),
      properties.getHttpMethod(), properties.getHttpEntity(),
      new ParameterizedTypeReference<String>() {
      }, properties.getUrlVariables());


  ObjectMapper objectMapper = new ObjectMapper();

  Object returnBody = null;
  if (!StringHelper.isNullOrEmpty(responseEntity.getBody())) {
    if (responseEntity.getBody().startsWith("[")) {
      returnBody = objectMapper.readValue(responseEntity.getBody(),
          objectMapper.getTypeFactory().constructCollectionType(List.class,
              properties.getReturnType()));
    } else {
      returnBody = objectMapper.readValue(responseEntity.getBody(), properties.getReturnType());
    }
  }
  RestResponse<Object> restResponse = new RestResponse<>(returnBody,
      responseEntity.getHeaders(),
      responseEntity.getStatusCode());

  return restResponse;
}
项目:spring-credhub    文件:CredHubTemplate.java   
@Override
public <T> CredentialDetails<T> getById(final String id, Class<T> credentialType) {
    Assert.notNull(id, "credential id must not be null");
    Assert.notNull(credentialType, "credential type must not be null");

    final ParameterizedTypeReference<CredentialDetails<T>> ref =
            new ParameterizedTypeReference<CredentialDetails<T>>() {};

    return doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
        @Override
        public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
            ResponseEntity<CredentialDetails<T>> response =
                    restOperations.exchange(ID_URL_PATH, GET, null, ref, id);

            throwExceptionOnError(response);

            return response.getBody();
        }
    });
}
项目:Settings    文件:ApplicationsApi.java   
/**
 * 
 * 
 * <p><b>200</b> - Success
 * @return HierarchicalModel
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public HierarchicalModel apiApplicationsGet() throws RestClientException {
    Object postBody = null;

    String path = UriComponentsBuilder.fromPath("/api/applications").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 = { };
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

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

    ParameterizedTypeReference<HierarchicalModel> returnType = new ParameterizedTypeReference<HierarchicalModel>() {};
    return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
项目:Settings    文件:EnvironmentsApi.java   
/**
 * 
 * 
 * <p><b>200</b> - Success
 * @return HierarchicalModel
 * @throws RestClientException if an error occurs while attempting to invoke the API
 */
public HierarchicalModel apiEnvironmentsGet() throws RestClientException {
    Object postBody = null;

    String path = UriComponentsBuilder.fromPath("/api/environments").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 = { };
    final MediaType contentType = apiClient.selectHeaderContentType(contentTypes);

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

    ParameterizedTypeReference<HierarchicalModel> returnType = new ParameterizedTypeReference<HierarchicalModel>() {};
    return apiClient.invokeAPI(path, HttpMethod.GET, queryParams, postBody, headerParams, formParams, accept, contentType, authNames, returnType);
}
项目:Settings    文件:AuthorizationApi.java   
/**
 * 
 * 
 * <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);
}
项目:Settings    文件:ApiClient.java   
/**
 * Invoke API by sending HTTP request with the given options.
 *
 * @param <T> the return type to use
 * @param path The sub-path of the HTTP URL
 * @param method The request method
 * @param queryParams The query parameters
 * @param body The request body object
 * @param headerParams The header parameters
 * @param formParams The form parameters
 * @param accept The request's Accept header
 * @param contentType The request's Content-Type header
 * @param authNames The authentications to apply
 * @param returnType The return type into which to deserialize the response
 * @return The response body in chosen type
 */
public <T> T invokeAPI(String path, HttpMethod method, MultiValueMap<String, String> queryParams, Object body, HttpHeaders headerParams, MultiValueMap<String, Object> formParams, List<MediaType> accept, MediaType contentType, String[] authNames, ParameterizedTypeReference<T> returnType) throws RestClientException {
    updateParamsForAuth(authNames, queryParams, headerParams);

    final UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(basePath).path(path);
    if (queryParams != null) {
        builder.queryParams(queryParams);
    }

    final BodyBuilder requestBuilder = RequestEntity.method(method, builder.build().toUri());
    if(accept != null) {
        requestBuilder.accept(accept.toArray(new MediaType[accept.size()]));
    }
    if(contentType != null) {
        requestBuilder.contentType(contentType);
    }

    addHeadersToRequest(headerParams, requestBuilder);
    addHeadersToRequest(defaultHeaders, requestBuilder);

    RequestEntity<Object> requestEntity = requestBuilder.body(selectBody(body, formParams, contentType));

    ResponseEntity<T> responseEntity = restTemplate.exchange(requestEntity, returnType);

    statusCode = responseEntity.getStatusCode();
    responseHeaders = responseEntity.getHeaders();

    if (responseEntity.getStatusCode() == HttpStatus.NO_CONTENT) {
        return null;
    } else if (responseEntity.getStatusCode().is2xxSuccessful()) {
        if (returnType == null) {
            return null;
        }
        return responseEntity.getBody();
    } else {
        // The error handler built into the RestTemplate should handle 400 and 500 series errors.
        throw new RestClientException("API returned " + statusCode + " and it wasn't handled by the RestTemplate error handler");
    }
}
项目:cf-java-client-sap    文件:CloudControllerClientImpl.java   
@Override
public void uploadApplication(String appName, ApplicationArchive archive, UploadStatusCallback callback) throws IOException {
    Assert.notNull(appName, "AppName must not be null");
    Assert.notNull(archive, "Archive must not be null");
    UUID appId = getAppId(appName);

    if (callback == null) {
        callback = UploadStatusCallback.NONE;
    }
    CloudResources knownRemoteResources = getKnownRemoteResources(archive);
    callback.onCheckResources();
    callback.onMatchedFileNames(knownRemoteResources.getFilenames());
    UploadApplicationPayload payload = new UploadApplicationPayload(archive, knownRemoteResources);
    callback.onProcessMatchedResources(payload.getTotalUncompressedSize());
    HttpEntity<?> entity = generatePartialResourceRequest(payload, knownRemoteResources);
    ResponseEntity<Map<String, Object>> responseEntity = getRestTemplate().exchange(getUrl("/v2/apps/{guid}/bits?async=true"),
        HttpMethod.PUT, entity, new ParameterizedTypeReference<Map<String, Object>>() {
        }, appId);
    processAsyncJob(responseEntity.getBody(), callback);
}
项目:cf-java-client-sap    文件:CloudControllerClientImpl.java   
private void waitForAsyncJobCompletion(Map<String, Object> jobResponse) {
    long timeout = System.currentTimeMillis() + JOB_TIMEOUT;
    while (System.currentTimeMillis() < timeout) {
        CloudJob job = resourceMapper.mapResource(jobResponse, CloudJob.class);

        if (job.getStatus() == CloudJob.Status.FINISHED) {
            return;
        }

        if (job.getStatus() == CloudJob.Status.FAILED) {
            throw new CloudOperationException(job.getErrorDetails().getDescription());
        }

        try {
            Thread.sleep(JOB_POLLING_PERIOD);
        } catch (InterruptedException e) {
            return;
        }

        jobResponse = getRestTemplate().exchange(getUrl(job.getMeta().getUrl()), HttpMethod.GET, HttpEntity.EMPTY,
            new ParameterizedTypeReference<Map<String, Object>>() {
            }).getBody();
    }
}
项目:spring-credhub    文件:CredHubTemplate.java   
@Override
public <T> List<CredentialDetails<T>> getByNameWithHistory(final CredentialName name, Class<T> credentialType) {
    Assert.notNull(name, "credential name must not be null");
    Assert.notNull(credentialType, "credential type must not be null");

    final ParameterizedTypeReference<CredentialDetailsData<T>> ref =
            new ParameterizedTypeReference<CredentialDetailsData<T>>() {};

    return doWithRest(new RestOperationsCallback<List<CredentialDetails<T>>>() {
        @Override
        public List<CredentialDetails<T>> doWithRestOperations(RestOperations restOperations) {
            ResponseEntity<CredentialDetailsData<T>> response =
                    restOperations.exchange(NAME_URL_QUERY, GET, null, ref, name.getName());

            throwExceptionOnError(response);

            return response.getBody().getData();
        }
    });
}
项目:che-starter    文件:GitHubClient.java   
public GitHubEmail getPrimaryEmail(final String gitHubToken) {
    RestTemplate template = new GitHubRestTemplate(gitHubToken);
    ResponseEntity<List<GitHubEmail>> response = template.exchange(GITHUB_EMAIL_URL, HttpMethod.GET, null, new ParameterizedTypeReference<List<GitHubEmail>>(){});
    List<GitHubEmail> emails = response.getBody();
    GitHubEmail primary = emails.stream().filter(e -> e.isPrimary()).findFirst().get();
    return primary;
}
项目:CityPower-Build-Sample    文件:IncidentServiceImpl.java   
@Override
public CompletableFuture<List<IncidentBean>> getAllIncidentsAsync() {
    CompletableFuture<List<IncidentBean>> cf = new CompletableFuture<>();
    CompletableFuture.runAsync(() -> {
        LOG.info("Performing get {} web service", applicationProperties.getIncidentApiUrl() +"/incidents");
        final String restUri = applicationProperties.getIncidentApiUrl() +"/incidents";
        ResponseEntity<Resources<IncidentBean>> response = restTemplate.exchange(restUri, HttpMethod.GET, null,
                new ParameterizedTypeReference<Resources<IncidentBean>>() {});
        //            LOG.info("Total Incidents {}", response.getBody().size());
        Resources<IncidentBean> beanResources = response.getBody();
        Collection<IncidentBean> beanCol = beanResources.getContent();
        ArrayList<IncidentBean> beanList= new ArrayList<IncidentBean>(beanCol);
        cf.complete( beanList );
        LOG.info("Done getting incidents");
    });
    return cf;
}
项目:apollo-custom    文件:CtripUserServiceTest.java   
@Before
public void setUp() throws Exception {
  when(portalConfig.connectTimeout()).thenReturn(3000);
  when(portalConfig.readTimeout()).thenReturn(3000);
  ctripUserService = new CtripUserService(portalConfig);
  ReflectionTestUtils.setField(ctripUserService, "restTemplate", restTemplate);
  someResponseType =
      (ParameterizedTypeReference<Map<String, List<CtripUserService.UserServiceResponse>>>) ReflectionTestUtils
          .getField(ctripUserService, "responseType");

  someUserServiceUrl = "http://someurl";
  someUserServiceToken = "someToken";
  when(portalConfig.userServiceUrl()).thenReturn(someUserServiceUrl);
  when(portalConfig.userServiceAccessToken()).thenReturn(someUserServiceToken);

}
项目:spring-credhub    文件:CredHubTemplate.java   
@Override
public <T> CredentialDetails<T> regenerate(final CredentialName name) {
    Assert.notNull(name, "credential name must not be null");

    final ParameterizedTypeReference<CredentialDetails<T>> ref =
            new ParameterizedTypeReference<CredentialDetails<T>>() {};

    return doWithRest(new RestOperationsCallback<CredentialDetails<T>>() {
        @Override
        public CredentialDetails<T> doWithRestOperations(RestOperations restOperations) {
            Map<String, Object> request = new HashMap<String, Object>(1);
            request.put("name", name.getName());

            ResponseEntity<CredentialDetails<T>> response =
                    restOperations.exchange(REGENERATE_URL_PATH, POST,
                            new HttpEntity<Map<String, Object>>(request), ref);

            throwExceptionOnError(response);

            return response.getBody();
        }
    });
}
项目:spring-boot-vue-simple-sample    文件:JsonSampleControllerTest.java   
@Test
public void testNest() throws Exception {

    final Map<String, Object> grandchild = new HashMap<>();
    grandchild.put("foo", "grandchild");
    grandchild.put("bar", 1);
    grandchild.put("baz", "2017-02-01");
    grandchild.put("qux", Collections.emptyList());

    final Map<String, Object> child1 = new HashMap<>();
    child1.put("foo", "child1");
    child1.put("bar", 2);
    child1.put("baz", "2017-02-02");
    child1.put("qux", Collections.singletonList(grandchild));

    final Map<String, Object> child2 = new HashMap<>();
    child2.put("foo", "child2");
    child2.put("bar", 3);
    child2.put("baz", "2017-02-03");
    child2.put("qux", Collections.emptyList());

    final Map<String, Object> root = new HashMap<>();
    root.put("foo", "root");
    root.put("bar", 4);
    root.put("baz", "2017-02-04");
    root.put("qux", Arrays.asList(child1, child2));

    final RequestEntity<Map<String, Object>> requestEntity = RequestEntity
            .post(new UriTemplate(url).expand(port))
            .contentType(MediaType.APPLICATION_JSON)
            .accept(MediaType.APPLICATION_JSON)
            .body(root);
    final ParameterizedTypeReference<Map<String, Object>> responseType = new ParameterizedTypeReference<Map<String, Object>>() {
    };
    final ResponseEntity<Map<String, Object>> response = restTemplate.exchange(requestEntity,
            responseType);

    assertThat(response.getBody(), is(root));
}
项目:spring-boot-vue-simple-sample    文件:DivControllerTest.java   
private ResponseEntity<Map<String, Object>> doRequest(final Map<String, Object> body) {
    final RequestEntity<Map<String, Object>> requestEntity = RequestEntity
            .post(new UriTemplate(url).expand(port))
            .contentType(MediaType.APPLICATION_JSON)
            .accept(MediaType.APPLICATION_JSON)
            .body(body);
    final ParameterizedTypeReference<Map<String, Object>> responseType = new ParameterizedTypeReference<Map<String, Object>>() {
    };
    return restTemplate.exchange(requestEntity, responseType);
}
项目:mu-workshop-lab3    文件:BananaProvider.java   
private List<Map<String,Object>> getAll() {
  ParameterizedTypeReference<List<Map<String, Object>>> typeRef =
          new ParameterizedTypeReference<List<Map<String, Object>>>() {};

  ResponseEntity<List<Map<String, Object>>> exchange =
          this.restTemplate.exchange("http://banana-service/bananas",
                  HttpMethod.GET,null, typeRef);

  return exchange.getBody();
}
项目:spring-cloud-skipper    文件:DefaultSkipperClient.java   
@Override
public Info status(String releaseName, int releaseVersion) {
    ParameterizedTypeReference<Resource<Info>> typeReference =
            new ParameterizedTypeReference<Resource<Info>>() {  };
    Map<String, String> uriVariables = new HashMap<String, String>();
    uriVariables.put("releaseName", releaseName);
    uriVariables.put("releaseVersion", Integer.toString(releaseVersion));
    ResponseEntity<Resource<Info>> resourceResponseEntity =
            restTemplate.exchange(baseUri + "/release/status/{releaseName}/{releaseVersion}",
                    HttpMethod.GET,
                    null,
                    typeReference,
                    uriVariables);
    return resourceResponseEntity.getBody().getContent();
}
项目:apollo-custom    文件:CtripUserService.java   
public CtripUserService(PortalConfig portalConfig) {
  this.portalConfig = portalConfig;
  this.restTemplate = new RestTemplate(clientHttpRequestFactory());
  this.searchUserMatchFields =
      Lists.newArrayList("empcode", "empaccount", "displayname", "c_name", "pinyin");
  this.responseType = new ParameterizedTypeReference<Map<String, List<UserServiceResponse>>>() {
  };
}
项目:CityPower-Build-Sample    文件:IncidentServiceImpl.java   
@Override
   @JsonSerialize(using = Jackson2HalModule.HalResourcesSerializer.class)
   @JsonDeserialize(using = Jackson2HalModule.HalResourcesDeserializer.class)
public PagedIncidents getIncidentsPaged(int pagenum,int pagesize) {
    LOG.info("Performing get {} web service", applicationProperties.getIncidentApiUrl() +"/incidents");
    final String restUri = applicationProperties.getIncidentApiUrl() +"/incidents?page="+pagenum+"&size="+pagesize;
    ResponseEntity<PagedResources<IncidentBean>> response = restTemplate.exchange(restUri, HttpMethod.GET, null,
            new ParameterizedTypeReference<PagedResources<IncidentBean>>() {});
    //        LOG.info("Total Incidents {}", response.getBody().size());
    PagedResources<IncidentBean> beanResources = response.getBody();
    PagedIncidents incidents = new PagedIncidents(beanResources,pagenum);
    return incidents;
}
项目:swordfish-service    文件:TeamQueryGatewayRestController.java   
@GetMapping("/teams/{id}")
public ResponseEntity<String> teamsById(@PathVariable String id) {
    ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {
    };

    return restTemplate.exchange(SERVICE + "/{id}", HttpMethod.GET, authenticationService.addAuthenticationHeader(), reference, id);
}
项目:spring-cloud-skipper    文件:DefaultSkipperClient.java   
@Override
public Resources<Release> history(String releaseName) {
    ParameterizedTypeReference<Resources<Release>> typeReference =
            new ParameterizedTypeReference<Resources<Release>>() {  };
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("name", releaseName);
    Traverson.TraversalBuilder traversalBuilder = this.traverson.follow("releases", "search",
            "findByNameIgnoreCaseContainingOrderByNameAscVersionDesc");

    return traversalBuilder.withTemplateParameters(parameters).toObject(typeReference);
}
项目:spring-cloud-skipper    文件:DefaultSkipperClient.java   
@Override
public Resources<Repository> listRepositories() {
    ParameterizedTypeReference<Resources<Repository>> typeReference = new ParameterizedTypeReference<Resources<Repository>>() {
    };
    Traverson.TraversalBuilder traversalBuilder = this.traverson.follow("repositories");
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("size", 2000);
    return traversalBuilder.withTemplateParameters(parameters).toObject(typeReference);
}
项目:spring-cloud-skipper    文件:DefaultSkipperClient.java   
@Override
public Resources<Deployer> listDeployers() {
    ParameterizedTypeReference<Resources<Deployer>> typeReference = new ParameterizedTypeReference<Resources<Deployer>>() {
    };
    Traverson.TraversalBuilder traversalBuilder = this.traverson.follow("deployers");
    Map<String, Object> parameters = new HashMap<>();
    parameters.put("size", 2000);
    return traversalBuilder.withTemplateParameters(parameters).toObject(typeReference);
}
项目:swordfish-service    文件:RestoreQueryGatewayRestController.java   
@GetMapping("/restore/snapshots/{projectId}")
public ResponseEntity<String> listAllSnapshots(@PathVariable String projectId) {
    ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() {
    };

    return restTemplate.exchange(SERVICE + "/snapshots/{projectId}", HttpMethod.GET,
            null, reference, projectId);
}
项目:cdct    文件:CustomerClient.java   
public Collection<Customer> getCustomers() {

        ParameterizedTypeReference<Collection<Customer>> responseType
                = new ParameterizedTypeReference<Collection<Customer>>() {
        };

        return restTemplate.exchange(
                host + "/customers",
                HttpMethod.GET,
                null,
                responseType)
                .getBody();
    }
项目:Learning-Spring-Boot-2.0-Second-Edition    文件:CommentHelper.java   
@HystrixCommand(fallbackMethod = "defaultComments")
public List<Comment> getComments(Image image) {
    return restTemplate.exchange(
        "http://COMMENTS/comments/{imageId}",
        HttpMethod.GET,
        null,
        new ParameterizedTypeReference<List<Comment>>() {
        },
        image.getId()).getBody();
}