Search in sources :

Example 1 with Customer

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);
}
Also used : HttpClient(com.tvd12.ezyhttp.client.HttpClient) GetRequest(com.tvd12.ezyhttp.client.request.GetRequest) RequestEntity(com.tvd12.ezyhttp.client.request.RequestEntity)

Example 2 with Customer

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);
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) Customer(com.tvd12.ezyhttp.client.test.request.Customer) HttpClient(com.tvd12.ezyhttp.client.HttpClient) RequestEntity(com.tvd12.ezyhttp.client.request.RequestEntity)

Example 3 with Customer

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());
}
Also used : PostRequest(com.tvd12.ezyhttp.client.request.PostRequest) HttpClient(com.tvd12.ezyhttp.client.HttpClient) GetRequest(com.tvd12.ezyhttp.client.request.GetRequest) List(java.util.List) DeleteRequest(com.tvd12.ezyhttp.client.request.DeleteRequest)

Example 4 with Customer

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));
}
Also used : URITree(com.tvd12.ezyhttp.core.net.URITree) Test(org.testng.annotations.Test)

Example 5 with Customer

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));
}
Also used : Customer(com.tvd12.ezyhttp.server.boot.test.data.Customer) EzyPostInit(com.tvd12.ezyfox.bean.annotation.EzyPostInit)

Aggregations

HttpClient (com.tvd12.ezyhttp.client.HttpClient)3 GetRequest (com.tvd12.ezyhttp.client.request.GetRequest)2 PostRequest (com.tvd12.ezyhttp.client.request.PostRequest)2 RequestEntity (com.tvd12.ezyhttp.client.request.RequestEntity)2 EzyPostInit (com.tvd12.ezyfox.bean.annotation.EzyPostInit)1 DeleteRequest (com.tvd12.ezyhttp.client.request.DeleteRequest)1 Customer (com.tvd12.ezyhttp.client.test.request.Customer)1 URITree (com.tvd12.ezyhttp.core.net.URITree)1 Customer (com.tvd12.ezyhttp.server.boot.test.data.Customer)1 List (java.util.List)1 Test (org.testng.annotations.Test)1