use of com.dtflys.test.http.model.Cause in project forest by dromara.
the class TestForestJacksonConverter method testJavaObjectToMap3.
@Test
public void testJavaObjectToMap3() {
FormListParam param = new FormListParam();
List<Integer> idList = Lists.newArrayList(1, 2, 3);
param.setUsername("foo");
param.setPassword("123456");
param.setIdList(idList);
Cause cause1 = new Cause();
cause1.setId(1);
cause1.setScore(87);
Cause cause2 = new Cause();
cause2.setId(2);
cause2.setScore(73);
List<Cause> causes = Lists.newArrayList(cause1, cause2);
param.setCause(causes);
Map map = ReflectUtils.convertObjectToMap(param, ForestConfiguration.configuration());
assertEquals("foo", map.get("username"));
assertEquals("123456", map.get("password"));
assertEquals(idList, map.get("idList"));
assertEquals(causes, map.get("cause"));
}
use of com.dtflys.test.http.model.Cause in project forest by dromara.
the class TestPostClient method postFormListWithBodyAnn2.
@Test
public void postFormListWithBodyAnn2() {
server.enqueue(new MockResponse().setBody(EXPECTED));
FormListParam param = new FormListParam();
List<Integer> idList = Lists.newArrayList(1, 2, 3);
param.setUsername("foo");
param.setPassword("123456");
param.setIdList(idList);
Cause cause1 = new Cause();
cause1.setId(1);
cause1.setScore(87);
Cause cause2 = new Cause();
cause2.setId(2);
cause2.setScore(73);
List<Cause> causes = Lists.newArrayList(cause1, cause2);
param.setCause(causes);
assertThat(postClient.postFormListWithBodyAnn2(param)).isNotNull().isEqualTo(EXPECTED);
mockRequest(server).assertMethodEquals("POST").assertPathEquals("/form-array").assertHeaderEquals("Content-Type", "application/x-www-form-urlencoded").assertBodyEquals("username=foo&password=123456&idList=1,2,3&cause[0].id=1&cause[0].score=87&cause[1].id=2&cause[1].score=73");
}
Aggregations