@Test public void testFieldAnnotationStringGeneration() { Annotation label = new AnnotationImpl( annotationDefinitions.get( org.kie.api.definition.type.Label.class.getName() ) ); label.setValue( "value", "Attribute 1" ); Annotation desc = new AnnotationImpl( annotationDefinitions.get( org.kie.api.definition.type.Description.class.getName() ) ); desc.setValue( "value", "Description for Attribute 1" ); Annotation key = new AnnotationImpl( annotationDefinitions.get( org.kie.api.definition.type.Key.class.getName() ) ); Annotation position = new AnnotationImpl( annotationDefinitions.get( org.kie.api.definition.type.Position.class.getName() ) ); position.setValue("value", "0"); GenerationContext generationContext = new GenerationContext( dataModelOracleDriver.createModel() ); try { String result = engine.generateAnnotationString(generationContext, label); assertEquals( results.getProperty( "testFieldAnnotationStringGeneration1" ), result ); result = engine.generateAnnotationString(generationContext, desc); assertEquals( results.getProperty( "testFieldAnnotationStringGeneration2" ), result ); result = engine.generateAnnotationString(generationContext, key); assertEquals( results.getProperty( "testFieldAnnotationStringGeneration3" ), result ); result = engine.generateAnnotationString(generationContext, position); assertEquals( results.getProperty( "testFieldAnnotationStringGeneration4" ), result ); } catch ( Exception e ) { e.printStackTrace(); } }
public String generateAnnotationString(GenerationContext generationContext, Annotation annotation) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("annotation", annotation); return generateSubTemplateString(generationContext, "java_annotation"); }
GenerationEngine { public String generateAnnotationString(GenerationContext generationContext, Annotation annotation) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("annotation", annotation); return generateSubTemplateString(generationContext, "java_annotation"); } }
GenerationEngine { public String generateAnnotationString(GenerationContext generationContext, Annotation annotation) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("annotation", annotation); return generateSubTemplateString(generationContext, "java_annotation"); }  }
GenerationEngine { public String generateAnnotationString(GenerationContext generationContext, Annotation annotation) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("annotation", annotation); return generateSubTemplateString(generationContext, "java_annotation"); }  static GenerationEngine getInstance(); void generate(GenerationContext generationContext); void generateAsset(GenerationContext generationContext, String template, String filePath); void generateConstructors(GenerationContext generationContext, String template); void generateAttribute(GenerationContext generationContext, ObjectProperty attribute, String template); void generateMethod( GenerationContext generationContext, Method method, String template); void generateNestedClass( GenerationContext generationContext, JavaClass nestedClass, String template); void generateSetterGetter(GenerationContext generationContext, ObjectProperty attribute, String template); void generateEquals(GenerationContext generationContext, String template); void generateHashCode(GenerationContext generationContext, String template); void generateTypeAnnotation(GenerationContext generationContext, Annotation annotation, String template); void generateFieldAnnotation(GenerationContext generationContext, Annotation annotation, String template); void generateSubTemplate(GenerationContext generationContext, String template); String generateDefaultConstructorString(GenerationContext generationContext, DataObject dataObject); String generateAllFieldsConstructorString(GenerationContext generationContext, DataObject dataObject); String generateKeyFieldsConstructorString(GenerationContext generationContext, DataObject dataObject); String generatePositionFieldsConstructorString(GenerationContext generationContext, DataObject dataObject); String generateAnnotationString(GenerationContext generationContext, Annotation annotation); String generateMethodString(GenerationContext generationContext, Method method, String indent); String generateMethodString(GenerationContext generationContext, Method method); String generateNestedClassString(GenerationContext generationContext, JavaClass javaClass, String indent); String generateNestedClassString(GenerationContext generationContext, JavaClass javaClass); String generateFieldString(GenerationContext generationContext, ObjectProperty attribute); String generateFieldGetterString(GenerationContext generationContext, ObjectProperty attribute); String generateFieldSetterString(GenerationContext generationContext, ObjectProperty attribute); String generateEqualsString(GenerationContext generationContext, DataObject dataObject, String indent); String generateEqualsString(GenerationContext generationContext, DataObject dataObject); String generateHashCodeString(GenerationContext generationContext, DataObject dataObject, String indent); String generateHashCodeString(GenerationContext generationContext, DataObject dataObject); String generateAllConstructorsString(GenerationContext generationContext, DataObject dataObject); String generateAllConstructorsString(GenerationContext generationContext, DataObject dataObject, String indent); String generateAllAnnotationsString(GenerationContext generationContext, HasAnnotations hasAnnotations); String generateAllAnnotationsString(GenerationContext generationContext, HasAnnotations hasAnnotations, String indent); String generateCompleteFieldString(GenerationContext generationContext, ObjectProperty attribute); String generateCompleteFieldString(GenerationContext generationContext, ObjectProperty attribute, String indent); String generateFieldGetterSetterString(GenerationContext generationContext, ObjectProperty attribute); String generateFieldGetterSetterString(GenerationContext generationContext, ObjectProperty attribute, String indent); String generateJavaClassString(GenerationContext generationContext, DataObject dataObject); String generateSubTemplateString(GenerationContext generationContext, String template); static String indentLines(String source, String indent); }
GenerationEngine { public String generateAnnotationString(GenerationContext generationContext, Annotation annotation) throws Exception { VelocityContext vc = buildContext(generationContext); vc.put("annotation", annotation); return generateSubTemplateString(generationContext, "java_annotation"); }  static GenerationEngine getInstance(); void generate(GenerationContext generationContext); void generateAsset(GenerationContext generationContext, String template, String filePath); void generateConstructors(GenerationContext generationContext, String template); void generateAttribute(GenerationContext generationContext, ObjectProperty attribute, String template); void generateMethod( GenerationContext generationContext, Method method, String template); void generateNestedClass( GenerationContext generationContext, JavaClass nestedClass, String template); void generateSetterGetter(GenerationContext generationContext, ObjectProperty attribute, String template); void generateEquals(GenerationContext generationContext, String template); void generateHashCode(GenerationContext generationContext, String template); void generateTypeAnnotation(GenerationContext generationContext, Annotation annotation, String template); void generateFieldAnnotation(GenerationContext generationContext, Annotation annotation, String template); void generateSubTemplate(GenerationContext generationContext, String template); String generateDefaultConstructorString(GenerationContext generationContext, DataObject dataObject); String generateAllFieldsConstructorString(GenerationContext generationContext, DataObject dataObject); String generateKeyFieldsConstructorString(GenerationContext generationContext, DataObject dataObject); String generatePositionFieldsConstructorString(GenerationContext generationContext, DataObject dataObject); String generateAnnotationString(GenerationContext generationContext, Annotation annotation); String generateMethodString(GenerationContext generationContext, Method method, String indent); String generateMethodString(GenerationContext generationContext, Method method); String generateNestedClassString(GenerationContext generationContext, JavaClass javaClass, String indent); String generateNestedClassString(GenerationContext generationContext, JavaClass javaClass); String generateFieldString(GenerationContext generationContext, ObjectProperty attribute); String generateFieldGetterString(GenerationContext generationContext, ObjectProperty attribute); String generateFieldSetterString(GenerationContext generationContext, ObjectProperty attribute); String generateEqualsString(GenerationContext generationContext, DataObject dataObject, String indent); String generateEqualsString(GenerationContext generationContext, DataObject dataObject); String generateHashCodeString(GenerationContext generationContext, DataObject dataObject, String indent); String generateHashCodeString(GenerationContext generationContext, DataObject dataObject); String generateAllConstructorsString(GenerationContext generationContext, DataObject dataObject); String generateAllConstructorsString(GenerationContext generationContext, DataObject dataObject, String indent); String generateAllAnnotationsString(GenerationContext generationContext, HasAnnotations hasAnnotations); String generateAllAnnotationsString(GenerationContext generationContext, HasAnnotations hasAnnotations, String indent); String generateCompleteFieldString(GenerationContext generationContext, ObjectProperty attribute); String generateCompleteFieldString(GenerationContext generationContext, ObjectProperty attribute, String indent); String generateFieldGetterSetterString(GenerationContext generationContext, ObjectProperty attribute); String generateFieldGetterSetterString(GenerationContext generationContext, ObjectProperty attribute, String indent); String generateJavaClassString(GenerationContext generationContext, DataObject dataObject); String generateSubTemplateString(GenerationContext generationContext, String template); static String indentLines(String source, String indent);  }