use of com.tvd12.ezyhttp.server.boot.test.data.Customer in project ezyhttp by youngmonkeys.
the class CustomerApisTest method getCustomerTest.
protected static void getCustomerTest() throws Exception {
HttpClient client = HttpClient.builder().build();
RequestEntity entity = RequestEntity.builder().header("token", "123").build();
GetRequest request = new GetRequest().setURL("http://localhost:8081/api/v1/customer/hello/dung").setEntity(entity).setResponseType(String.class).setReadTimeout(HttpClient.NO_TIMEOUT).setConnectTimeout(HttpClient.NO_TIMEOUT);
String response = client.call(request);
System.out.println(response);
}
use of com.tvd12.ezyhttp.server.boot.test.data.Customer in project ezyhttp by youngmonkeys.
the class CustomerApisTest method addCustomerTest.
protected static void addCustomerTest() throws Exception {
HttpClient client = HttpClient.builder().build();
Customer body = new Customer();
body.setName("dung");
body.setAge(28);
RequestEntity entity = RequestEntity.of(body).header("token", "123").build();
PostRequest request = new PostRequest().setURL("http://localhost:8081/api/v1/customer/add").setEntity(entity).setResponseType(String.class).setReadTimeout(HttpClient.NO_TIMEOUT).setConnectTimeout(HttpClient.NO_TIMEOUT);
String response = client.call(request);
System.out.println(response);
}
use of com.tvd12.ezyhttp.server.boot.test.data.Customer in project ezyhttp by youngmonkeys.
the class V018HttpClientTest method main.
public static void main(String[] args) throws Exception {
HttpClient client = HttpClient.builder().build();
PostRequest loveRequest = new PostRequest().setURL("http://localhost:8083/love");
System.out.println(client.request(loveRequest));
DeleteRequest deleteRequest = new DeleteRequest().setURL("http://localhost:8083/api/v1/customer/delete").setEntity(RequestEntity.builder().header("token", "123456").build());
System.out.println(client.request(deleteRequest));
System.out.println(client.request(deleteRequest).getBody().toString());
GetRequest textRequest = new GetRequest().setURL("http://localhost:8083/text");
System.out.println((String) client.call(textRequest));
GetRequest listRequest = new GetRequest().setResponseType(List.class).setURL("http://localhost:8083/list");
System.out.println(client.call(listRequest).toString());
}
use of com.tvd12.ezyhttp.server.boot.test.data.Customer in project ezyhttp by youngmonkeys.
the class URITreeTest method test.
@Test
public void test() {
// given
String uri11 = "/api/v1/customer/{name}/create";
String uri12 = "/api/v1/customer/{name}/delete";
String uri2 = "/api/v1/user";
// when
URITree tree = new URITree();
tree.addURI(uri11);
tree.addURI(uri12);
tree.addURI(uri2);
// then
System.out.println("tree: " + tree);
String check11 = "/api/v1/customer/dung/create";
String check12 = "/api/v1/customer/dung/create/1";
Assert.assertEquals("/api/v1/customer/{name}/create", tree.getMatchedURI(check11));
System.out.println("check11: " + tree.getMatchedURI(check11));
Assert.assertNull(tree.getMatchedURI(check12));
System.out.println("check12: " + tree.getMatchedURI(check12));
}
use of com.tvd12.ezyhttp.server.boot.test.data.Customer in project ezyhttp by youngmonkeys.
the class CustomerService method postInit.
@EzyPostInit
public void postInit() {
save(new Customer(1L, "Hello", 25));
save(new Customer(2L, "World", 26));
}
Aggregations