use of com.dtflys.test.http.model.JsonTestUser in project forest by dromara.
the class TestPostClient method testPostJsonListInObjInDataProperty.
@Test
public void testPostJsonListInObjInDataProperty() throws InterruptedException {
server.enqueue(new MockResponse().setBody(EXPECTED));
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
JsonTestList testList = new JsonTestList();
testList.setUserList(Collections.singletonList(user));
assertThat(postClient.postJsonListInObjInDataProperty(testList)).isNotNull().isEqualTo(EXPECTED);
mockRequest(server).assertMethodEquals("POST").assertPathEquals("/json").assertHeaderEquals("Content-Type", "application/json; charset=utf-8").assertBodyEquals("{\"userList\":[{\"username\":\"foo\"}]}");
}
use of com.dtflys.test.http.model.JsonTestUser in project forest by dromara.
the class TestPostClient method testPostJsonObjList.
@Test
public void testPostJsonObjList() throws InterruptedException {
server.enqueue(new MockResponse().setBody(EXPECTED));
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
JsonTestList testList = new JsonTestList();
testList.setUserList(Collections.singletonList(user));
List<JsonTestList> list = new ArrayList<>();
list.add(testList);
assertThat(postClient.postJsonObjListWithDataObjectAnn(list)).isNotNull().isEqualTo(EXPECTED);
mockRequest(server).assertMethodEquals("POST").assertPathEquals("/json").assertHeaderEquals("Content-Type", "application/json; charset=utf-8").assertBodyEquals("[{\"userList\":[{\"username\":\"foo\"}]}]");
}
use of com.dtflys.test.http.model.JsonTestUser in project forest by dromara.
the class TestPostClient method testJsonPostBodyObj.
@Test
public void testJsonPostBodyObj() throws InterruptedException {
server.enqueue(new MockResponse().setBody(EXPECTED));
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
assertThat(postClient.postJsonBodyObj(user)).isNotNull().isEqualTo(EXPECTED);
mockRequest(server).assertMethodEquals("POST").assertPathEquals("/json").assertHeaderEquals("Content-Type", "application/json").assertBodyEquals("{\"username\":\"foo\"}");
}
use of com.dtflys.test.http.model.JsonTestUser in project forest by dromara.
the class TestPostClient method testPostJsonObjListWithLog_content_noRequest_noStatus.
@Test
public void testPostJsonObjListWithLog_content_noRequest_noStatus() {
server.enqueue(new MockResponse().setBody(EXPECTED));
ForestLogger logger = Mockito.mock(ForestLogger.class);
configuration.getLogHandler().setLogger(logger);
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
JsonTestList testList = new JsonTestList();
testList.setUserList(Collections.singletonList(user));
List<JsonTestList> list = new ArrayList<>();
list.add(testList);
assertThat(postClient.postJsonObjListWithLog_content_noRequest_noStatus(list)).isNotNull().isEqualTo(EXPECTED);
Mockito.verify(logger, Mockito.never()).info("[Forest] Request (" + configuration.getBackend().getName() + "): \n" + "\tPOST http://localhost:" + server.getPort() + "/json HTTP\n" + "\tHeaders: \n" + "\t\tContent-Type: application/json; charset=utf-8\n" + "\tBody: [{\"userList\":[{\"username\":\"foo\"}]}]");
Mockito.verify(logger).info("[Forest] Response Content:\n\t" + EXPECTED);
}
use of com.dtflys.test.http.model.JsonTestUser in project forest by dromara.
the class TestPostClient method testPostJsonListInObjWithDataObjectAnn.
@Test
public void testPostJsonListInObjWithDataObjectAnn() throws InterruptedException {
server.enqueue(new MockResponse().setBody(EXPECTED));
JsonTestUser user = new JsonTestUser();
user.setUsername("foo");
JsonTestList testList = new JsonTestList();
testList.setUserList(Collections.singletonList(user));
assertThat(postClient.postJsonListInObjWithDataObjectAnn(testList)).isNotNull().isEqualTo(EXPECTED);
mockRequest(server).assertMethodEquals("POST").assertPathEquals("/json").assertHeaderEquals("Content-Type", "application/json; charset=utf-8").assertBodyEquals("{\"userList\":[{\"username\":\"foo\"}]}");
}
Aggregations