@SuppressWarnings("unchecked") @Test public void testGenerateMethodParamsWithOneParameter() { 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")); MethodDeclaration md = ast.newMethodDeclaration(); md.setName(ast.newSimpleName("calculateAge")); Operation operation = mock(Operation.class, Answers.RETURNS_DEEP_STUBS.get()); EList<Parameter> parameters = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); Iterator<Parameter> paramIterator = mock(Iterator.class); Parameter parameter = mock(Parameter.class, Answers.RETURNS_DEEP_STUBS.get()); Type type = mock(Type.class, Answers.RETURNS_DEEP_STUBS.get()); when(operation.getOwnedParameters()).thenReturn(parameters); when(parameters.iterator()).thenReturn(paramIterator); when(paramIterator.hasNext()).thenReturn(true, false); when(paramIterator.next()).thenReturn(parameter); when(parameter.getDirection()).thenReturn( ParameterDirectionKind.IN_LITERAL); when(parameter.getType()).thenReturn(type); when(parameter.getName()).thenReturn("person"); when(parameter.getUpper()).thenReturn(0); when(type.getName()).thenReturn("Person"); when(type.getQualifiedName()).thenReturn("de.component.Person"); interfaceGenerator.generateMethodParams(ast, td, operation, md); assertEquals("void calculateAge(de.component.Person person);\n", md.toString()); }
public void generateMethodParams(AST ast, TypeDeclaration td, Operation operation, MethodDeclaration md) { EList<Parameter> parameters = operation.getOwnedParameters(); for (Parameter parameter : parameters) { if (parameter.getDirection().getValue() != ParameterDirectionKind.RETURN) { Type type = parameter.getType(); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); String umlPropertyName = StringUtils.uncapitalize(parameter .getName()); logger.log(Level.FINE, "Parameter: " + parameter.getName() + " - " + "Type: " + umlTypeName); if (parameter.getUpper() >= 0) { if (dataTypeUtils.isParameterizedType(umlTypeName)) { Map<String, String> types = umlHelper .checkParameterizedTypeForTemplateParameterSubstitution(type); umlTypeName = types.get("umlTypeName"); umlQualifiedTypeName = types .get("umlQualifiedTypeName"); } jdtHelper.createParameterTypes(ast, td, md, umlTypeName, umlQualifiedTypeName, umlPropertyName, sourceDirectoryPackageName); } else { generateAssociationEndUpperCardinalityMultiples(ast, td, parameter, md, umlTypeName, umlQualifiedTypeName, umlPropertyName); } } } }
InterfaceGenerator { public void generateMethodParams(AST ast, TypeDeclaration td, Operation operation, MethodDeclaration md) { EList<Parameter> parameters = operation.getOwnedParameters(); for (Parameter parameter : parameters) { if (parameter.getDirection().getValue() != ParameterDirectionKind.RETURN) { Type type = parameter.getType(); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); String umlPropertyName = StringUtils.uncapitalize(parameter .getName()); logger.log(Level.FINE, "Parameter: " + parameter.getName() + " - " + "Type: " + umlTypeName); if (parameter.getUpper() >= 0) { if (dataTypeUtils.isParameterizedType(umlTypeName)) { Map<String, String> types = umlHelper .checkParameterizedTypeForTemplateParameterSubstitution(type); umlTypeName = types.get("umlTypeName"); umlQualifiedTypeName = types .get("umlQualifiedTypeName"); } jdtHelper.createParameterTypes(ast, td, md, umlTypeName, umlQualifiedTypeName, umlPropertyName, sourceDirectoryPackageName); } else { generateAssociationEndUpperCardinalityMultiples(ast, td, parameter, md, umlTypeName, umlQualifiedTypeName, umlPropertyName); } } } } }
InterfaceGenerator { public void generateMethodParams(AST ast, TypeDeclaration td, Operation operation, MethodDeclaration md) { EList<Parameter> parameters = operation.getOwnedParameters(); for (Parameter parameter : parameters) { if (parameter.getDirection().getValue() != ParameterDirectionKind.RETURN) { Type type = parameter.getType(); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); String umlPropertyName = StringUtils.uncapitalize(parameter .getName()); logger.log(Level.FINE, "Parameter: " + parameter.getName() + " - " + "Type: " + umlTypeName); if (parameter.getUpper() >= 0) { if (dataTypeUtils.isParameterizedType(umlTypeName)) { Map<String, String> types = umlHelper .checkParameterizedTypeForTemplateParameterSubstitution(type); umlTypeName = types.get("umlTypeName"); umlQualifiedTypeName = types .get("umlQualifiedTypeName"); } jdtHelper.createParameterTypes(ast, td, md, umlTypeName, umlQualifiedTypeName, umlPropertyName, sourceDirectoryPackageName); } else { generateAssociationEndUpperCardinalityMultiples(ast, td, parameter, md, umlTypeName, umlQualifiedTypeName, umlPropertyName); } } } }  }
InterfaceGenerator { public void generateMethodParams(AST ast, TypeDeclaration td, Operation operation, MethodDeclaration md) { EList<Parameter> parameters = operation.getOwnedParameters(); for (Parameter parameter : parameters) { if (parameter.getDirection().getValue() != ParameterDirectionKind.RETURN) { Type type = parameter.getType(); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); String umlPropertyName = StringUtils.uncapitalize(parameter .getName()); logger.log(Level.FINE, "Parameter: " + parameter.getName() + " - " + "Type: " + umlTypeName); if (parameter.getUpper() >= 0) { if (dataTypeUtils.isParameterizedType(umlTypeName)) { Map<String, String> types = umlHelper .checkParameterizedTypeForTemplateParameterSubstitution(type); umlTypeName = types.get("umlTypeName"); umlQualifiedTypeName = types .get("umlQualifiedTypeName"); } jdtHelper.createParameterTypes(ast, td, md, umlTypeName, umlQualifiedTypeName, umlPropertyName, sourceDirectoryPackageName); } else { generateAssociationEndUpperCardinalityMultiples(ast, td, parameter, md, umlTypeName, umlQualifiedTypeName, umlPropertyName); } } } }  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); }
InterfaceGenerator { public void generateMethodParams(AST ast, TypeDeclaration td, Operation operation, MethodDeclaration md) { EList<Parameter> parameters = operation.getOwnedParameters(); for (Parameter parameter : parameters) { if (parameter.getDirection().getValue() != ParameterDirectionKind.RETURN) { Type type = parameter.getType(); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); String umlPropertyName = StringUtils.uncapitalize(parameter .getName()); logger.log(Level.FINE, "Parameter: " + parameter.getName() + " - " + "Type: " + umlTypeName); if (parameter.getUpper() >= 0) { if (dataTypeUtils.isParameterizedType(umlTypeName)) { Map<String, String> types = umlHelper .checkParameterizedTypeForTemplateParameterSubstitution(type); umlTypeName = types.get("umlTypeName"); umlQualifiedTypeName = types .get("umlQualifiedTypeName"); } jdtHelper.createParameterTypes(ast, td, md, umlTypeName, umlQualifiedTypeName, umlPropertyName, sourceDirectoryPackageName); } else { generateAssociationEndUpperCardinalityMultiples(ast, td, parameter, md, umlTypeName, umlQualifiedTypeName, umlPropertyName); } } } }  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);  }