use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.
the class JaxrsClient method testExchange.
private static void testExchange(RestTemplate template, String cseUrlPrefix) {
HttpHeaders headers = new HttpHeaders();
headers.add("Accept", MediaType.APPLICATION_JSON);
Person person = new Person();
person.setName("world");
HttpEntity<Person> requestEntity = new HttpEntity<>(person, headers);
ResponseEntity<Person> resEntity = template.exchange(cseUrlPrefix + "/compute/sayhello", HttpMethod.POST, requestEntity, Person.class);
TestMgr.check("hello world", resEntity.getBody());
ResponseEntity<String> resEntity2 = template.exchange(cseUrlPrefix + "/compute/addstring?s=abc&s=def", HttpMethod.DELETE, null, String.class);
TestMgr.check("abcdef", resEntity2.getBody());
}
use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.
the class JaxrsClient method testPost.
private static void testPost(RestTemplate template, String cseUrlPrefix) {
Map<String, String> params = new HashMap<>();
params.put("a", "5");
params.put("b", "3");
int result = template.postForObject(cseUrlPrefix + "/compute/add", params, Integer.class);
TestMgr.check(8, result);
Person person = new Person();
person.setName("world");
Person resultPerson = template.postForObject(cseUrlPrefix + "/compute/sayhello", person, Person.class);
TestMgr.check("hello world", resultPerson.getName());
HttpHeaders headers = new HttpHeaders();
headers.add("prefix", "haha");
HttpEntity<Person> reqEntity = new HttpEntity<>(person, headers);
TestMgr.check("haha world", template.postForObject(cseUrlPrefix + "/compute/saysomething", reqEntity, String.class));
}
use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstPojoClient method testCodeFirstSayHello.
protected void testCodeFirstSayHello(CodeFirstPojoIntf codeFirst) {
Person input = new Person();
input.setName("person name");
Person result = codeFirst.sayHello(input);
TestMgr.check("hello person name", result.getName());
}
use of org.apache.servicecomb.demo.compute.Person in project incubator-servicecomb-java-chassis by apache.
the class CodeFirstRestTemplate method testModelFieldIgnore.
protected 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 incubator-servicecomb-java-chassis by apache.
the class CodeFirstRestTemplate method testCodeFirstSayHello.
protected void testCodeFirstSayHello(RestTemplate template, String cseUrlPrefix) {
Map<String, String> persionFieldMap = new HashMap<>();
persionFieldMap.put("name", "person name from map");
Person result = template.postForObject(cseUrlPrefix + "sayhello", persionFieldMap, Person.class);
TestMgr.check("hello person name from map", result);
Person input = new Person();
input.setName("person name from Object");
result = template.postForObject(cseUrlPrefix + "sayhello", input, Person.class);
TestMgr.check("hello person name from Object", result);
}
Aggregations