InterfaceGenerator { public void generateMethods(Classifier clazz, AST ast, TypeDeclaration td) { EList<Operation> operations = clazz.getOperations(); for (Operation operation : operations) { logger.log(Level.FINE, "Operation: " + operation.getName()); MethodDeclaration md = ast.newMethodDeclaration(); md.setName(ast.newSimpleName(operation.getName())); generateMethodParams(ast, td, operation, md); generateMethodReturnType(ast, td, operation, md); generateMethodThrowException(ast, operation, md); generateMethodJavadoc(ast, operation, md); generateMethodTemplateParams(ast, operation, md); } }  CompilationUnit generateInterface(Classifier clazz,
			String sourceDirectoryPackageName); @SuppressWarnings("unchecked") void generatePackageJavadoc(AST ast,
			PackageDeclaration packageDeclaration, String... comment); void generateGettersSetters(Classifier clazz, AST ast,
			TypeDeclaration td); MethodDeclaration generateGetterMethod(AST ast,
			AbstractTypeDeclaration td, Property property, String umlTypeName,
			String umlQualifiedTypeName); MethodDeclaration generateGetterMethod(AST ast,
			AbstractTypeDeclaration td, Property property, String umlTypeName,
			String umlQualifiedTypeName, String sourceDirectoryPackageName); @SuppressWarnings("unchecked") void generateSetterMethod(AST ast, AbstractTypeDeclaration td,
			Property property, String umlTypeName, String umlQualifiedTypeName); void generateAssociationEndUpperCardinalityMultiples(AST ast,
			AbstractTypeDeclaration td, Property property,
			MethodDeclaration mdGetter, String umlTypeName,
			String umlQualifiedTypeName); void generateAssociationEndUpperCardinalityMultiples(AST ast,
			AbstractTypeDeclaration td, Operation operation,
			MethodDeclaration mdGetter, String umlTypeName,
			String umlQualifiedTypeName); void generateAssociationEndUpperCardinalityMultiples(AST ast,
			AbstractTypeDeclaration td, Parameter parameter,
			MethodDeclaration md, String umlTypeName,
			String umlQualifiedTypeName, String umlPropertyName); void generateGetterSetterJavadoc(AST ast, Property property,
			MethodDeclaration methodDeclaration); @SuppressWarnings("unchecked") TypeDeclaration generateClass(Classifier clazz, AST ast,
			CompilationUnit cu); void generateClassJavadoc(Classifier clazz, AST ast,
			AbstractTypeDeclaration td); @SuppressWarnings("unchecked") void generateClassTemplateParams(Classifier clazz, AST ast,
			TypeDeclaration td); void generatePackage(Classifier clazz, AST ast, CompilationUnit cu); void generateMethods(Classifier clazz, AST ast, TypeDeclaration td); @SuppressWarnings("unchecked") void generateMethodTemplateParams(AST ast, Operation operation,
			MethodDeclaration md); void generateMethodJavadoc(AST ast, Operation operation,
			MethodDeclaration md); void generateMethodParams(AST ast, TypeDeclaration td,
			Operation operation, MethodDeclaration md);  }
@SuppressWarnings("unchecked") @Test public void testGenerateMethods() { AST ast = AST.newAST(AST.JLS3); ast.newCompilationUnit(); TypeDeclaration td = ast.newTypeDeclaration(); td.setInterface(true); Modifier modifier = ast .newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD); td.modifiers().add(modifier); td.setName(ast.newSimpleName("Company")); EList<Operation> operations = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); Operation operation = mock(Operation.class, Answers.RETURNS_DEEP_STUBS.get()); Type operationType = mock(Type.class, Answers.RETURNS_DEEP_STUBS.get()); Iterator<Operation> iteratorOperation = mock(Iterator.class); EList<Type> raisedExceptions = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); Iterator<Type> iteratorException = mock(Iterator.class); Type exceptionType = mock(Type.class, Answers.RETURNS_DEEP_STUBS.get()); when(clazz.getOperations()).thenReturn(operations); when(operations.iterator()).thenReturn(iteratorOperation); when(iteratorOperation.hasNext()).thenReturn(true, false); when(iteratorOperation.next()).thenReturn(operation); when(operation.getName()).thenReturn("calculateMe"); when(operation.getType()).thenReturn(operationType); when(operation.getRaisedExceptions()).thenReturn(raisedExceptions); when(raisedExceptions.iterator()).thenReturn(iteratorException); when(iteratorException.hasNext()).thenReturn(true, false); when(iteratorException.next()).thenReturn(exceptionType); when(exceptionType.getQualifiedName()).thenReturn( "de::test::CalculatorException"); when(operationType.getQualifiedName()).thenReturn( "de::test::Calculator"); when(operationType.getName()).thenReturn("Calculator"); interfaceGenerator.generateMethods(clazz, ast, td); assertEquals( "public interface Company {\n de.test.Calculator calculateMe() throws de.test.CalculatorException ;\n}\n", td.toString()); }