EnumGenerator { public FieldDeclaration generateAttribute(Classifier clazz, AST ast, Property property) { Type type = property.getType(); logger.log(Level.FINE, "Class: " + clazz.getName() + " - " + "Property: " + property.getName() + " - " + "Property Upper: " + property.getUpper() + " - " + "Property Lower: " + property.getLower()); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); org.eclipse.jdt.core.dom.Type chosenType = jdtHelper.getChosenType(ast, umlTypeName, umlQualifiedTypeName, sourceDirectoryPackageName); VariableDeclarationFragment fragment = ast .newVariableDeclarationFragment(); SimpleName variableName = ast.newSimpleName(property.getName()); fragment.setName(variableName); FieldDeclaration fieldDeclaration = ast.newFieldDeclaration(fragment); fieldDeclaration.setType(chosenType); EList<Comment> comments = property.getOwnedComments(); for (Comment comment : comments) { Javadoc javadoc = ast.newJavadoc(); generateJavadoc(ast, comment, javadoc); fieldDeclaration.setJavadoc(javadoc); } return fieldDeclaration; }  void setConstructorParameterNames(
			ArrayList<String> constructorParameterNames); CompilationUnit generateEnum(Classifier clazz,
			String sourceDirectoryPackageName); @SuppressWarnings("unchecked") void generateAttributes(Classifier clazz, AST ast, EnumDeclaration ed); FieldDeclaration generateAttribute(Classifier clazz, AST ast,
			Property property); @SuppressWarnings("unchecked") void generateGetterMethod(Classifier clazz, AST ast,
			EnumDeclaration ed); void generateGetterMethod(Classifier clazz, AST ast,
			EnumDeclaration ed, String sourceDirectoryPackageName); @SuppressWarnings("unchecked") void generateConstructor(Classifier clazz, AST ast,
			EnumDeclaration ed); @SuppressWarnings("unchecked") EnumDeclaration generateEnum(Classifier clazz, AST ast,
			CompilationUnit cu); void generateClassJavadoc(Element clazz, AST ast, BodyDeclaration td); void generatePackage(Classifier clazz, AST ast, CompilationUnit cu); @SuppressWarnings("unchecked") void generateConstants(Classifier clazz, AST ast, EnumDeclaration ed);  }
@SuppressWarnings("unchecked") @Test public void testGenerateAttribute() { AST ast = AST.newAST(AST.JLS3); CompilationUnit cu = ast.newCompilationUnit(); EnumDeclaration ed = enumGenerator.generateEnum(clazz, ast, cu); EList<Property> properties = mock(EList.class); Iterator<Property> propertyIter = mock(Iterator.class); Property property = mock(Property.class); Type type = mock(Type.class); String name = "type"; EList<Comment> comments = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); when(clazz.getAttributes()).thenReturn(properties); when(properties.iterator()).thenReturn(propertyIter); when(propertyIter.hasNext()).thenReturn(true).thenReturn(false); when(propertyIter.next()).thenReturn(property); when(property.getType()).thenReturn(type); when(property.getName()).thenReturn(name); when(property.getUpper()).thenReturn(1); when(property.getLower()).thenReturn(1); when(property.getOwnedComments()).thenReturn(comments); when(type.getName()).thenReturn("String"); when(type.getQualifiedName()).thenReturn("String"); enumGenerator.generateAttributes(clazz, ast, ed); assertEquals("public enum Company {; String type;\n}\n", cu.toString()); }