/** UML2 3.0: property.validateUpperGt0 no longer exists * @param arg0 * @param arg1 * @return property.getUpper() > 0 */ public boolean validateUpperGt0( final DiagnosticChain arg0, final Map<Object, Object> arg1) { return this.property.getUpper() > 0; }
/** * @return this.property.getUpper() * @see org.eclipse.uml2.uml.Property#getUpper() */ public int upper() { return this.property.getUpper(); }
/** * @return this.property.getUpper() * @see org.eclipse.uml2.uml.Property#getUpper() */ public int upper() { return this.property.getUpper(); }
/** * @see org.eclipse.uml2.uml.MultiplicityElement#getUpper() */ public int getUpper() { return this.property.getUpper(); }
/** * @see org.eclipse.uml2.uml.MultiplicityElement#getUpper() */ public int getUpper() { return this.property.getUpper(); }
/** * @return this.property.getUpper() * @see org.eclipse.uml2.uml.Property#getUpper() */ public int upper() { return this.property.getUpper(); }
/** * @return this.property.getUpper() * @see org.eclipse.uml2.uml.Property#getUpper() */ public int upper() { return this.property.getUpper(); }
/** * @see org.eclipse.uml2.uml.MultiplicityElement#getUpper() */ public int getUpper() { return this.property.getUpper(); }
/** * @see org.eclipse.uml2.uml.MultiplicityElement#getUpper() */ public int getUpper() { return this.property.getUpper(); }
/** UML2 3.0: property.validateUpperGt0 no longer exists * @param arg0 * @param arg1 * @return property.getUpper() > 0 */ public boolean validateUpperGt0( final DiagnosticChain arg0, final Map<Object, Object> arg1) { return this.property.getUpper() > 0; }
/** UML2 3.0: property.validateUpperGt0 no longer exists * @param arg0 * @param arg1 * @return property.getUpper() > 0 */ public boolean validateUpperGt0( final DiagnosticChain arg0, final Map<Object, Object> arg1) { return this.property.getUpper() > 0; /* return this.property.validateUpperGt0( arg0, arg1); */ }
/** UML2 3.0: property.validateUpperGt0 no longer exists * @param arg0 * @param arg1 * @return property.getUpper() > 0 */ public boolean validateUpperGt0( final DiagnosticChain arg0, final Map<Object, Object> arg1) { return this.property.getUpper() > 0; /* return this.property.validateUpperGt0( arg0, arg1); */ }
@SuppressWarnings("unchecked") @Test public void testGenerateGetterMethodWithSourceDirectoryPackageNameWrong() { 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("Data::String"); when(type.getQualifiedName()).thenReturn("Data::String"); enumGenerator.generateGetterMethod(clazz, ast, ed); assertEquals( "public enum Company {; public Data.String getType(){\n return type;\n}\n}\n", cu.toString()); }
@SuppressWarnings("unchecked") @Test public void testGenerateGetterMethodWithSourceDirectoryPackageNameCorrect() { 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("Data::String"); when(type.getQualifiedName()).thenReturn("Data::String"); enumGenerator.generateGetterMethod(clazz, ast, ed, "Data"); assertEquals( "public enum Company {; public String getType(){\n return type;\n}\n}\n", cu.toString()); }
@SuppressWarnings("unchecked") @Test public void testGenerateGetterMethod() { 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.generateGetterMethod(clazz, ast, ed); assertEquals( "public enum Company {; public String getType(){\n return type;\n}\n}\n", cu.toString()); }
@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()); }
@SuppressWarnings("unchecked") @Test public void testGenerateGetterMethodUpperZero() { 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")); Property property = mock(Property.class); String umlQualifiedTypeName = "test.de.Company"; String umlTypeName = "Company"; EList<Comment> comments = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); when(property.getName()).thenReturn("name"); when(property.getUpper()).thenReturn(0); when(property.getOwnedComments()).thenReturn(comments); interfaceGenerator.generateGetterMethod(ast, td, property, umlTypeName, umlQualifiedTypeName); MethodDeclaration[] methods = td.getMethods(); for (MethodDeclaration method : methods) { assertEquals("getName", method.getName().toString()); assertEquals("test.de.Company", method.getReturnType2().toString()); } }
@SuppressWarnings("unchecked") @Test public void testGenerateGetterMethodTypeBoolean() { 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")); Property property = mock(Property.class); String umlQualifiedTypeName = "Boolean"; String umlTypeName = "Boolean"; EList<Comment> comments = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); when(property.getName()).thenReturn("name"); when(property.getUpper()).thenReturn(0); when(property.getOwnedComments()).thenReturn(comments); interfaceGenerator.generateGetterMethod(ast, td, property, umlTypeName, umlQualifiedTypeName); MethodDeclaration[] methods = td.getMethods(); for (MethodDeclaration method : methods) { assertEquals("isName", method.getName().toString()); assertEquals("Boolean", method.getReturnType2().toString()); } }
@SuppressWarnings("unchecked") @Test public void testGenerateGetterMethodTypeLowerCaseBoolean() { 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")); Property property = mock(Property.class); String umlQualifiedTypeName = "boolean"; String umlTypeName = "boolean"; EList<Comment> comments = mock(EList.class, Answers.RETURNS_DEEP_STUBS.get()); when(property.getName()).thenReturn("name"); when(property.getUpper()).thenReturn(0); when(property.getOwnedComments()).thenReturn(comments); interfaceGenerator.generateGetterMethod(ast, td, property, umlTypeName, umlQualifiedTypeName); MethodDeclaration[] methods = td.getMethods(); for (MethodDeclaration method : methods) { assertEquals("isName", method.getName().toString()); assertEquals("boolean", method.getReturnType2().toString()); } }
public static boolean isControllingSide(Property p) { boolean result = p.isComposite(); if (p.getOtherEnd() == null) { result = true; } else if (isOneToOne(p) && !p.isComposite() && !p.getOtherEnd().isComposite()) { // If association is OneToOne and both sides are non composite then // if there is a 1-1 and 0-1 then take the 1-1 side as inverse=true else compare alphabetically if ((p.getLower() == 0 && p.getOtherEnd().getLower() == 0) || (p.getLower() == 1 && p.getOtherEnd().getLower() == 1)) { result = p.getName().compareTo(p.getOtherEnd().getName()) > -1; } else { result = p.getLower() == 1 && p.getUpper() == 1; } } else if (isOneToMany(p) && !p.isComposite() && !p.getOtherEnd().isComposite()) { // If association is OneToMany and both sides are non composite then // take the many side as inverse=true //result = p.getUpper() == -1 || p.getUpper() > 1; result = true; } else if (isManyToMany(p) && !p.isComposite() && !p.getOtherEnd().isComposite()) { // If association is ManyToMany and both sides are non composite // then take any side consistently result = 0 > p.getName().compareTo(p.getOtherEnd().getName()); } return result; }