use of org.apache.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.
the class CodeFirstRestTemplate method testModelFieldIgnore.
private void testModelFieldIgnore(RestTemplate template, String cseUrlPrefix) {
InputModelForTestIgnore input = new InputModelForTestIgnore("input_id_rest", "input_id_content", new Person("inputSomeone"), new JsonObject("{\"InputJsonKey\" : \"InputJsonValue\"}"), () -> {
});
OutputModelForTestIgnore output = template.postForObject(cseUrlPrefix + "ignore", input, OutputModelForTestIgnore.class);
TestMgr.check(null, output.getInputId());
TestMgr.check(input.getContent(), output.getContent());
TestMgr.check(null, output.getOutputId());
TestMgr.check(null, output.getInputIgnoreInterface());
TestMgr.check(null, output.getInputJsonObject());
TestMgr.check(null, output.getInputObject());
TestMgr.check(null, output.getOutputIgnoreInterface());
TestMgr.check(null, output.getOutputJsonObject());
TestMgr.check(null, output.getOutputObject());
}
use of org.apache.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.
the class SpringMvcIntegrationTestBase method ableToPostObjectAsJson.
@Test
public void ableToPostObjectAsJson() throws Exception {
Map<String, String> personFieldMap = new HashMap<>();
personFieldMap.put("name", "person name from map");
Person person = restTemplate.postForObject(codeFirstUrl + "sayhello", jsonRequest(personFieldMap), Person.class);
assertThat(person.toString(), is("hello person name from map"));
Person input = new Person();
input.setName("person name from Object");
person = restTemplate.postForObject(codeFirstUrl + "sayhello", jsonRequest(input), Person.class);
assertThat(person.toString(), is("hello person name from Object"));
ListenableFuture<ResponseEntity<Person>> listenableFuture = asyncRestTemplate.postForEntity(codeFirstUrl + "sayhello", jsonRequest(personFieldMap), Person.class);
ResponseEntity<Person> futureResponse = listenableFuture.get();
person = futureResponse.getBody();
assertThat(person.toString(), is("hello person name from map"));
listenableFuture = asyncRestTemplate.postForEntity(codeFirstUrl + "sayhello", jsonRequest(input), Person.class);
futureResponse = listenableFuture.get();
person = futureResponse.getBody();
assertThat(person.toString(), is("hello person name from Object"));
}
use of org.apache.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.
the class SpringMvcIntegrationTestBase method ableToPostWithHeader.
@Test
public void ableToPostWithHeader() throws Exception {
Person person = new Person();
person.setName("person name");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(APPLICATION_JSON);
headers.add("prefix", "prefix prefix");
HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
ResponseEntity<String> responseEntity = restTemplate.postForEntity(codeFirstUrl + "saysomething", requestEntity, String.class);
assertThat(jsonOf(responseEntity.getBody(), String.class), is("prefix prefix person name"));
ListenableFuture<ResponseEntity<String>> listenableFuture = asyncRestTemplate.postForEntity(codeFirstUrl + "saysomething", requestEntity, String.class);
responseEntity = listenableFuture.get();
assertThat(jsonOf(responseEntity.getBody(), String.class), is("prefix prefix person name"));
}
use of org.apache.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.
the class JaxrsIntegrationTestBase method ableToPostObjectAsJson.
@Test
public void ableToPostObjectAsJson() {
Map<String, String> personFieldMap = new HashMap<>();
personFieldMap.put("name", "person name from map");
for (String url : urls) {
Person person = restTemplate.postForObject(url + "sayhello", jsonRequest(personFieldMap), Person.class);
assertEquals("hello person name from map", person.toString());
Person input = new Person();
input.setName("person name from Object");
person = restTemplate.postForObject(url + "sayhello", jsonRequest(input), Person.class);
assertEquals("hello person name from Object", person.toString());
}
}
use of org.apache.servicecomb.demo.compute.Person in project java-chassis by ServiceComb.
the class JaxrsIntegrationTestBase method ableToPostWithHeaderWithIdentifier.
@Test
public void ableToPostWithHeaderWithIdentifier() {
Person person = new Person();
person.setName("person name");
HttpHeaders headers = new HttpHeaders();
headers.setContentType(APPLICATION_JSON);
headers.add("prefix-test", "prefix prefix");
HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
for (String url : urls) {
ResponseEntity<String> responseEntity = restTemplate.postForEntity(url + "saysomething1", requestEntity, String.class);
assertEquals("prefix prefix person name", jsonBodyOf(responseEntity, String.class));
}
}
Aggregations