@Test public void test() throws IOException { String code = readCode("api/BaseApiController.java"); Analyse analyse = createAnalyse(); ApiInfo api = (ApiInfo) analyse.analyse(code, "api"); assertEquals("BaseApi", api.getName()); assertEquals("api", api.getPackageName()); ImportsInfo imports = api.getImports(); assertEquals(9, imports.getImports().size()); assertImport(imports.get("TestForm"), "api.form.TestForm", true); assertImport(imports.get("TestObject"), "api.model.TestObject", true); assertImport(imports.get("User"), "api.model.User", true); assertImport(imports.get("PathVariable"), PathVariable.class.getName()); assertImport(imports.get("Valid"), Valid.class.getName()); JavadocInfo comment = api.getComment(); Map.Entry<String, Collection<List<String>>> entry = comment.getTags(0); assertJavadocInfo(api.getComment(), "@author", Collections.singletonList(" zuoge85 on 15/6/11.")); testBase(api.get("base/",ActionType.POST)); testBaseId(api.get("base/{id}", ActionType.GET)); testBaseUrl(api.get("baseUrl/", ActionType.GET)); }
@Override public ModuleInfo analyse() { ApiInfo apiInfo = new ApiInfo(); initModuleInfo(apiInfo); apiInfo.setName(apiInfo.getName().replace("Controller", "")); MethodDeclaration[] methods = jdtInfo.getType().getMethods(); for (MethodDeclaration method : methods) { List modifiers = method.modifiers(); for (Object o : modifiers) { if (o instanceof Annotation) { Annotation annotation = (Annotation) o; if (equalsType(annotation.getTypeName(), RequestMapping.class)) { ApiMethodInfo apiMethodInfo = analyseMethodInfo(method, annotation); if (!apiMethodInfo.isIgnore()) { apiInfo.addApiMethod(apiMethodInfo); log.debug("ApiMethodInfo: {}:{}", method.getName(), apiMethodInfo); } } } } } return apiInfo; }
JdtApiAnalyse extends JdtAbstractModuleAnalyse { @Override public ModuleInfo analyse() { ApiInfo apiInfo = new ApiInfo(); initModuleInfo(apiInfo); apiInfo.setName(apiInfo.getName().replace("Controller", "")); MethodDeclaration[] methods = jdtInfo.getType().getMethods(); for (MethodDeclaration method : methods) { List modifiers = method.modifiers(); for (Object o : modifiers) { if (o instanceof Annotation) { Annotation annotation = (Annotation) o; if (equalsType(annotation.getTypeName(), RequestMapping.class)) { ApiMethodInfo apiMethodInfo = analyseMethodInfo(method, annotation); if (!apiMethodInfo.isIgnore()) { apiInfo.addApiMethod(apiMethodInfo); log.debug("ApiMethodInfo: {}:{}", method.getName(), apiMethodInfo); } } } } } return apiInfo; } }
JdtApiAnalyse extends JdtAbstractModuleAnalyse { @Override public ModuleInfo analyse() { ApiInfo apiInfo = new ApiInfo(); initModuleInfo(apiInfo); apiInfo.setName(apiInfo.getName().replace("Controller", "")); MethodDeclaration[] methods = jdtInfo.getType().getMethods(); for (MethodDeclaration method : methods) { List modifiers = method.modifiers(); for (Object o : modifiers) { if (o instanceof Annotation) { Annotation annotation = (Annotation) o; if (equalsType(annotation.getTypeName(), RequestMapping.class)) { ApiMethodInfo apiMethodInfo = analyseMethodInfo(method, annotation); if (!apiMethodInfo.isIgnore()) { apiInfo.addApiMethod(apiMethodInfo); log.debug("ApiMethodInfo: {}:{}", method.getName(), apiMethodInfo); } } } } } return apiInfo; } JdtApiAnalyse(JdtInfo jdtInfo); }
JdtApiAnalyse extends JdtAbstractModuleAnalyse { @Override public ModuleInfo analyse() { ApiInfo apiInfo = new ApiInfo(); initModuleInfo(apiInfo); apiInfo.setName(apiInfo.getName().replace("Controller", "")); MethodDeclaration[] methods = jdtInfo.getType().getMethods(); for (MethodDeclaration method : methods) { List modifiers = method.modifiers(); for (Object o : modifiers) { if (o instanceof Annotation) { Annotation annotation = (Annotation) o; if (equalsType(annotation.getTypeName(), RequestMapping.class)) { ApiMethodInfo apiMethodInfo = analyseMethodInfo(method, annotation); if (!apiMethodInfo.isIgnore()) { apiInfo.addApiMethod(apiMethodInfo); log.debug("ApiMethodInfo: {}:{}", method.getName(), apiMethodInfo); } } } } } return apiInfo; } JdtApiAnalyse(JdtInfo jdtInfo); @Override ModuleInfo analyse(); }
JdtApiAnalyse extends JdtAbstractModuleAnalyse { @Override public ModuleInfo analyse() { ApiInfo apiInfo = new ApiInfo(); initModuleInfo(apiInfo); apiInfo.setName(apiInfo.getName().replace("Controller", "")); MethodDeclaration[] methods = jdtInfo.getType().getMethods(); for (MethodDeclaration method : methods) { List modifiers = method.modifiers(); for (Object o : modifiers) { if (o instanceof Annotation) { Annotation annotation = (Annotation) o; if (equalsType(annotation.getTypeName(), RequestMapping.class)) { ApiMethodInfo apiMethodInfo = analyseMethodInfo(method, annotation); if (!apiMethodInfo.isIgnore()) { apiInfo.addApiMethod(apiMethodInfo); log.debug("ApiMethodInfo: {}:{}", method.getName(), apiMethodInfo); } } } } } return apiInfo; } JdtApiAnalyse(JdtInfo jdtInfo); @Override ModuleInfo analyse();  }