Search in sources :

Example 11 with ApiResultObject

use of com.terran4j.commons.api2doc.domain.ApiResultObject in project commons by terran4j.

the class ParseListBeanTest method testParseListBean.

@Test
public void testParseListBean() throws Exception {
    log.info("testParseListBean");
    Method method = ReflectionUtils.findMethod(getClass(), "getListBean");
    Assert.assertNotNull(method);
    KeyedList<String, ApiResultObject> list = new KeyedList<>();
    ApiResultObject results = ApiResultObject.parseResultType(method, list);
    Assert.assertNotNull(results);
    log.info("results: {}", results);
    Assert.assertTrue(list.size() == 2);
    ApiResultObject resultTop = list.get(0);
    log.info("resultTop: {}", resultTop);
    Assert.assertTrue(resultTop.getChildren().size() == 1);
    ApiResultObject users = resultTop.getChildren().get(0);
    Assert.assertEquals("users", users.getId());
    Assert.assertEquals("There are many users!", users.getComment().getValue());
    ApiResultObject resultUser = list.get(1);
    log.info("resultUser: {}", resultUser);
    Assert.assertEquals("users", resultUser.getId());
    Assert.assertTrue(resultUser.getChildren().size() == 2);
    ApiResultObject userId = resultUser.getChildren().get(0);
    Assert.assertEquals("id", userId.getId());
    Assert.assertEquals("账号id", userId.getComment().getValue());
}
Also used : KeyedList(com.terran4j.commons.util.value.KeyedList) Method(java.lang.reflect.Method) ApiResultObject(com.terran4j.commons.api2doc.domain.ApiResultObject) Test(org.junit.Test)

Example 12 with ApiResultObject

use of com.terran4j.commons.api2doc.domain.ApiResultObject in project commons by terran4j.

the class ParseListBeanTest method testGetSourceType.

@Test
public void testGetSourceType() throws Exception {
    log.info("testGetSourceType");
    Method method = ReflectionUtils.findMethod(getClass(), "getListBean");
    ApiResultObject results = ApiResultObject.parseResultType(method, new KeyedList<>());
    Assert.assertNotNull(results);
    log.info("results: {}", results);
    Assert.assertTrue(results.getChildren().size() == 1);
    ApiResultObject user = results.getChildren().get(0);
    Assert.assertEquals(User.class, user.getSourceType());
}
Also used : Method(java.lang.reflect.Method) ApiResultObject(com.terran4j.commons.api2doc.domain.ApiResultObject) Test(org.junit.Test)

Aggregations

ApiResultObject (com.terran4j.commons.api2doc.domain.ApiResultObject)12 Test (org.junit.Test)11 Method (java.lang.reflect.Method)9 KeyedList (com.terran4j.commons.util.value.KeyedList)7 ApiDocObject (com.terran4j.commons.api2doc.domain.ApiDocObject)2 ApiFolderObject (com.terran4j.commons.api2doc.domain.ApiFolderObject)2 ApiParamObject (com.terran4j.commons.api2doc.domain.ApiParamObject)2 Api2DocCollector (com.terran4j.commons.api2doc.impl.Api2DocCollector)2 MemoryCodeOutput (com.terran4j.commons.api2doc.codewriter.MemoryCodeOutput)1 Set (java.util.Set)1 HashedMap (org.apache.commons.collections4.map.HashedMap)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1