Search in sources :

Example 1 with MemoryCodeOutput

use of com.terran4j.commons.api2doc.codewriter.MemoryCodeOutput in project commons by terran4j.

the class JavaBeanCodeWriterTest method testGetModel.

@Test
public void testGetModel() throws Exception {
    log.info("testGetModel");
    Method method = ReflectionUtils.findMethod(getClass(), "getUser");
    KeyedList<String, ApiResultObject> totalResults = new KeyedList<>();
    ApiResultObject user = ApiResultObject.parseResultType(method, totalResults);
    Map<String, Object> model = javaBeanCodeWriter.getModel(user, "User", null);
    @SuppressWarnings("unchecked") Set<String> imports = (Set<String>) model.get("imports");
    log.info("imports: {}", imports);
    Assert.assertFalse(imports.contains(Date.class.getName()));
    MemoryCodeOutput out = new MemoryCodeOutput();
    javaBeanCodeWriter.writeCode(user, "User", out, null);
    String code = out.getCode("User.java");
    log.info("User.java:\n{}", code);
}
Also used : Set(java.util.Set) MemoryCodeOutput(com.terran4j.commons.api2doc.codewriter.MemoryCodeOutput) KeyedList(com.terran4j.commons.util.value.KeyedList) ApiResultObject(com.terran4j.commons.api2doc.domain.ApiResultObject) Method(java.lang.reflect.Method) ApiResultObject(com.terran4j.commons.api2doc.domain.ApiResultObject) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

MemoryCodeOutput (com.terran4j.commons.api2doc.codewriter.MemoryCodeOutput)1 ApiResultObject (com.terran4j.commons.api2doc.domain.ApiResultObject)1 KeyedList (com.terran4j.commons.util.value.KeyedList)1 Method (java.lang.reflect.Method)1 Set (java.util.Set)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1