@Test public void testParameters() throws IOException, ParseException { File file = new File("src/test/java/controller/ParameterizedController.java"); final CompilationUnit declaration = JavaParser.parse(file); ControllerModel model = new ControllerModel(); visitor.visit(declaration, model); ControllerRouteModel route = getModelByPath(model, "/params/1"); assertThat(route).isNotNull(); assertThat(route.getParams()).hasSize(1); RouteParamModel param = (RouteParamModel) Iterables.get(route.getParams(), 0); assertThat(param.getName()).isEqualTo("hello"); assertThat(param.getParamType()).isEqualTo(RouteParamModel.ParamType.FORM); assertThat(param.getDefaultValue()).isNull(); assertThat(param.getValueType()).isEqualTo(String.class.getSimpleName()); route = getModelByPath(model, "/params/2/{hello}"); assertThat(route).isNotNull(); assertThat(route.getParams()).hasSize(1); param = (RouteParamModel) Iterables.get(route.getParams(), 0); assertThat(param.getName()).isEqualTo("hello"); assertThat(param.getParamType()).isEqualTo(RouteParamModel.ParamType.PATH_PARAM); assertThat(param.getDefaultValue()).isNull(); assertThat(param.getValueType()).isEqualTo(String.class.getSimpleName()); route = getModelByPath(model, "/params/3/{hello}"); assertThat(route).isNotNull(); assertThat(route.getParams()).hasSize(2); param = getParamByName(route.getParams(), "hello"); assertThat(param.getParamType()).isEqualTo(RouteParamModel.ParamType.PATH_PARAM); assertThat(param.getDefaultValue()).isNull(); assertThat(param.getValueType()).isEqualTo(String.class.getSimpleName()); param = getParamByName(route.getParams(), "name"); assertThat(param.getParamType()).isEqualTo(RouteParamModel.ParamType.FORM); assertThat(param.getDefaultValue()).isEqualTo("wisdom"); assertThat(param.getValueType()).isEqualTo(String.class.getSimpleName()); }
@Override public void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller) { controller.setName(declaration.getName()); LOGGER.info("[controller]Visit " + controller.getName()); super.visit(declaration,controller); }
ControllerSourceVisitor extends VoidVisitorAdapter<ControllerModel> implements NameConstant { @Override public void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller) { controller.setName(declaration.getName()); LOGGER.info("[controller]Visit " + controller.getName()); super.visit(declaration,controller); } }
ControllerSourceVisitor extends VoidVisitorAdapter<ControllerModel> implements NameConstant { @Override public void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller) { controller.setName(declaration.getName()); LOGGER.info("[controller]Visit " + controller.getName()); super.visit(declaration,controller); }  }
ControllerSourceVisitor extends VoidVisitorAdapter<ControllerModel> implements NameConstant { @Override public void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller) { controller.setName(declaration.getName()); LOGGER.info("[controller]Visit " + controller.getName()); super.visit(declaration,controller); }  @Override void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller); @Override void visit(NormalAnnotationExpr anno, ControllerModel controller); @Override void visit(InitializerDeclaration n, ControllerModel arg); @Override void visit(FieldDeclaration n, ControllerModel arg); @Override void visit(FieldAccessExpr n, ControllerModel arg); @Override void visit(SingleMemberAnnotationExpr anno, ControllerModel controller); @Override void visit(JavadocComment jdoc, ControllerModel controller); @Override void visit(MethodDeclaration method, ControllerModel controller); }
ControllerSourceVisitor extends VoidVisitorAdapter<ControllerModel> implements NameConstant { @Override public void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller) { controller.setName(declaration.getName()); LOGGER.info("[controller]Visit " + controller.getName()); super.visit(declaration,controller); }  @Override void visit(ClassOrInterfaceDeclaration declaration, ControllerModel controller); @Override void visit(NormalAnnotationExpr anno, ControllerModel controller); @Override void visit(InitializerDeclaration n, ControllerModel arg); @Override void visit(FieldDeclaration n, ControllerModel arg); @Override void visit(FieldAccessExpr n, ControllerModel arg); @Override void visit(SingleMemberAnnotationExpr anno, ControllerModel controller); @Override void visit(JavadocComment jdoc, ControllerModel controller); @Override void visit(MethodDeclaration method, ControllerModel controller);  }