Example usage for org.springframework.web.client RestTemplate getForEntity

List of usage examples for org.springframework.web.client RestTemplate getForEntity

Introduction

In this page you can find the example usage for org.springframework.web.client RestTemplate getForEntity.

Prototype

@Override
    public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String, ?> uriVariables)
            throws RestClientException 

Source Link

Usage

From source file:org.springframework.http.converter.obm.ThriftHttpMessageConverterTest.java

@Test
public void testSimpleIntegration() throws Throwable {
    RestIntegrationTestUtils.startServiceAndConnect(MyService.class,
            new RestIntegrationTestUtils.ServerExecutionCallback() {
                @Override//from w  w w . j ava2 s  .c om
                public void doWithServer(RestTemplate clientRestTemplate, Server server) throws Throwable {

                    Assert.assertNotNull(clientRestTemplate);

                    Map<String, Object> mapOfVars = new HashMap<String, Object>();
                    mapOfVars.put("customerId", 3);

                    Customer customer = clientRestTemplate
                            .getForEntity("http://localhost:8080/ws/customers/{customerId}", Customer.class,
                                    mapOfVars)
                            .getBody();
                    Assert.assertNotNull(customer.getFirstName());
                    Assert.assertNotNull(customer.getLastName());
                    Assert.assertNotNull(customer.getEmail());

                    if (log.isDebugEnabled()) {
                        log.debug("response payload: " + ToStringBuilder.reflectionToString(customer));
                    }
                }
            });
}