EnumGenerator { @SuppressWarnings("unchecked") void generateContructorParameters(Classifier clazz, AST ast, MethodDeclaration md) { constructorParameterNames.clear(); EList<Property> constructorProperties = clazz.getAttributes(); for (Property constructorProperty : constructorProperties) { Type constructorType = constructorProperty.getType(); constructorParameterNames.add(constructorProperty.getName()); logger.log( Level.FINE, "Class: " + clazz.getName() + " - " + "Constructor property: " + constructorProperty.getName() + " - " + "Constructor property Upper: " + constructorProperty.getUpper() + " - " + "Constructor property Lower: " + constructorProperty.getLower()); String contructorUmlTypeName = constructorType.getName(); String constructorUmlQualifiedTypeName = constructorType .getQualifiedName(); org.eclipse.jdt.core.dom.Type constructorChosenType = jdtHelper .getChosenType(ast, contructorUmlTypeName, constructorUmlQualifiedTypeName, sourceDirectoryPackageName); SingleVariableDeclaration variableDeclaration = ast .newSingleVariableDeclaration(); variableDeclaration.setType(constructorChosenType); variableDeclaration.setName(ast.newSimpleName(constructorProperty .getName())); md.parameters().add(variableDeclaration); } }  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 testGenerateContructorParameters() { AST ast = AST.newAST(AST.JLS3); CompilationUnit cu = ast.newCompilationUnit(); EnumDeclaration ed = enumGenerator.generateEnum(clazz, ast, cu); MethodDeclaration md = ast.newMethodDeclaration(); md.setConstructor(true); md.setName(ast.newSimpleName(clazz.getName())); md.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PRIVATE_KEYWORD)); EList<Property> properties = mock(EList.class); Iterator<Property> propertyIter = mock(Iterator.class); Property propertyName = mock(Property.class); String name = "name"; Type typeName = mock(Type.class); Property propertyCount = mock(Property.class); String count = "count"; Type typeCount = mock(Type.class); 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(true) .thenReturn(false); when(propertyIter.next()).thenReturn(propertyName).thenReturn( propertyCount); when(propertyName.getType()).thenReturn(typeName); when(propertyName.getName()).thenReturn(name); when(propertyName.getUpper()).thenReturn(1); when(propertyName.getLower()).thenReturn(1); when(propertyName.getOwnedComments()).thenReturn(comments); when(typeName.getName()).thenReturn("String"); when(typeName.getQualifiedName()).thenReturn("String"); when(propertyCount.getType()).thenReturn(typeCount); when(propertyCount.getName()).thenReturn(count); when(propertyCount.getUpper()).thenReturn(1); when(propertyCount.getLower()).thenReturn(1); when(propertyCount.getOwnedComments()).thenReturn(comments); when(typeCount.getName()).thenReturn("Integer"); when(typeCount.getQualifiedName()).thenReturn("Integer"); enumGenerator.generateContructorParameters(clazz, ast, md); ed.bodyDeclarations().add(md); assertEquals( "public enum Company {; private Company(String name,Integer count);\n}\n", cu.toString()); }