Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org')
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/AllTests.java14
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/DOMTestPlugin.java10
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/FileBasedDOMTest.java8
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/TypeDeclarationFinder.java30
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/AllTests.java8
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java62
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java46
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java16
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AnchoredTypeTest.java36
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java92
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest2.java32
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java58
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CallinMappingDeclarationTest.java46
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CalloutMappingDeclarationTest.java218
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java36
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/FieldAccessSpecTest.java100
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/GuardPredicateTest.java38
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/LiftingTypeTest.java62
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/MethodSpecTest.java102
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCallinTest.java60
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCalloutTest.java94
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/PrecedenceDeclarationTest.java32
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/RoleTypeDeclarationTest.java116
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperConstructorInvocationTest.java64
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperMessageSendTest.java74
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/WithinStatementTest.java72
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewriteFlattenerTest.java336
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCallinMappingDeclarationTest.java289
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCalloutMappingDeclarationTest.java225
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingRoleTest.java247
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTeamTest.java211
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTest.java16
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/AllTests.java8
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/AstRewritingDescribingTest.java26
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/CallinMappingDeclarationTest.java28
-rw-r--r--testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java60
36 files changed, 1484 insertions, 1488 deletions
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/AllTests.java
index 619e617de..5ed8ccc5c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/AllTests.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -37,13 +37,13 @@ public class AllTests {
//$JUnit-BEGIN$
// DOM bindings tests
suite.addTest(org.eclipse.objectteams.otdt.ui.tests.dom.bindings.AllTests.suite());
-
+
// DOM converter tests
suite.addTest(org.eclipse.objectteams.otdt.ui.tests.dom.converter.AllTests.suite());
-
+
// DOM rewrite tests
suite.addTest(org.eclipse.objectteams.otdt.ui.tests.dom.rewrite.AllTests.suite());
-
+
//$JUnit-END$
return suite;
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/DOMTestPlugin.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/DOMTestPlugin.java
index 6c65e0493..98878179d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/DOMTestPlugin.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/DOMTestPlugin.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -35,7 +35,7 @@ public class DOMTestPlugin extends Plugin {
private static DOMTestPlugin plugin;
//Resource bundle.
private ResourceBundle resourceBundle;
-
+
/**
* The constructor.
*/
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/FileBasedDOMTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/FileBasedDOMTest.java
index 27f9d9b1c..e7bb6d53d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/FileBasedDOMTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/FileBasedDOMTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/TypeDeclarationFinder.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/TypeDeclarationFinder.java
index 84d3bf5ec..eecef55e3 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/TypeDeclarationFinder.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/TypeDeclarationFinder.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -35,52 +35,52 @@ public class TypeDeclarationFinder extends ASTVisitor
private TypeDeclaration _typeDecl;
private String[] _path;
private int _pathIdx;
-
+
public TypeDeclarationFinder()
{
_typeDecl = null;
_path = null;
_pathIdx = 0;
}
-
+
private boolean checkTypeDeclaration(TypeDeclaration node)
{
if ( (_path == null) || (_pathIdx >= _path.length))
{
return false;
}
-
+
if (!node.getName().getIdentifier().equals(_path[_pathIdx]))
{
return false; // wrong path
}
-
+
_pathIdx++;
if (_pathIdx == _path.length)
{
_typeDecl = node;
return false;
}
-
+
return true;
}
-
-
- public boolean visit(RoleTypeDeclaration node)
+
+
+ public boolean visit(RoleTypeDeclaration node)
{
return checkTypeDeclaration(node);
}
-
+
public boolean visit(TypeDeclaration node)
{
return checkTypeDeclaration(node);
}
-
+
public TypeDeclaration getTypeDeclaration()
{
return _typeDecl;
}
-
+
public void setName(String name)
{
if (name != null)
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/AllTests.java
index 2426f0873..bb20f6117 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/AllTests.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java
index 12fb7fca6..1e5aadd5b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/MethodMappingBindingTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -63,24 +63,24 @@ public class MethodMappingBindingTest extends FileBasedDOMTest
private CalloutMappingDeclaration[] _callouts;
private MethodDeclaration[] _methods;
private IMethodMappingBinding _testObj;
-
+
public MethodMappingBindingTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(MethodMappingBindingTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_team = getCompilationUnit(
@@ -88,12 +88,12 @@ public class MethodMappingBindingTest extends FileBasedDOMTest
"src",
"bindings.teampkg",
"T1.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_team);
_parser.setResolveBindings(true);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit)root;
_teamDecl = (TypeDeclaration)compUnit.types().get(0);
@@ -113,43 +113,43 @@ public class MethodMappingBindingTest extends FileBasedDOMTest
public void testGetName_NoSignature()
{
_testObj = _callouts[0].resolveBinding();
-
+
String actual = _testObj.getName();
String expected = "void m1() -> void m1() ;";
-
+
assertEquals(expected, actual);
}
public void testGetName_WithSignature()
{
_testObj = _callouts[1].resolveBinding();
-
+
String actual = _testObj.getName();
- String expected = "java.lang.String m2(java.lang.Integer) -> java.lang.String m2(java.lang.Integer) ;";
-
+ String expected = "java.lang.String m2(java.lang.Integer) -> java.lang.String m2(java.lang.Integer) ;";
+
assertEquals(expected, actual);
}
-
+
public void testGetDeclaringClass()
{
_testObj = _callouts[0].resolveBinding();
-
+
ITypeBinding actual = _testObj.getDeclaringRoleClass();
ITypeBinding expected = _roleDecl.resolveBinding();
-
+
assertEquals(expected, actual);
}
public void testGetRoleMethod()
{
_testObj = _callins[0].resolveBinding();
-
+
MethodDeclaration roleMethod =
(MethodDeclaration)_methods[1];
-
+
IMethodBinding actual = _testObj.getRoleMethod();
IMethodBinding expected = roleMethod.resolveBinding();
-
+
assertEquals(expected, actual);
}
@@ -160,36 +160,36 @@ public class MethodMappingBindingTest extends FileBasedDOMTest
// check we have the same method:
MethodDeclaration roleMethod = (MethodDeclaration)_methods[1];
assertEquals(roleMethod.resolveBinding(), ((MethodSpec)roleMappingElement).resolveBinding());
-
+
// check the return types:
ITypeBinding actual = roleMappingElement.getName().resolveTypeBinding();
ITypeBinding expected = roleMethod.resolveBinding().getReturnType();
-
+
assertEquals(expected, actual);
}
-
+
public void testGetReferencedBaseClass()
{
_testObj = _callins[0].resolveBinding();
ITypeBinding actual = _testObj.getReferencedBaseClass();
ITypeBinding expected = _roleDecl.resolveBinding().getBaseClass();
-
+
assertNotNull(actual);
assertEquals(expected, actual);
}
-
+
public void testGetModifiers_After()
{
_testObj = _callins[0].resolveBinding();
int modifier = _testObj.getModifiers();
-
+
boolean isCallinReplace = Modifier.isAfter(modifier)
&& _testObj.isCallin();
-
+
assertTrue(isCallinReplace);
}
-
+
/** Resolve a qualified callin name in a precedence declaration. */
public void testPrecedence1() {
PrecedenceDeclaration prec = (PrecedenceDeclaration) _teamDecl.precedences().get(0);
@@ -199,7 +199,7 @@ public class MethodMappingBindingTest extends FileBasedDOMTest
assertTrue("Is mapping binding", binding instanceof IMethodMappingBinding);
assertEquals("Has expected representation", "ci1: java.lang.Integer m5(java.lang.Integer) <- after java.lang.Integer m5(java.lang.Integer) ;", binding.toString());
}
-
+
/** Try to resolve an unqualified callin name in a precedence declaration -> fails to resolve but shouldn't CCE. */
public void testPrecedence2() {
PrecedenceDeclaration prec = (PrecedenceDeclaration) _teamDecl.precedences().get(0);
@@ -209,7 +209,7 @@ public class MethodMappingBindingTest extends FileBasedDOMTest
assertTrue("Is mapping binding", binding instanceof IMethodMappingBinding);
assertEquals("Has expected representation", "missingCallin:ci2: NULL ROLE METHODS<- <unknown> ;", binding.toString());
}
-
+
/** Resolve an unqualified callin name in a precedence declaration */
public void testPrecedence3() {
RoleTypeDeclaration role2Decl = (RoleTypeDeclaration)_teamDecl.getRoles()[1];
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java
index 5c840b1db..7801c571b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/bindings/TypeBindingTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -50,7 +50,7 @@ public class TypeBindingTest extends FileBasedDOMTest
{
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
-
+
private ASTParser _parser;
private ICompilationUnit _cuTA;
private ICompilationUnit _cuTB;
@@ -59,28 +59,28 @@ public class TypeBindingTest extends FileBasedDOMTest
private RoleTypeDeclaration _roleTAT2R1;
private RoleTypeDeclaration _roleTBT1R1;
private RoleTypeDeclaration _roleTBT2R1;
-
+
private TypeDeclaration _teamMyTeam;
private RoleTypeDeclaration _focus;
-
- public TypeBindingTest(String name)
+
+ public TypeBindingTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(TypeBindingTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
-
- protected void setUp() throws Exception
+
+ protected void setUp() throws Exception
{
super.setUp();
_cuTA = getCompilationUnit(
@@ -98,12 +98,12 @@ public class TypeBindingTest extends FileBasedDOMTest
"src",
"roleTypeDeclaration.teampkg",
"MyTeam.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject(super.getJavaProject(TEST_PROJECT));
_parser.setResolveBindings(true);
_parser.setSource(_cuTA);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
TypeDeclarationFinder finder = new TypeDeclarationFinder();
@@ -114,7 +114,7 @@ public class TypeBindingTest extends FileBasedDOMTest
_parser.setSource(_cuTB);
_parser.setResolveBindings(true);
-
+
root = _parser.createAST( new NullProgressMonitor() );
compUnit = (CompilationUnit) root;
@@ -124,11 +124,11 @@ public class TypeBindingTest extends FileBasedDOMTest
finder.setName("TB.T2.R1");
compUnit.accept(finder);
- _roleTBT2R1 = (RoleTypeDeclaration)finder.getTypeDeclaration();
+ _roleTBT2R1 = (RoleTypeDeclaration)finder.getTypeDeclaration();
_parser.setSource(_cuMyT);
_parser.setResolveBindings(true);
-
+
root = _parser.createAST( new NullProgressMonitor() );
compUnit = (CompilationUnit) root;
@@ -136,7 +136,7 @@ public class TypeBindingTest extends FileBasedDOMTest
compUnit.accept(finder);
_teamMyTeam = finder.getTypeDeclaration();
}
-
+
public void testInstanceTypes()
{
assertNotNull(_roleTAT2R1);
@@ -146,12 +146,12 @@ public class TypeBindingTest extends FileBasedDOMTest
assertTrue(_roleTBT1R1 instanceof RoleTypeDeclaration);
assertTrue(_roleTBT2R1 instanceof RoleTypeDeclaration);
}
-
+
public void testGetSuperRoles()
{
_focus = _roleTBT2R1;
ITypeBinding binding = (ITypeBinding)_focus.resolveBinding();
-
+
ITypeBinding[] expected = new ITypeBinding[]
{
_roleTBT1R1.resolveBinding(),
@@ -164,7 +164,7 @@ public class TypeBindingTest extends FileBasedDOMTest
assertEquals(expected[0].getOptimalName(), actual[0].getOptimalName());
assertEquals(expected[1].getOptimalName(), actual[1].getOptimalName());
}
-
+
public void testDeclaredLiftingType() {
MethodDeclaration method = (MethodDeclaration) _teamMyTeam.bodyDeclarations().get(3);
SingleVariableDeclaration arg1 = (SingleVariableDeclaration) method.parameters().get(0);
@@ -185,10 +185,10 @@ public class TypeBindingTest extends FileBasedDOMTest
parser.setSource(("public class C {\n" +
"public bug352605.Sub f;\n" +
"}\n").toCharArray());
-
+
ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
-
+
TypeDeclaration type = (TypeDeclaration) compUnit.types().get(0);
FieldDeclaration field = (FieldDeclaration) type.bodyDeclarations().get(0);
Type fieldType = field.getType();
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java
index e514580bb..31e27a031 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AllTests.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -32,14 +32,14 @@ import org.eclipse.objectteams.otdt.tests.AbstractJavaModelTests;
/**
* Enter a class description here!
- *
+ *
* @author jwloka
* @version $Id: AllTests.java 23496 2010-02-05 23:20:15Z stephan $
*/
public class AllTests extends TestCase
{
- public AllTests(String name)
+ public AllTests(String name)
{
super(name);
}
@@ -52,7 +52,7 @@ public class AllTests extends TestCase
BaseCallMessageSendTest2.class,
BaseConstructorInvocationTest.class,
CallinMappingDeclarationTest.class,
- CalloutMappingDeclarationTest.class,
+ CalloutMappingDeclarationTest.class,
FieldAccessSpecTest.class,
GuardPredicateTest.class,
LiftingTypeTest.class,
@@ -64,7 +64,7 @@ public class AllTests extends TestCase
TSuperConstructorInvocationTest.class,
TSuperMessageSendTest.class,
WithinStatementTest.class,
-
+
DOMRegressionTests.class
};
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AnchoredTypeTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AnchoredTypeTest.java
index 0f3ff7804..281157a4d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AnchoredTypeTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/AnchoredTypeTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -51,33 +51,33 @@ public class AnchoredTypeTest extends FileBasedDOMTest
private ASTParser _parser;
private ICompilationUnit _simpleTeam;
-
+
private TypeDeclaration _typeDecl; // a java class common to all within tests
- private MethodDeclaration _methodDecl;
+ private MethodDeclaration _methodDecl;
private SingleVariableDeclaration _argumentDecl;
private VariableDeclarationStatement _localDecls;
private VariableDeclarationFragment _localDecl;
-
-
+
+
private Type _testObj;
-
+
public AnchoredTypeTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(AnchoredTypeTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -85,15 +85,15 @@ public class AnchoredTypeTest extends FileBasedDOMTest
"src",
"anchoredType.teampkg",
"Team1.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
- _methodDecl = (MethodDeclaration)_typeDecl.bodyDeclarations().get(0);
+ _methodDecl = (MethodDeclaration)_typeDecl.bodyDeclarations().get(0);
_argumentDecl = (SingleVariableDeclaration)_methodDecl.parameters().get(1);
_localDecls = (VariableDeclarationStatement)_methodDecl.getBody().statements().get(0);
_localDecl = (VariableDeclarationFragment)_localDecls.fragments().get(0);
@@ -104,17 +104,17 @@ public class AnchoredTypeTest extends FileBasedDOMTest
{
_testObj = _argumentDecl.getType();
String sig = Util.getSignature(_testObj);
-
+
assertEquals("Argument type has wrong name ",
"QMyRole<@team1>;",
sig);
}
-
+
public void testAllocation()
{
ClassInstanceCreation creation = (ClassInstanceCreation) _localDecl.getInitializer();
String sig = Util.getSignature(creation.getType());
-
+
assertEquals("Argument type has wrong name ",
"QMyRole<@team1>;",
sig);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java
index e0976e523..5d03ea98c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -56,7 +56,7 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
*/
public class BaseCallMessageSendTest extends FileBasedDOMTest
{
-
+
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS10;
@@ -69,12 +69,12 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(BaseCallMessageSendTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -88,19 +88,19 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
parser.setProject(getJavaProject(TEST_PROJECT));
parser.setSource(teamClass);
parser.setResolveBindings(true);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
_role = _typeDecl.getTypes()[0];
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
-
+
public void testInstanceType1()
{
MethodDeclaration method = _role.getMethods()[0];
@@ -108,7 +108,7 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
(ExpressionStatement)method.getBody().statements().get(0);
Expression testObj = exprStatement.getExpression();
-
+
assertTrue("Base call not an instance of BaseCallMessageSend",
testObj instanceof BaseCallMessageSend);
}
@@ -122,27 +122,27 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
(VariableDeclarationFragment)varDecl.fragments().get(0);
Expression testObj = varDeclFrag.getInitializer();
-
+
assertTrue("Base call not an instance of BaseCallMessageSend",
testObj instanceof BaseCallMessageSend);
}
-
-
+
+
public void testGetNodeType1()
{
MethodDeclaration method = _role.getMethods()[0];
ExpressionStatement exprStatement =
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
int actual = _testObj.getNodeType();
-
+
assertEquals("Base Call has wrong node type",
ASTNode.BASE_CALL_MESSAGE_SEND,
actual);
}
-
+
public void testGetName1()
{
MethodDeclaration method = _role.getMethods()[0];
@@ -151,21 +151,21 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
String actual = _testObj.getName().getIdentifier();
-
+
assertEquals("Base call has wrong name ",
"roleMethod0",
actual);
}
-
+
public void testGetArguments_2Args()
{
MethodDeclaration method = _role.getMethods()[0];
ExpressionStatement exprStatement =
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
List<?> actual = _testObj.getArguments();
-
+
assertEquals("Base call has wrong number of arguments",
2,
actual.size());
@@ -177,25 +177,25 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
ExpressionStatement exprStatement =
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
List<?> actual = _testObj.getArguments();
-
+
assertEquals("Base call has wrong number of arguments",
0,
actual.size());
}
-
-
+
+
public void testChildNodesHaveCorrectParent1()
{
MethodDeclaration constructor = _role.getMethods()[1];
ExpressionStatement statement =
(ExpressionStatement)constructor.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)statement.getExpression();
-
+
List<Expression> childNodes = _testObj.getArguments();
- for (Iterator<Expression> iter = childNodes.iterator(); iter.hasNext();)
+ for (Iterator<Expression> iter = childNodes.iterator(); iter.hasNext();)
{
Expression curChild = (Expression) iter.next();
assertEquals("Base call arguments have wrong parent node",
@@ -203,47 +203,47 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
curChild.getParent());
}
}
-
+
public void testChildNodesHaveCorrectParent2()
{
MethodDeclaration method = _role.getMethods()[0];
ExpressionStatement exprStatement =
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
SimpleName childNode = _testObj.getName();
-
+
assertEquals("Base call selector has wrong parent",
_testObj,
childNode.getParent());
}
-
+
public void testSubtreeMatch1()
{
MethodDeclaration method = _role.getMethods()[0];
ExpressionStatement exprStatement =
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
assertTrue("Base call message sends don't match", actual);
}
-
+
public void testToString1()
{
MethodDeclaration method = _role.getMethods()[0];
ExpressionStatement exprStatement =
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
String actual = _testObj.toString();
String expected = "base.roleMethod0(arg0, arg1)";
-
+
assertEquals("Base call message send: wrong naive flat string representation",
expected, actual);
}
-
+
public void testResolveMethodBinding()
{
MethodDeclaration method = _role.getMethods()[0];
@@ -251,11 +251,11 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
(ExpressionStatement)method.getBody().statements().get(0);
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
-
+
// Note(SH): base call message send no longer resolves to the enclosing method
//IMethodBinding expected = method.resolveBinding();
IMethodBinding actual = _testObj.resolveMethodBinding();
-
+
assertNotNull(actual);
//Not correct: assertEquals(expected, actual);
//Not implemented: assertTrue(actual.isBaseCallSurrogate());
@@ -264,13 +264,13 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
// public void testResolveReferencedBaseMethodBinding()
// mkr: either remove test or implement resolve binding.
// Note(SH): base call does NOT resolve to a base method.
-
+
public void testNoOtherStatement() {
MethodDeclaration method = _role.getMethods()[0];
assertEquals("Body should have exactly one statement", 1, method.getBody().statements().size());
}
-
+
// check base call within a buggy role (missing base class)
public void testtoString1() throws JavaModelException
@@ -280,30 +280,30 @@ public class BaseCallMessageSendTest extends FileBasedDOMTest
"src",
"basecall.teampkg",
"Team2.java");
-
+
ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
parser.setResolveBindings(true);
parser.setProject( getJavaProject(TEST_PROJECT) );
parser.setSource(_teamClass);
-
+
ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit)root;
TypeDeclaration teamDecl = (TypeDeclaration)compUnit.types().get(0);
TypeDeclaration roleDecl = teamDecl.getTypes()[0];
-
+
MethodDeclaration callinMethod = roleDecl.getMethods()[0];
IfStatement statement = (IfStatement) callinMethod.getBody().statements().get(1);
Assignment assignment = (Assignment)((ExpressionStatement)statement.getThenStatement()).getExpression();
_testObj = (BaseCallMessageSend)assignment.getRightHandSide();
-
+
String actual = _testObj.toString();
String expected = "base.callinMethod(dummy)";
assertEquals("Base call has wrong naive flat string representation",
expected, actual);
}
-
+
// see http://bugs.eclipse.org/372433 - [refactoring][dom] extract method in a callin with tunneled base result throws NPE
public void testReturnWithHiddenExpression1() {
MethodDeclaration method = _role.getMethods()[1];
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest2.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest2.java
index 783dce8e3..a29d9d911 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest2.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseCallMessageSendTest2.java
@@ -1,11 +1,11 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,9 +13,9 @@
*
* SPDX-License-Identifier: EPL-2.0
* $Id$
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -46,7 +46,7 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
*/
public class BaseCallMessageSendTest2 extends FileBasedDOMTest
{
-
+
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
@@ -59,12 +59,12 @@ public class BaseCallMessageSendTest2 extends FileBasedDOMTest
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(BaseCallMessageSendTest2.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -77,14 +77,14 @@ public class BaseCallMessageSendTest2 extends FileBasedDOMTest
ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
parser.setProject(getJavaProject(TEST_PROJECT));
parser.setSource(teamClass);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
_role = _typeDecl.getTypes()[0];
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
@@ -94,18 +94,18 @@ public class BaseCallMessageSendTest2 extends FileBasedDOMTest
MethodDeclaration method = _role.getMethods()[0];
TryStatement tryStatement = (TryStatement)method.getBody().statements().get(0);
Block block = tryStatement.getBody();
-
+
ExpressionStatement exprStatement = (ExpressionStatement)block.statements().get(0);
-
+
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
String actual = _testObj.getName().getIdentifier();
-
+
assertEquals("Base call has wrong name ",
"roleMethod0",
actual);
}
-
+
public void testGetName2()
{
MethodDeclaration method = _role.getMethods()[1];
@@ -114,9 +114,9 @@ public class BaseCallMessageSendTest2 extends FileBasedDOMTest
_testObj = (BaseCallMessageSend)exprStatement.getExpression();
String actual = _testObj.getName().getIdentifier();
-
+
assertEquals("Base call has wrong name ",
"roleMethod1",
actual);
}
-}
+}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java
index 89abba40b..2e91cb428 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/BaseConstructorInvocationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -56,19 +56,19 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
private TypeDeclaration _typeDecl;
private TypeDeclaration _role;
-
+
private BaseConstructorInvocation _testObj;
public BaseConstructorInvocationTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(BaseConstructorInvocationTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -79,12 +79,12 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
"src",
"baseconstructor.teampkg",
"Team1.java");
-
+
ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
parser.setResolveBindings(true);
parser.setProject( getJavaProject(TEST_PROJECT) );
parser.setSource(_teamClass);
-
+
ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit)root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
@@ -92,7 +92,7 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
_role = _typeDecl.getTypes()[0];
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
@@ -114,7 +114,7 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
_testObj = (BaseConstructorInvocation)constructor.getBody().statements().get(0);
int actual = _testObj.getNodeType();
-
+
assertEquals("BaseConstructorMessageSend has wrong node type",
ASTNode.BASE_CONSTRUCTOR_INVOCATION,
actual);
@@ -124,9 +124,9 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
{
MethodDeclaration constructor = _role.getMethods()[0];
_testObj = (BaseConstructorInvocation)constructor.getBody().statements().get(0);
-
+
List actual = _testObj.getArguments();
-
+
assertEquals("BaseConstructorMessageSend has wrong number of arguments",
0,
actual.size());
@@ -137,23 +137,23 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
RoleTypeDeclaration role = _typeDecl.getRoles()[0];
MethodDeclaration constructor = role.getMethods()[1];
_testObj = (BaseConstructorInvocation)constructor.getBody().statements().get(0);
-
+
List actual = _testObj.getArguments();
-
+
assertEquals("BaseConstructorMessageSend has wrong number of arguments",
2,
actual.size());
}
-
+
public void testChildNodesHaveCorrectParent1()
{
MethodDeclaration constructor = _role.getMethods()[1];
_testObj = (BaseConstructorInvocation) constructor.getBody().statements().get(0);
-
+
List childNodes = _testObj.getArguments();
- for (Iterator iter = childNodes.iterator(); iter.hasNext();)
+ for (Iterator iter = childNodes.iterator(); iter.hasNext();)
{
Expression curChild = (Expression) iter.next();
assertEquals("Base call arguments have wrong parent node",
@@ -161,23 +161,23 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
curChild.getParent());
}
}
-
+
public void testSubtreeMatch1()
{
MethodDeclaration constructor = _role.getMethods()[1];
_testObj = (BaseConstructorInvocation)constructor.getBody().statements().get(0);
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
assertTrue("Base constructor calls don't match", actual);
-
+
}
public void testtoString1()
{
MethodDeclaration constructor = _role.getMethods()[1];
_testObj = (BaseConstructorInvocation)constructor.getBody().statements().get(0);
-
+
String actual = _testObj.toString();
String expected = "base(dummy0, dummy1);";
@@ -193,28 +193,28 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
"src",
"baseconstructor.teampkg",
"Team2.java");
-
+
ASTParser parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
parser.setResolveBindings(true);
parser.setProject( getJavaProject(TEST_PROJECT) );
parser.setSource(_teamClass);
-
+
ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit)root;
TypeDeclaration team2Decl = (TypeDeclaration)compUnit.types().get(0);
TypeDeclaration role2Decl = team2Decl.getTypes()[0];
-
+
MethodDeclaration constructor = role2Decl.getMethods()[1];
_testObj = (BaseConstructorInvocation)constructor.getBody().statements().get(0);
-
+
String actual = _testObj.toString();
String expected = "base(dummy0, dummy1);";
assertEquals("Base constructor call has wrong naive flat string representation",
expected, actual);
}
-
+
public void testResolveConstructorBinding()
{
RoleTypeDeclaration role = _typeDecl.getRoles()[0];
@@ -224,10 +224,10 @@ public class BaseConstructorInvocationTest extends FileBasedDOMTest
ITypeBinding baseClass = role.resolveBinding().getBaseClass();
IMethodBinding baseConstructorBinding = baseClass.getDeclaredMethods()[1];
-
+
IMethodBinding expected = baseConstructorBinding;
IMethodBinding actual = _testObj.resolveConstructorBinding();
-
+
assertNotNull(actual);
assertEquals(expected, actual);
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CallinMappingDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CallinMappingDeclarationTest.java
index 34718f470..d679047df 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CallinMappingDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CallinMappingDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -47,7 +47,7 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
/**
* @author mkr
* @version $Id: CallinMappingDeclarationTest.java 23496 2010-02-05 23:20:15Z stephan $
- *
+ *
* NOTE: ParameterMappings are tested in ParameterMappingTest, including the PARAMETER_MAPPINGS_PROPERTY
* (attribute of CallinMappingDeclaration).
*/
@@ -68,12 +68,12 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(CallinMappingDeclarationTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -88,13 +88,13 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
_parser.setResolveBindings(true);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
@@ -130,11 +130,11 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
TypeDeclaration role = types[0];
_testObj = (CallinMappingDeclaration)role.bodyDeclarations().get(0);
-
+
assertTrue("Missing 'before' modifier",
Modifier.isBefore(_testObj.getCallinModifier()));
}
-
+
public void testGetCallinModifiers_ReplaceBinding()
{
TypeDeclaration[] types = _typeDecl.getTypes();
@@ -198,7 +198,7 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
assertEquals(1, actual.size());
}
-
+
public void testGetBaseMappingElements_ThreeElems()
{
TypeDeclaration[] types = _typeDecl.getTypes();
@@ -210,41 +210,41 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
assertEquals("Wrong number of MethodSpec",
3, actual.size());
}
-
+
public void testGetRoleMappingElement_InstanceType()
{
TypeDeclaration[] types = _typeDecl.getTypes();
TypeDeclaration role = types[0];
_testObj = (CallinMappingDeclaration)role.bodyDeclarations().get(3);
-
+
assertTrue("Left side of callin not a MethodSpec",
_testObj.getRoleMappingElement() instanceof MethodSpec);
}
-
+
public void testGetBaseMappingElements_InstanceType()
{
TypeDeclaration[] types = _typeDecl.getTypes();
TypeDeclaration role = types[0];
_testObj = (CallinMappingDeclaration)role.bodyDeclarations().get(3);
-
+
assertTrue("Right side of callin not a MethodSpec",
_testObj.getBaseMappingElements().get(0) instanceof MethodSpec);
assertTrue("Right side of callin not a MethodSpec",
_testObj.getBaseMappingElements().get(1) instanceof MethodSpec);
assertTrue("Right side of callin not a MethodSpec",
_testObj.getBaseMappingElements().get(2) instanceof MethodSpec);
-
+
}
-
+
public void testGetParameterMappings_NotNull()
{
TypeDeclaration[] types = _typeDecl.getTypes();
TypeDeclaration role = types[0];
_testObj = (CallinMappingDeclaration)role.bodyDeclarations().get(4);
-
+
assertTrue("Parameter mapping null", _testObj.getParameterMappings() != null);
}
@@ -255,12 +255,12 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
_testObj = (CallinMappingDeclaration)role.bodyDeclarations().get(4);
List actualNodes = _testObj.getParameterMappings();
- for (Iterator iter = actualNodes.iterator(); iter.hasNext();)
+ for (Iterator iter = actualNodes.iterator(); iter.hasNext();)
{
ParameterMapping curActual = (ParameterMapping) iter.next();
assertTrue("CallinMappingDeclaration has ParameterMapping with wrong parent",
_testObj == curActual.getParent());
- }
+ }
}
public void testGetParameterMappings_Empty()
@@ -303,7 +303,7 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
"BrokenTeam.java");
_parser.setSource(brokenCU);
_parser.setResolveBindings(true);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
TypeDeclaration teamType = (TypeDeclaration)compUnit.types().get(0);
@@ -312,5 +312,5 @@ public class CallinMappingDeclarationTest extends FileBasedDOMTest
assertEquals("foo <- after bar;", callinMapping.toString());
// TODO(SH): adjust once recovery of parameter mappings is implemented.
}
-
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CalloutMappingDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CalloutMappingDeclarationTest.java
index 75760dfbd..1a97c15cf 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CalloutMappingDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/CalloutMappingDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -47,7 +47,7 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
/**
* @author jsv
* @version $Id: CalloutMappingDeclarationTest.java 23496 2010-02-05 23:20:15Z stephan $
- *
+ *
* NOTE: ParameterMappings are tested in ParameterMappingTest, including the PARAMETER_MAPPINGS_PROPERTY
* (attribute of CalloutMappingDeclaration).
*/
@@ -63,28 +63,28 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
private TypeDeclaration _role;
// one more version with a syntax error:
private ICompilationUnit _simpleTeamBuggy;
- private TypeDeclaration _typeDeclBuggy;
+ private TypeDeclaration _typeDeclBuggy;
private TypeDeclaration _roleBuggy;
-
+
private CalloutMappingDeclaration _testObj;
public CalloutMappingDeclarationTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(CalloutMappingDeclarationTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -92,11 +92,11 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
"src",
"callouts.teampkg",
"Team1.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
@@ -109,11 +109,11 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
"src",
"callouts.teampkg",
"TeamBuggy.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeamBuggy);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDeclBuggy = (TypeDeclaration)compUnit.types().get(0);
@@ -124,68 +124,68 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
{
// extract the callout mapping as body declaration
BodyDeclaration testObj = (BodyDeclaration)_role.bodyDeclarations().get(2);
-
+
assertTrue(
"BodyDeclaration is not an instance of CalloutMappingDeclaration",
testObj instanceof CalloutMappingDeclaration);
}
-
+
public void testGetNodeType1()
{
// extract the callout mapping as body declaration
BodyDeclaration testObj = (BodyDeclaration)_role.bodyDeclarations().get(2);
-
+
int actual = testObj.getNodeType();
-
+
assertEquals(
- "CalloutMappingDeclaration has wrong NodeType",
- ASTNode.CALLOUT_MAPPING_DECLARATION,
+ "CalloutMappingDeclaration has wrong NodeType",
+ ASTNode.CALLOUT_MAPPING_DECLARATION,
actual);
}
-
+
public void testIsCalloutOverride_false()
{
- _testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
+ _testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
boolean actual = _testObj.isCalloutOverride();
-
+
assertFalse("Callout is not overridden", actual);
}
-
+
public void testIsCalloutOverride_true()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
-
+
boolean actual = _testObj.isCalloutOverride();
-
+
assertTrue("Callout is overridden", actual);
}
-
+
public void testHasSignature_true()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
-
- boolean actual = _testObj.hasSignature();
-
+
+ boolean actual = _testObj.hasSignature();
+
assertTrue(
- "Callout binding should have a signature",
+ "Callout binding should have a signature",
actual);
}
-
+
public void testHasSignature_false()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
-
+
boolean actual = _testObj.hasSignature();
-
+
assertFalse(
- "Callout binding should not have a signature",
+ "Callout binding should not have a signature",
actual);
}
-
+
public void testCalloutWithModifier() {
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(10);
-
+
boolean found = false;
boolean other = false;
for (Object modObj : _testObj.modifiers()) {
@@ -198,12 +198,12 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
System.out.println("Unexpected modifier "+other);
}
}
-
+
assertTrue(
- "Callout binding should have a protected modifier",
- found);
+ "Callout binding should have a protected modifier",
+ found);
assertFalse(
- "Callout binding should not have other modifier",
+ "Callout binding should not have other modifier",
other);
}
@@ -211,8 +211,8 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
- ASTNode actual = _testObj.getParent();
-
+ ASTNode actual = _testObj.getParent();
+
assertNotNull(
"ParentNode of CalloutMappingDeclaration has to be not null",
actual);
@@ -222,17 +222,17 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
- ASTNode actual = _testObj.getParent();
-
+ ASTNode actual = _testObj.getParent();
+
assertNotNull(
"ParentNode of CalloutMappingDeclaration has to be not null",
actual);
- }
+ }
public void testGetParent_InstanceType1()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
-
+
ASTNode actual = _testObj.getParent();
assertTrue(
@@ -245,185 +245,185 @@ public class CalloutMappingDeclarationTest extends FileBasedDOMTest
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
ASTNode actual = _testObj.getParent();
-
+
assertTrue(
"ParentNode has wrong Type",
actual instanceof RoleTypeDeclaration );
}
-
+
public void testGetLeftMethodSpec_notNull()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
-
+
MethodSpec actual = (MethodSpec)_testObj.getRoleMappingElement();
-
+
assertNotNull("LeftMethodSpec must not be null", actual);
- }
+ }
public void testGetRightMethodSpec_notNull()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
-
+
MethodSpec actual = (MethodSpec)_testObj.getBaseMappingElement();
assertNotNull("RightMethodSpec must not be null", actual);
}
-
+
public void testHasSignature_SameFlag()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
MethodSpec leftMethodSpec = (MethodSpec)_testObj.getRoleMappingElement();
MethodSpec rightMethodSpec = (MethodSpec)_testObj.getBaseMappingElement();
-
- boolean actual = leftMethodSpec.hasSignature() == rightMethodSpec.hasSignature();
-
+
+ boolean actual = leftMethodSpec.hasSignature() == rightMethodSpec.hasSignature();
+
assertTrue(
"The base and base method should have the same signature flag",
actual);
}
-
+
public void testGetRightMethodSpec_InstanceType1()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
-
+
Object actual = _testObj.getBaseMappingElement();
assertTrue(
- "In this case the base accessor should be a MethodSpec",
+ "In this case the base accessor should be a MethodSpec",
actual instanceof MethodSpec);
}
-
+
public void testGetRightMethodSpec_InstanceType2()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(5);
-
+
Object actual = _testObj.getBaseMappingElement();
-
+
assertTrue(
- "In this case the base accessor should be a FieldAccessSpec",
+ "In this case the base accessor should be a FieldAccessSpec",
actual instanceof FieldAccessSpec);
}
-
+
public void testGetRightMethodSpec_InstanceType3()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(7);
-
+
Object actual = _testObj.getBaseMappingElement();
-
+
assertTrue(
- "In this case the base accessor should be a FieldAccessSpec",
+ "In this case the base accessor should be a FieldAccessSpec",
actual instanceof FieldAccessSpec);
}
-
+
public void testGetParameterMappings_Empty()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(7);
List parameterMappings = _testObj.getParameterMappings();
-
+
boolean actual = parameterMappings.isEmpty();
-
+
assertTrue(
"List ParameterMappings is not empty",
actual);
}
-
+
public void testGetParameterMappings_NotEmpty()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(9);
List parameterMappings = _testObj.getParameterMappings();
-
+
boolean actual = parameterMappings.isEmpty();
-
+
assertFalse("List ParameterMappings is empty", actual);
- }
-
- /**
- * compares the AST references of calloutMappingDeclaration and
- * roleMethodSpec
+ }
+
+ /**
+ * compares the AST references of calloutMappingDeclaration and
+ * roleMethodSpec
*/
public void testGetAST_Identity1()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
MethodSpec roleMethodSpec = (MethodSpec)_testObj.getRoleMappingElement();
-
+
assertTrue(
"Role Methodspec is not associate to the same AST like parent CalloutMappingDeclaration",
_testObj.getAST() == roleMethodSpec.getAST());
}
- /**
+ /**
* compares the AST references of calloutMappingDeclaration and baseMethodSpec
*/
public void testGetAST_Identity2()
{
_testObj= (CalloutMappingDeclaration)_role.bodyDeclarations().get(2);
MethodSpec baseMethodSpec = (MethodSpec)_testObj.getBaseMappingElement();
-
+
assertTrue(
"Base Methodspec is not associate to the same AST like parent CalloutMappingDeclaration",
_testObj.getAST() == baseMethodSpec.getAST());
}
-
- /**
- * compares the AST references of calloutMappingDeclaration and
- * baseFieldAccessSpec
- */
+
+ /**
+ * compares the AST references of calloutMappingDeclaration and
+ * baseFieldAccessSpec
+ */
public void testGetAST_Identity3()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(5);
- FieldAccessSpec baseFiedAccessSpec =
+ FieldAccessSpec baseFiedAccessSpec =
(FieldAccessSpec)_testObj.getBaseMappingElement();
-
+
assertTrue(
"Base FieldAccessySpec is not associate to the same AST like parent CalloutMappingDeclaration",
_testObj.getAST() == baseFiedAccessSpec.getAST());
}
-
- /**
- * compares the AST references of calloutMappingDeclaration and first
- * ParameterMapping
- */
+
+ /**
+ * compares the AST references of calloutMappingDeclaration and first
+ * ParameterMapping
+ */
public void testGetAST_Identity4()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(9);
// get first ParameterMapping
- ParameterMapping parameterMapping =
- (ParameterMapping)_testObj.getParameterMappings().get(0);
-
+ ParameterMapping parameterMapping =
+ (ParameterMapping)_testObj.getParameterMappings().get(0);
+
assertTrue(
"First ParameterMapping is not associate to the same AST like parent CalloutMappingDeclaration",
_testObj.getAST() == parameterMapping.getAST());
}
-
+
public void testSubtreeMatch1()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(9);
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
-
+
assertTrue("Callout mappings don't match", actual);
}
-
+
public void testCopySubtree1()
{
_testObj = (CalloutMappingDeclaration)_role.bodyDeclarations().get(9);
-
- CalloutMappingDeclaration clonedTestObject =
+
+ CalloutMappingDeclaration clonedTestObject =
(CalloutMappingDeclaration)ASTNode.copySubtree(AST.newAST(AST.JLS4), _testObj);
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), clonedTestObject);
assertTrue("Copy of subtree not correct", actual);
}
-
+
public void testSourceRangeOfBuggyCallout() throws JavaModelException
{
setupForBuggyTeam();
-
+
_testObj = (CalloutMappingDeclaration)_roleBuggy.bodyDeclarations().get(3);
-
- int start = _testObj.getRoleMappingElement().getStartPosition();
- int length = _testObj.getRoleMappingElement().getLength();
-
+
+ int start = _testObj.getRoleMappingElement().getStartPosition();
+ int length = _testObj.getRoleMappingElement().getLength();
+
assertEquals(436, start);
assertEquals(14, length); // "void fooBar2()"
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
index fdd5d3b58..b48004a98 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/DOMRegressionTests.java
@@ -1,8 +1,8 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2010 Stephan Herrmann.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -10,9 +10,9 @@
*
* SPDX-License-Identifier: EPL-2.0
* $Id$
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Stephan Herrmann - Initial API and implementation
**********************************************************************/
@@ -34,20 +34,20 @@ import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
public class DOMRegressionTests extends FileBasedDOMTest {
-
+
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
-
+
public DOMRegressionTests(String name) {
super(name);
}
-
+
public static Test suite()
{
return new Suite(DOMRegressionTests.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -55,11 +55,11 @@ public class DOMRegressionTests extends FileBasedDOMTest {
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
-
+
// Bug 316666 - [dom] IllegalArgumentException in very broken source
public void testBug316666() throws JavaModelException {
ICompilationUnit teamClass = getCompilationUnit(
@@ -71,15 +71,15 @@ public class DOMRegressionTests extends FileBasedDOMTest {
parser.setProject(getJavaProject(TEST_PROJECT));
parser.setSource(teamClass);
parser.setResolveBindings(true);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
TypeDeclaration topTeam = (TypeDeclaration) compUnit.types().get(0);
TypeDeclaration nestedTeam = (TypeDeclaration) topTeam.getTypes()[1];
// note: the bug was related to mistakenly converted generated fields.
assertEquals("No fields expected",nestedTeam.getFields().length, 0);
}
-
+
// version with somewhat repaired structure in the source file (similar(?) to what the parser actually saw):
public void testBug316666_repaired() throws JavaModelException {
ICompilationUnit teamClass = getCompilationUnit(
@@ -91,8 +91,8 @@ public class DOMRegressionTests extends FileBasedDOMTest {
parser.setProject(getJavaProject(TEST_PROJECT));
parser.setSource(teamClass);
parser.setResolveBindings(true);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
TypeDeclaration topTeam = (TypeDeclaration) compUnit.types().get(0);
TypeDeclaration nestedTeam = (TypeDeclaration) topTeam.getTypes()[0];
@@ -113,8 +113,8 @@ public class DOMRegressionTests extends FileBasedDOMTest {
parser.setSource(teamClass);
parser.setStatementsRecovery(true);
parser.setResolveBindings(true);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
TypeDeclaration topTeam = (TypeDeclaration) compUnit.types().get(0);
TypeDeclaration role = (TypeDeclaration) topTeam.getTypes()[0];
@@ -124,5 +124,5 @@ public class DOMRegressionTests extends FileBasedDOMTest {
// note: the bug was related to mistakenly converted generated fields.
assertEquals("Call to foo expected", "foo", basecall.getName().getIdentifier());
}
-
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/FieldAccessSpecTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/FieldAccessSpecTest.java
index ed0a81633..fc512254a 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/FieldAccessSpecTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/FieldAccessSpecTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -50,31 +50,31 @@ public class FieldAccessSpecTest extends FileBasedDOMTest
private ASTParser _parser;
private ICompilationUnit _simpleTeam;
private ICompilationUnit _baseClassCompUnit;
-
+
private TypeDeclaration _typeDecl; // a java class common to all within tests
private TypeDeclaration _role;
private TypeDeclaration _base;
-
+
private FieldAccessSpec _testObj;
private Object mapping;
-
+
public FieldAccessSpecTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(FieldAccessSpecTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -93,26 +93,26 @@ public class FieldAccessSpecTest extends FileBasedDOMTest
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
_parser.setResolveBindings(true);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit)root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
_role = _typeDecl.getTypes()[0];
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_baseClassCompUnit);
_parser.setResolveBindings(true);
-
+
compUnit = (CompilationUnit)_parser.createAST( new NullProgressMonitor() );
- _base = (TypeDeclaration)compUnit.types().get(0);
+ _base = (TypeDeclaration)compUnit.types().get(0);
}
public void testInstanceType1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
FieldAccessSpec testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
assertTrue(testObj instanceof FieldAccessSpec);
}
@@ -120,117 +120,117 @@ public class FieldAccessSpecTest extends FileBasedDOMTest
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
boolean actual = _testObj.hasSignature();
-
+
assertTrue("FieldAccessSpec should have a signature", actual);
}
-
+
public void testHasSignature_false()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
boolean actual = _testObj.hasSignature();
-
+
assertFalse("FieldAccessSpec should not have a signature", actual);
}
-
+
public void testGetParent_InstanceType1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
- _testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+ _testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
+
ASTNode actual = _testObj.getParent();
assertTrue(
"ParentNode has wrong Type, Should be CalloutMappingDeclaration",
actual instanceof CalloutMappingDeclaration);
}
-
+
public void testSubtreeMatch1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
-
+
assertTrue("FieldAccessSpecs don't match", actual);
}
-
+
public void testCopySubtree1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
- _testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
- FieldAccessSpec clonedTestObject =
+ _testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
+
+ FieldAccessSpec clonedTestObject =
(FieldAccessSpec)ASTNode.copySubtree(AST.newAST(AST.JLS4), _testObj);
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), clonedTestObject);
assertTrue("Copy of subtree not correct", actual);
}
-
+
public void testGetModifiers_Get()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
int actual = mapping.bindingOperator().getBindingModifier();
-
+
assertTrue(
- "Callout should have the get modifier",
+ "Callout should have the get modifier",
Modifier.isGet(actual));
assertEquals(
"Callout should be a getter",
Modifier.OT_GET_CALLOUT,
mapping.bindingOperator().getBindingModifier());
}
-
+
public void testGetModifiers_Set()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
int actual = mapping.bindingOperator().getBindingModifier();
-
+
assertTrue(
- "Callout should have the set modifier",
+ "Callout should have the set modifier",
Modifier.isSet(actual));
assertEquals(
- "Callout should be a setter",
+ "Callout should be a setter",
Modifier.OT_SET_CALLOUT,
mapping.bindingOperator().getBindingModifier());
}
-
+
public void testGetName_string()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
String actual = _testObj.getName().getIdentifier();
-
+
assertEquals("FieldAccess has wrong name ",
"_string",
actual);
}
-
+
public void testResolveBinding()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
FieldDeclaration fieldDecl = (FieldDeclaration)_base.bodyDeclarations().get(0);
-
+
_testObj = (FieldAccessSpec)mapping.getBaseMappingElement();
-
+
VariableDeclarationFragment varDeclFrag =
(VariableDeclarationFragment)fieldDecl.fragments().get(0);
-
+
IVariableBinding expected = varDeclFrag.resolveBinding();
IVariableBinding actual = _testObj.resolveBinding();
assertEquals(expected.getKey(), actual.getKey());
}
-
-
-
+
+
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/GuardPredicateTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/GuardPredicateTest.java
index 1a9538478..ec9313874 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/GuardPredicateTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/GuardPredicateTest.java
@@ -1,11 +1,11 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,9 +13,9 @@
*
* SPDX-License-Identifier: EPL-2.0
* $Id$
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -46,7 +46,7 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
public class GuardPredicateTest extends FileBasedDOMTest {
public static final String TEST_PROJECT = "DOM_AST";
-
+
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
private ASTParser _parser;
@@ -55,16 +55,16 @@ public class GuardPredicateTest extends FileBasedDOMTest {
// Java class used for all within tests
private CompilationUnit _cu;
private TypeDeclaration _typeDecl;
-
+
public GuardPredicateTest(String name) {
super(name);
}
-
+
public static Test suite()
{
return new Suite(GuardPredicateTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -79,28 +79,28 @@ public class GuardPredicateTest extends FileBasedDOMTest {
_parser.setProject( getJavaProject(TEST_PROJECT) );
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
-
+
@SuppressWarnings({ "unchecked" })
- private void initAST(ICompilationUnit icu, boolean resolve, String targetLevel)
+ private void initAST(ICompilationUnit icu, boolean resolve, String targetLevel)
{
_parser.setSource(icu);
-
+
Map options = getJavaProject(TEST_PROJECT).getOptions(true);
options.put(CompilerOptions.OPTION_TargetPlatform, targetLevel);
_parser.setCompilerOptions(options);
_parser.setResolveBindings(resolve);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
_cu = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)_cu.types().get(0);
-
+
}
-
+
public void testPredicateInRole() {
initAST(_simpleTeam, false, CompilerOptions.VERSION_1_5);
@@ -110,7 +110,7 @@ public class GuardPredicateTest extends FileBasedDOMTest {
GuardPredicateDeclaration guard = role1.getGuardPredicate();
assertFalse("guard predicate is non-null", guard == null);
assertTrue("guard is base guard", guard.isBase());
-
+
ASTRewriteFlattener _rewriteFlattener = new ASTRewriteFlattener(new RewriteEventStore());
guard.accept(_rewriteFlattener);
@@ -118,7 +118,7 @@ public class GuardPredicateTest extends FileBasedDOMTest {
String expected = "base when (Team2.this.hasRole(base,R.class))"; //$NON-NLS-1$
assertEquals("Wrong guard Code", expected, actual);
}
-
+
@SuppressWarnings({ "restriction"})
public void testPredicateRegression() throws JavaModelException {
initAST(getCompilationUnit(
@@ -127,14 +127,14 @@ public class GuardPredicateTest extends FileBasedDOMTest {
"predicates.teampkg",
"TeamBug.java"),
true, CompilerOptions.VERSION_1_6);
-
+
TypeDeclaration[] types = _typeDecl.getTypes();
RoleTypeDeclaration role1 = (RoleTypeDeclaration)types[0];
CallinMappingDeclaration callinDecl = role1.getCallIns()[0];
GuardPredicateDeclaration guard = callinDecl.getGuardPredicate();
assertFalse("guard predicate is non-null", guard == null);
assertFalse("guard is not base guard", guard.isBase());
-
+
ASTRewriteFlattener _rewriteFlattener = new ASTRewriteFlattener(new RewriteEventStore());
guard.accept(_rewriteFlattener);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/LiftingTypeTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/LiftingTypeTest.java
index 513de7427..62fc9fe98 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/LiftingTypeTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/LiftingTypeTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -51,30 +51,30 @@ public class LiftingTypeTest extends FileBasedDOMTest
private ASTParser _parser;
private ICompilationUnit _simpleTeam;
-
+
private TypeDeclaration _typeDecl; // a java class common to all within tests
- private MethodDeclaration _methodDecl;
+ private MethodDeclaration _methodDecl;
private SingleVariableDeclaration _variableDecl;
-
+
private LiftingType _testObj;
-
+
public LiftingTypeTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(LiftingTypeTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -82,77 +82,77 @@ public class LiftingTypeTest extends FileBasedDOMTest
"src",
"liftingType.teampkg",
"Team1.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
- _methodDecl = (MethodDeclaration)_typeDecl.bodyDeclarations().get(0);
+ _methodDecl = (MethodDeclaration)_typeDecl.bodyDeclarations().get(0);
_variableDecl = (SingleVariableDeclaration)_methodDecl.parameters().get(0);
}
public void testInstanceType1()
{
Type testObj = _variableDecl.getType();
-
+
assertTrue(testObj instanceof LiftingType);
}
-
+
public void testSubtreeMatch1()
{
_testObj = (LiftingType)_variableDecl.getType();
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
-
+
assertTrue("LiftingTypes don't match", actual);
}
-
+
public void testCopySubtree1()
{
- _testObj = (LiftingType)_variableDecl.getType();
- LiftingType clonedTestObject =
+ _testObj = (LiftingType)_variableDecl.getType();
+ LiftingType clonedTestObject =
(LiftingType)ASTNode.copySubtree(AST.newAST(AST.JLS4), _testObj);
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), clonedTestObject);
assertTrue("Copy of subtree not correct", actual);
}
-
+
public void testGetBaseType_MyClass()
{
_testObj = (LiftingType)_variableDecl.getType();
Name typeName = ((SimpleType)_testObj.getBaseType()).getName();
-
+
String actual = ((SimpleName)typeName).getIdentifier();
-
+
assertEquals("Base type has wrong name ",
"MyClass",
actual);
}
-
+
public void testGetRoleType_MyRole()
{
_testObj = (LiftingType)_variableDecl.getType();
Name typeName = ((SimpleType)_testObj.getRoleType()).getName();
-
+
String actual = ((SimpleName)typeName).getIdentifier();
-
+
assertEquals("Role type has wrong name ",
"MyRole",
actual);
}
-
+
public void testSignature()
{
_testObj = (LiftingType)_variableDecl.getType();
String sig = Util.getSignature(_testObj);
-
+
assertEquals("Base type has wrong name ",
"QMyClass;",
sig);
}
-
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/MethodSpecTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/MethodSpecTest.java
index 695ab6c79..f98b71a66 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/MethodSpecTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/MethodSpecTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -52,29 +52,29 @@ public class MethodSpecTest extends FileBasedDOMTest
private ASTParser _parser;
private ICompilationUnit _simpleTeam;
-
+
private TypeDeclaration _typeDecl; // a java class common to all within tests
private TypeDeclaration _role;
-
+
private MethodSpec _testObj;
-
+
public MethodSpecTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(MethodSpecTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -82,144 +82,144 @@ public class MethodSpecTest extends FileBasedDOMTest
"src",
"methodSpec.teampkg",
"Team1.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
_parser.setResolveBindings(true);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit)root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
- _role = _typeDecl.getTypes()[0];
+ _role = _typeDecl.getTypes()[0];
}
public void testInstanceType1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
Object testObj = mapping.getRoleMappingElement();
-
+
assertTrue(testObj instanceof MethodSpec);
}
-
+
public void testParameters_Two()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+
List actual = _testObj.parameters();
-
+
assertEquals(2, actual.size());
}
-
+
public void testParameters_Empty()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(3);
_testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+
List actual = _testObj.parameters();
-
+
assertTrue(actual.isEmpty());
}
-
+
public void testHasSignature_true()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+
boolean actual = _testObj.hasSignature();
-
+
assertTrue("MethodSpec should have a signature", actual);
}
-
+
public void testHasSignature_false()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(5);
_testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+
boolean actual = _testObj.hasSignature();
assertFalse("MethodSpec should not have a signature", actual);
}
-
+
public void testSubtreeMatch1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
-
+
assertTrue("MethodSpecs don't match", actual);
}
-
+
public void testCopySubtree1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
- _testObj = (MethodSpec)mapping.getRoleMappingElement();
-
- MethodSpec clonedTestObject =
+ _testObj = (MethodSpec)mapping.getRoleMappingElement();
+
+ MethodSpec clonedTestObject =
(MethodSpec)ASTNode.copySubtree(AST.newAST(AST.JLS4), _testObj);
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), clonedTestObject);
assertTrue("Copy of subtree not correct", actual);
}
-
+
public void testGetParent_InstanceType1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
- _testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+ _testObj = (MethodSpec)mapping.getRoleMappingElement();
+
ASTNode actual = _testObj.getParent();
assertTrue(
"ParentNode has wrong Type, Should be CalloutMappingDeclaration",
actual instanceof CalloutMappingDeclaration );
}
-
+
public void testGetParent_InstanceType2()
{
CallinMappingDeclaration mapping = (CallinMappingDeclaration)_role.bodyDeclarations().get(7);
- _testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+ _testObj = (MethodSpec)mapping.getRoleMappingElement();
+
ASTNode actual = _testObj.getParent();
assertTrue(
"ParentNode has wrong Type. Should be CallinMappingDeclaration",
actual instanceof CallinMappingDeclaration );
}
-
+
public void testGetName1()
{
CalloutMappingDeclaration mapping = (CalloutMappingDeclaration)_role.bodyDeclarations().get(1);
_testObj = (MethodSpec)mapping.getRoleMappingElement();
String actual = _testObj.getName().getIdentifier();
-
+
assertEquals("MethodSpec has wrong name ",
"roleGetString",
actual);
}
-
+
public void testResolveBinding_roleMethSpec()
- {
+ {
CallinMappingDeclaration mapping = (CallinMappingDeclaration)_role.bodyDeclarations().get(7);
MethodDeclaration methDecl = (MethodDeclaration)_role.bodyDeclarations().get(6);
-
+
_testObj = (MethodSpec)mapping.getRoleMappingElement();
-
+
IMethodBinding expected = methDecl.resolveBinding();
IMethodBinding actual = _testObj.resolveBinding();
-
+
assertEquals(expected, actual);
}
-
+
public void testResolveBinding_baseMethSpec()
- {
+ {
CallinMappingDeclaration mapping = (CallinMappingDeclaration)_role.bodyDeclarations().get(7);
-
+
_testObj = (MethodSpec)mapping.getBaseMappingElements().get(0);
-
+
// Note: more than one createAST call causes that bindings resolved from one
- // AST won't be equal to ones resolved from the other AST. Se we can't compare
+ // AST won't be equal to ones resolved from the other AST. Se we can't compare
// bindings from _base with ones from _role. Instead, navigate the bindings within
// one AST.
@@ -233,7 +233,7 @@ public class MethodSpecTest extends FileBasedDOMTest
break;
}
}
-
+
IMethodBinding expected = baseMethodBinding;
assertNotNull(expected);
IMethodBinding actual = _testObj.resolveBinding();
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCallinTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCallinTest.java
index 0b922ad17..acf9a0e69 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCallinTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCallinTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -41,9 +41,9 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
* @author ike
*
* Tests the DOM-astNode parameterMapping.
- *
+ *
*/
-public class ParameterMappingCallinTest extends FileBasedDOMTest
+public class ParameterMappingCallinTest extends FileBasedDOMTest
{
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
@@ -51,9 +51,9 @@ public class ParameterMappingCallinTest extends FileBasedDOMTest
private ASTParser _parser;
private ICompilationUnit _simpleTeam;
private TypeDeclaration _typeDecl;
- private TypeDeclaration _role;
-
- public ParameterMappingCallinTest(String name)
+ private TypeDeclaration _role;
+
+ public ParameterMappingCallinTest(String name)
{
super(name);
}
@@ -62,14 +62,14 @@ public class ParameterMappingCallinTest extends FileBasedDOMTest
{
return new Suite(ParameterMappingCallinTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -77,83 +77,83 @@ public class ParameterMappingCallinTest extends FileBasedDOMTest
"src",
"parameterMapping.teampkg",
"MyTeam.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject(super.getJavaProject(TEST_PROJECT));
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
-
+
//this role contains only callinBindings
_role = _typeDecl.getTypes()[1];
}
-
+
//test is for first callinMapping in Testdata (Role)
public void testGetParameterMappings_notEmpty1()
{
CallinMappingDeclaration callinDecl = (CallinMappingDeclaration)_role.bodyDeclarations().get(3);
List mappings = callinDecl.getParameterMappings();
-
+
assertNotNull("ParametermappingList should be not empty", mappings);
assertFalse(mappings.isEmpty());
- }
-
+ }
+
//test is for first callinMapping in Testdata (Role)
public void testHasResultFlag_true1()
{
CallinMappingDeclaration callinDecl = (CallinMappingDeclaration)_role.bodyDeclarations().get(3);
List parameterMappings = callinDecl.getParameterMappings();
-
+
//test the second parameterMapping of this CalloutMappingDeclaration
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(1);
boolean actual = testObj.hasResultFlag();
-
+
assertTrue("Mapping is a result mapping, but was not detected", actual);
- }
+ }
//test is for second callinMapping in Testdata (Role)
public void testGetParameterMappings_notEmpty2()
{
CallinMappingDeclaration callinDecl = (CallinMappingDeclaration)_role.bodyDeclarations().get(4);
List mappings = callinDecl.getParameterMappings();
-
+
assertNotNull("ParametermappingList should be not empty", mappings);
assertFalse(mappings.isEmpty());
- }
-
+ }
+
//test is for fourth calloutMapping in Testdata (Role)
public void testHasResultFlag_true2()
{
CallinMappingDeclaration callinDecl = (CallinMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = callinDecl.getParameterMappings();
-
+
//test the second parameterMapping of this CalloutMappingDeclaration
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(1);
boolean actual = testObj.hasResultFlag();
-
+
assertTrue("Mapping is a result mapping, but was not detected", actual);
- }
+ }
public void testSubTreeMatch1()
{
CallinMappingDeclaration callinDecl = (CallinMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = callinDecl.getParameterMappings();
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(1);
-
+
boolean actual = testObj.subtreeMatch(new ASTMatcher(), testObj);
assertTrue("Both nodes are equal, even the same.", actual);
}
-
+
public void testCopySubtree()
{
CallinMappingDeclaration callinDecl = (CallinMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = callinDecl.getParameterMappings();
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(1);
- ParameterMapping clonedTestObject =
+ ParameterMapping clonedTestObject =
(ParameterMapping)ASTNode.copySubtree(AST.newAST(AST.JLS4), testObj);
boolean actual = testObj.subtreeMatch(new ASTMatcher(), clonedTestObject);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCalloutTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCalloutTest.java
index 7428c3bfa..3491ebcd2 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCalloutTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/ParameterMappingCalloutTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -45,9 +45,9 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
* @author ike
*
* Tests the DOM-astNode parameterMapping.
- *
+ *
*/
-public class ParameterMappingCalloutTest extends FileBasedDOMTest
+public class ParameterMappingCalloutTest extends FileBasedDOMTest
{
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
@@ -56,8 +56,8 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
private ICompilationUnit _simpleTeam;
private TypeDeclaration _typeDecl;
private TypeDeclaration _role;
-
- public ParameterMappingCalloutTest(String name)
+
+ public ParameterMappingCalloutTest(String name)
{
super(name);
}
@@ -66,14 +66,14 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
{
return new Suite(ParameterMappingCalloutTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -81,17 +81,17 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
"src",
"parameterMapping.teampkg",
"MyTeam.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject(super.getJavaProject(TEST_PROJECT));
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
_role = _typeDecl.getTypes()[0];
}
-
+
//test is for first calloutMapping in Testdata (Role)
public void testGetParameterMappings_notEmpty()
{
@@ -99,34 +99,34 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(4);
List mappings = calloutDecl.getParameterMappings();
-
+
assertNotNull("ParametermappingList should be not empty", mappings);
assertFalse(mappings.isEmpty());
- }
-
+ }
+
//test is for first calloutMapping in Testdata (Role)
public void testGetDirection()
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(0);
String actual = testObj.getDirection();
String expected = "->";
-
+
assertEquals("Wrong direction", expected, actual);
}
-
+
//test is for first calloutMapping in Testdata (Role)
public void testGetIdentifier()
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(0);
String actual = testObj.getIdentifier().getIdentifier();
String expected = "val";
-
+
assertEquals("Identifier is wrong", expected, actual);
}
@@ -135,43 +135,43 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(0);
Expression actual = (Expression)testObj.getExpression();
-
+
assertTrue(
- "Wrong Type of given expression, type is " + actual.getClass(),
+ "Wrong Type of given expression, type is " + actual.getClass(),
actual instanceof MethodInvocation);
- }
-
+ }
+
//test is for second calloutMapping in Testdata (Role)
public void testGetExpression_InstanceType2()
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(5);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(0);
Expression actual = (Expression)testObj.getExpression();
-
+
assertTrue(
- "Wrong Type of given expression, type is " + actual.getClass(),
+ "Wrong Type of given expression, type is " + actual.getClass(),
actual instanceof ClassInstanceCreation);
- }
+ }
//test is for fourth calloutMapping in Testdata (Role)
public void testGetExpression_InstanceType3()
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(7);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(0);
Expression actual = (Expression)testObj.getExpression();
-
+
assertTrue(
- "Wrong Type of given expression, type is " + actual.getClass(),
+ "Wrong Type of given expression, type is " + actual.getClass(),
actual instanceof SimpleName);
- }
-
+ }
+
//test is for third calloutMapping in Testdata (Role)
public void testValidMappingListSize()
{
@@ -187,10 +187,10 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(4);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(0);
boolean actual = testObj.hasResultFlag();
-
+
assertFalse("Mapping is a not a result mapping", actual);
}
@@ -199,11 +199,11 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(6);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
//test the second parameterMapping of this CalloutMappingDeclaration
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(1);
boolean actual = testObj.hasResultFlag();
-
+
assertTrue("Mapping is a result mapping, but was not detected", actual);
}
@@ -212,13 +212,13 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(7);
List parameterMappings = calloutDecl.getParameterMappings();
-
+
//test the third parameterMapping of this CalloutMappingDeclaration
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(2);
boolean actual = testObj.hasResultFlag();
-
+
assertTrue("Mapping is a result mapping, but was not detected", actual);
- }
+ }
//test is for fourth calloutMapping in Testdata (Role)
public void testValidMappingListSize1()
{
@@ -227,19 +227,19 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
int expected = 3;
assertEquals("ParameterMappingList has wrong size", expected, actual);
- }
-
+ }
+
//test is for fourth calloutMapping in Testdata (Role)
public void testSubTreeMatch()
{
CalloutMappingDeclaration calloutDecl = (CalloutMappingDeclaration)_role.bodyDeclarations().get(7);
List parameterMappings = calloutDecl.getParameterMappings();
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(2);
-
+
boolean actual = testObj.subtreeMatch(new ASTMatcher(), testObj);
assertTrue("Both nodes are equal, even the same.", actual);
- }
+ }
public void testCopySubtree()
{
@@ -247,7 +247,7 @@ public class ParameterMappingCalloutTest extends FileBasedDOMTest
List parameterMappings = calloutDecl.getParameterMappings();
ParameterMapping testObj = (ParameterMapping)parameterMappings.get(2);
- ParameterMapping clonedTestObject =
+ ParameterMapping clonedTestObject =
(ParameterMapping)ASTNode.copySubtree(AST.newAST(AST.JLS4), testObj);
boolean actual = testObj.subtreeMatch(new ASTMatcher(), clonedTestObject);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/PrecedenceDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/PrecedenceDeclarationTest.java
index 4a3e10967..828a3f55b 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/PrecedenceDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/PrecedenceDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -41,7 +41,7 @@ import org.eclipse.objectteams.otdt.ui.tests.dom.FileBasedDOMTest;
public class PrecedenceDeclarationTest extends FileBasedDOMTest
{
public static final String TEST_PROJECT = "DOM_AST";
-
+
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS9;
private ASTParser _parser;
@@ -55,12 +55,12 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(PrecedenceDeclarationTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -74,13 +74,13 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject( getJavaProject(TEST_PROJECT) );
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
_cu = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)_cu.types().get(0);
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
@@ -91,7 +91,7 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
List<?> precedences = role1.precedences();
assertFalse("precedences are non-null", precedences == null);
assertTrue("Role1 has 3 precedence lists", precedences.size() == 3);
-
+
PrecedenceDeclaration prec;
prec = (PrecedenceDeclaration)precedences.get(0);
List<?> elements = prec.elements();
@@ -122,7 +122,7 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
List<?> precedences = _typeDecl.precedences();
assertFalse("precedences are non-null", precedences == null);
assertTrue("Team2 has 2 precedence lists", precedences.size() == 2);
-
+
PrecedenceDeclaration prec;
prec = (PrecedenceDeclaration)precedences.get(0);
List<?> elements = prec.elements();
@@ -136,7 +136,7 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
List<?> precedences = _typeDecl.precedences();
assertFalse("precedences are non-null", precedences == null);
assertTrue("Team2 has 2 precedence lists", precedences.size() == 2);
-
+
PrecedenceDeclaration prec;
prec = (PrecedenceDeclaration)precedences.get(1);
List<?> elements = prec.elements();
@@ -145,13 +145,13 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
assertEquals("expecting element", elements.get(0).toString(), "Role2");
assertEquals("expecting element", elements.get(1).toString(), "Role1");
}
-
+
public void testPrecedenceFlattening() {
ASTRewriteFlattener _rewriteFlattener = new ASTRewriteFlattener(new RewriteEventStore());
_cu.accept(_rewriteFlattener);
String actual = _rewriteFlattener.getResult();
- String expected =
+ String expected =
"package precedences.teampkg;"+
"import precedences.basepkg.MyClass;"+
"public team class Team1 {"+
@@ -170,11 +170,11 @@ public class PrecedenceDeclarationTest extends FileBasedDOMTest
"precedence callin3, callin2;" +
"precedence after callinA3, callinA2;"+
"}"+
- "public class Role2 {}"+
+ "public class Role2 {}"+
"precedence Role1.callin2, Role1.callin1;"+
"precedence Role2, Role1;"+
"}";
-
+
assertEquals("Wrong CU-Code", expected, actual);
}
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/RoleTypeDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/RoleTypeDeclarationTest.java
index 40792f820..3b3bc9c86 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/RoleTypeDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/RoleTypeDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -47,31 +47,31 @@ public class RoleTypeDeclarationTest extends FileBasedDOMTest
{
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
-
+
private ASTParser _parser;
private ICompilationUnit _simpleTeam;
private TypeDeclaration _typeDecl;
private TypeDeclaration _testObj1;
- private TypeDeclaration _testObj2;
- private TypeDeclaration _testObj3;
-
- public RoleTypeDeclarationTest(String name)
+ private TypeDeclaration _testObj2;
+ private TypeDeclaration _testObj3;
+
+ public RoleTypeDeclarationTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(RoleTypeDeclarationTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
super.setUpSuite();
}
-
- protected void setUp() throws Exception
+
+ protected void setUp() throws Exception
{
super.setUp();
_simpleTeam = getCompilationUnit(
@@ -79,11 +79,11 @@ public class RoleTypeDeclarationTest extends FileBasedDOMTest
"src",
"roleTypeDeclaration.teampkg",
"MyTeam.java");
-
+
_parser = ASTParser.newParser(JAVA_LANGUAGE_SPEC_LEVEL);
_parser.setProject(super.getJavaProject(TEST_PROJECT));
_parser.setSource(_simpleTeam);
-
+
ASTNode root = _parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
@@ -91,102 +91,102 @@ public class RoleTypeDeclarationTest extends FileBasedDOMTest
_testObj2 = _typeDecl.getTypes()[1];
_testObj3 = _typeDecl.getTypes()[2];
}
-
+
public void testInstanceTypes()
{
assertTrue("First role was not detected as RoleTypeDeclaration",_testObj1 instanceof RoleTypeDeclaration);
assertTrue("Second role was not detected as RoleTypeDeclaration",_testObj2 instanceof RoleTypeDeclaration);
assertTrue("Third role was not detected as RoleTypeDeclaration",_testObj3 instanceof RoleTypeDeclaration);
}
-
+
//test for first Role in roleTypeDeclaration.teampkg.MyTeam
public void testIsTeam1()
{
boolean actual = _testObj1.isTeam();
-
+
assertFalse("This RoleTypeDeclaration is not a Team.", actual);
}
-
- //test for second Role in roleTypeDeclaration.teampkg.MyTeam
+
+ //test for second Role in roleTypeDeclaration.teampkg.MyTeam
public void testIsTeam2()
{
boolean actual = _testObj2.isTeam();
-
+
assertTrue("This RoleTypeDeclaration is a Team.", actual);
}
-
- //test for third Role in roleTypeDeclaration.teampkg.MyTeam
+
+ //test for third Role in roleTypeDeclaration.teampkg.MyTeam
public void testIsTeam3()
{
boolean actual = _testObj3.isTeam();
-
+
assertFalse("This RoleTypeDeclaration is not a Team.", actual);
- }
-
-
+ }
+
+
//test for first Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetBase1_notNull()
{
Type baseClass = ((RoleTypeDeclaration)_testObj1).getBaseClassType();
-
+
assertNotNull("RoleTypeDeclaration !!!has!!! a BaseClass.", baseClass);
}
-
- //test for second Role in roleTypeDeclaration.teampkg.MyTeam
+
+ //test for second Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetBase2_notNull()
{
Type baseClass = ((RoleTypeDeclaration)_testObj2).getBaseClassType();
-
+
assertNotNull("RoleTypeDeclaration !!!has!!! a BaseClass.", baseClass);
}
-
- //test for third Role in roleTypeDeclaration.teampkg.MyTeam
+
+ //test for third Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetBase3_Null()
{
Type baseClass = ((RoleTypeDeclaration)_testObj3).getBaseClassType();
-
+
assertNull("RoleTypeDeclaration !!!hasn't!!! a BaseClass.", baseClass);
- }
-
+ }
+
//test for first Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetTeam1_notNull()
{
Type teamClass = ((RoleTypeDeclaration)_testObj1).getTeamClassType();
-
+
assertNotNull("RoleTypeDeclaration !!!has!!! a TeamClass.", teamClass);
}
-
- //test for second Role in roleTypeDeclaration.teampkg.MyTeam
+
+ //test for second Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetTeam2_notNull()
{
Type teamClass = ((RoleTypeDeclaration)_testObj2).getTeamClassType();
-
+
assertNotNull("RoleTypeDeclaration !!!has!!! a TeamClass.", teamClass);
}
-
- //test for third Role in roleTypeDeclaration.teampkg.MyTeam
+
+ //test for third Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetTeam3_notNull()
{
Type teamClass = ((RoleTypeDeclaration)_testObj3).getTeamClassType();
-
+
assertNotNull("RoleTypeDeclaration !!!hasn't!!! a TeamClass.", teamClass);
- }
+ }
//test for first Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetCallOuts1_notEmpty()
{
CalloutMappingDeclaration[] callouts = ((RoleTypeDeclaration)_testObj1).getCallOuts();
- boolean isEmpty = callouts.length == 0;
-
+ boolean isEmpty = callouts.length == 0;
+
assertFalse("List of CalloutMappingDeclaration isn't empty", isEmpty);
}
-
+
//test for third Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetCallOuts3_isEmpty()
{
CalloutMappingDeclaration[] callouts = ((RoleTypeDeclaration)_testObj3).getCallOuts();
- boolean isEmpty = callouts.length == 0;
-
+ boolean isEmpty = callouts.length == 0;
+
assertTrue("List of CalloutMappingDeclaration is empty", isEmpty);
}
@@ -194,17 +194,17 @@ public class RoleTypeDeclarationTest extends FileBasedDOMTest
public void testGetCallIns2_notEmpty()
{
CallinMappingDeclaration[] callins = ((RoleTypeDeclaration)_testObj2).getCallIns();
- boolean isEmpty = callins.length == 0;
-
+ boolean isEmpty = callins.length == 0;
+
assertFalse("List of CallinMappingDeclaration isn't empty", isEmpty);
}
-
+
//test for third Role in roleTypeDeclaration.teampkg.MyTeam
public void testGetCallIns3_isEmpty()
{
CallinMappingDeclaration[] callins = ((RoleTypeDeclaration)_testObj3).getCallIns();
- boolean isEmpty = callins.length == 0;
-
+ boolean isEmpty = callins.length == 0;
+
assertTrue("List of CallinMappingDeclaration is empty", isEmpty);
}
@@ -213,15 +213,15 @@ public class RoleTypeDeclarationTest extends FileBasedDOMTest
boolean actual = _testObj1.subtreeMatch(new ASTMatcher(), _testObj1);
assertTrue("Both nodes are equal, even the same.", actual);
- }
-
+ }
+
public void testCopySubtree1()
{
- RoleTypeDeclaration clonedTestObject =
+ RoleTypeDeclaration clonedTestObject =
(RoleTypeDeclaration)ASTNode.copySubtree(AST.newAST(AST.JLS4), _testObj1);
boolean actual = _testObj1.subtreeMatch(new ASTMatcher(), clonedTestObject);
-
+
assertTrue("Copy of subtree not correct", actual);
}
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperConstructorInvocationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperConstructorInvocationTest.java
index 4476d0c45..f5a588ecf 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperConstructorInvocationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperConstructorInvocationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -60,20 +60,20 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
private MethodDeclaration _constructor1;
private Statement _tsuper0;
private Statement _tsuper1;
-
-
+
+
private TSuperConstructorInvocation _testObj;
public TSuperConstructorInvocationTest(String name)
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(TSuperConstructorInvocationTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -87,8 +87,8 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
parser.setProject( getJavaProject(TEST_PROJECT) );
parser.setSource(_teamClass);
parser.setResolveBindings(true);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
@@ -100,12 +100,12 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
-
+
public void testInstanceType1()
{
assertTrue("tsuper call not an instance of TSuperConstructorInvocation",
@@ -121,21 +121,21 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
public void testNodeType1()
{
_testObj = (TSuperConstructorInvocation)_tsuper1;
-
+
int actual = _testObj.getNodeType();
-
+
assertEquals("tsuper call has wrong node type",
ASTNode.TSUPER_CONSTRUCTOR_INVOCATION,
actual);
}
-
+
public void testGetArguments2_TwoArgs()
{
_testObj = (TSuperConstructorInvocation)_tsuper1;
-
+
List actual = _testObj.getArguments();
-
+
assertEquals("tsuper call has wrong number of arguments",
2,
actual.size());
@@ -144,9 +144,9 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
public void testGetArguments1_NoArgs()
{
_testObj = (TSuperConstructorInvocation)_tsuper0;
-
+
List actual = _testObj.getArguments();
-
+
assertEquals("tsuper call has wrong number of arguments",
0,
actual.size());
@@ -155,10 +155,10 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
public void testChildNodesHaveCorrectParent1()
{
_testObj = (TSuperConstructorInvocation)_tsuper1;
-
+
List childNodes = _testObj.getArguments();
- for (Iterator iter = childNodes.iterator(); iter.hasNext();)
+ for (Iterator iter = childNodes.iterator(); iter.hasNext();)
{
Expression curChild = (Expression) iter.next();
assertEquals("tsuper call arguments have wrong parent node",
@@ -167,34 +167,34 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
}
}
-
+
public void testSubtreeMatch1()
{
_testObj = (TSuperConstructorInvocation)_tsuper1;
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
assertTrue("tsuper call message sends don't match", actual);
-
+
}
public void testToString1()
{
_testObj = (TSuperConstructorInvocation)_tsuper1;
-
+
String actual = _testObj.toString();
String expected = "tsuper(arg0, arg1)";
-
+
assertEquals(
"tsuper call message send: wrong naive flat string representation",
- expected,
+ expected,
actual);
}
-
+
public void testResolveBinding()
{
_testObj = (TSuperConstructorInvocation)_tsuper1;
-
+
ITypeBinding itb = _typeDecl.resolveBinding();
ITypeBinding tsuperRoleClass = null;
for (ITypeBinding role : itb.getSuperclass().getDeclaredTypes()) {
@@ -206,11 +206,11 @@ public class TSuperConstructorInvocationTest extends FileBasedDOMTest
assertNotNull("tsuper Role not found", tsuperRoleClass);
IMethodBinding tSuperConstructor =
tsuperRoleClass.getDeclaredMethods()[1];
-
+
IMethodBinding expected = tSuperConstructor;
IMethodBinding actual = _testObj.resolveConstructorBinding();
assertEquals(expected, actual);
}
-
-
+
+
} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperMessageSendTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperMessageSendTest.java
index c420dc957..08ad67146 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperMessageSendTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/TSuperMessageSendTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -65,12 +65,12 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(TSuperMessageSendTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -84,8 +84,8 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
parser.setProject( getJavaProject(TEST_PROJECT) );
parser.setSource(_teamClass);
parser.setResolveBindings(true);
-
- ASTNode root = parser.createAST( new NullProgressMonitor() );
+
+ ASTNode root = parser.createAST( new NullProgressMonitor() );
CompilationUnit compUnit = (CompilationUnit) root;
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
_role = _typeDecl.getTypes()[0];
@@ -93,19 +93,19 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
_roleMethod1 = _role.getMethods()[3];
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
-
+
public void testInstanceType1()
{
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod0.getBody().statements().get(0);
Expression testObj = exprStatement.getExpression();
-
+
assertTrue("tsuper call not an instance of TSuperMessageSend",
testObj instanceof TSuperMessageSend);
}
@@ -116,7 +116,7 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
Expression testObj = exprStatement.getExpression();
-
+
assertTrue("tsuper call not an instance of TSuperMessageSend",
testObj instanceof TSuperMessageSend);
}
@@ -126,9 +126,9 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod0.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
int actual = _testObj.getNodeType();
-
+
assertEquals("tsuper call has wrong node type",
ASTNode.TSUPER_MESSAGE_SEND,
actual);
@@ -141,20 +141,20 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
_testObj = (TSuperMessageSend)exprStatement.getExpression();
String actual = _testObj.getName().getIdentifier();
-
+
assertEquals("tsuper call has wrong name ",
"method0",
actual);
}
-
+
public void testGetArguments2_TwoArgs()
{
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
List actual = _testObj.getArguments();
-
+
assertEquals("tsuper call has wrong number of arguments",
2,
actual.size());
@@ -165,9 +165,9 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod0.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
List actual = _testObj.getArguments();
-
+
assertEquals("tsuper call has wrong number of arguments",
0,
actual.size());
@@ -178,10 +178,10 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
List childNodes = _testObj.getArguments();
- for (Iterator iter = childNodes.iterator(); iter.hasNext();)
+ for (Iterator iter = childNodes.iterator(); iter.hasNext();)
{
Expression curChild = (Expression) iter.next();
assertEquals("tsuper call arguments have wrong parent node",
@@ -190,15 +190,15 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
}
}
-
+
public void testChidlNodeHaveCorrectParrent2()
{
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
SimpleName childNode = _testObj.getName();
-
+
assertEquals("tsuper call selector has wrong parent",
_testObj,
childNode.getParent());
@@ -209,11 +209,11 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
boolean actual = _testObj.subtreeMatch(new ASTMatcher(), _testObj);
assertTrue("tsuper call message sends don't match", actual);
-
+
}
public void testToString1()
@@ -221,21 +221,21 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
String actual = _testObj.toString();
String expected = "tsuper.method1(arg0, arg1)";
-
+
assertEquals("tsuper call message send: wrong naive flat string representation",
expected, actual);
}
-
+
public void testResolveBinding()
{
ExpressionStatement exprStatement =
(ExpressionStatement)_roleMethod1.getBody().statements().get(0);
-
+
_testObj = (TSuperMessageSend)exprStatement.getExpression();
-
+
ITypeBinding itb = _typeDecl.resolveBinding();
IMethodBinding expected = null;
// don't access method via index since bindings are sorted by the compiler
@@ -247,17 +247,17 @@ public class TSuperMessageSendTest extends FileBasedDOMTest
}
}
assertNotNull("tsuper Role not found", tsuperRoleClass);
- for (IMethodBinding tSuperMethod: tsuperRoleClass.getDeclaredMethods())
+ for (IMethodBinding tSuperMethod: tsuperRoleClass.getDeclaredMethods())
{
if (tSuperMethod.getName().equals("method1")) {
expected = tSuperMethod;
break;
- }
+ }
}
-
+
IMethodBinding actual = _testObj.resolveMethodBinding();
-
+
assertEquals(expected, actual);
}
-
+
} \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/WithinStatementTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/WithinStatementTest.java
index b8295082c..279ee0ac1 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/WithinStatementTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/converter/WithinStatementTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -62,12 +62,12 @@ public class WithinStatementTest extends FileBasedDOMTest
{
super(name);
}
-
+
public static Test suite()
{
return new Suite(WithinStatementTest.class);
}
-
+
public void setUpSuite() throws Exception
{
setTestProjectDir(TEST_PROJECT);
@@ -87,7 +87,7 @@ public class WithinStatementTest extends FileBasedDOMTest
_typeDecl = (TypeDeclaration)compUnit.types().get(0);
}
- protected void setUp() throws Exception
+ protected void setUp() throws Exception
{
super.setUp();
}
@@ -99,28 +99,28 @@ public class WithinStatementTest extends FileBasedDOMTest
WithinStatementTest.getMethodDeclarationByName(_typeDecl,
"withinSimple");
List statements = methodDecl.getBody().statements();
-
+
Statement testObj = (Statement) statements.get(0);
assertTrue("Statement is not an instance of WithinStatement",
testObj instanceof WithinStatement);
}
-
+
public void testGetNodeType()
{
MethodDeclaration methodDecl =
WithinStatementTest.getMethodDeclarationByName(_typeDecl,
"withinSimple");
List statements = methodDecl.getBody().statements();
-
+
_testObj = (WithinStatement) statements.get(0);
-
+
assertEquals(
"WithinStatement has wrong NodeType",
- ASTNode.WITHIN_STATEMENT,
+ ASTNode.WITHIN_STATEMENT,
_testObj.getNodeType());
}
-
+
public void testGetBody_Empty()
{
MethodDeclaration methodDecl =
@@ -128,14 +128,14 @@ public class WithinStatementTest extends FileBasedDOMTest
"withinSimpleEmptyBody");
List statements = methodDecl.getBody().statements();
Statement firstStatement = (Statement) statements.get(0);
-
+
_testObj = (WithinStatement) firstStatement;
assertTrue(
"withing: body block is not empty",
((Block)_testObj.getBody()).statements().isEmpty());
}
-
+
public void testGetBody_NotEmpty()
{
MethodDeclaration methodDecl =
@@ -149,7 +149,7 @@ public class WithinStatementTest extends FileBasedDOMTest
assertEquals("within: body block is empty",
1, ((Block)_testObj.getBody()).statements().size());
}
-
+
public void testBody_ParentIdentity()
{
MethodDeclaration methodDecl = WithinStatementTest.getMethodDeclarationByName(_typeDecl, "withinSimple");
@@ -159,11 +159,11 @@ public class WithinStatementTest extends FileBasedDOMTest
_testObj = (WithinStatement) firstStatement;
Block body = (Block)_testObj.getBody();
ASTNode bodyParent = body.getParent();
-
+
assertTrue("within: ", _testObj == bodyParent );
-
+
}
-
+
/** Tests if body belong to the same AST as the within statement */
public void testBody_ASTIdentity()
{
@@ -175,7 +175,7 @@ public class WithinStatementTest extends FileBasedDOMTest
Block body = (Block)_testObj.getBody();
assertTrue(
- "within: body (Block) doesn't belong to AST",
+ "within: body (Block) doesn't belong to AST",
_testObj.getAST() == body.getAST() );
}
@@ -218,7 +218,7 @@ public class WithinStatementTest extends FileBasedDOMTest
assertTrue("within: Team expression is not a ClassInstanceCreation",
_testObj.getTeamExpression() instanceof ClassInstanceCreation);
}
-
+
public void testGetTeamExpression2_InstanceType()
{
MethodDeclaration methodDecl = WithinStatementTest.getMethodDeclarationByName(_typeDecl, "withinSimple");
@@ -238,11 +238,11 @@ public class WithinStatementTest extends FileBasedDOMTest
Statement firstStatement = (Statement)statements.get(0);
_testObj = (WithinStatement) firstStatement;
-
+
assertTrue("within: Team expression is not a SimpleName",
_testObj.getTeamExpression() instanceof MethodInvocation);
}
-
+
public void testGetTeamExpression_Parent()
{
MethodDeclaration methodDecl = WithinStatementTest.getMethodDeclarationByName(_typeDecl, "withinNewTeam");
@@ -264,11 +264,11 @@ public class WithinStatementTest extends FileBasedDOMTest
_testObj = (WithinStatement) firstStatement;
ClassInstanceCreation teamExpression = (ClassInstanceCreation)_testObj.getTeamExpression();
-
+
assertEquals("within: Team expression is not a SimpleName",
"new Team1()", teamExpression.toString());
}
-
+
public void testGetTeamExpression_Identifier2()
{
MethodDeclaration methodDecl = WithinStatementTest.getMethodDeclarationByName(_typeDecl, "withinSimple");
@@ -277,7 +277,7 @@ public class WithinStatementTest extends FileBasedDOMTest
_testObj = (WithinStatement) firstStatement;
SimpleName teamExpression = (SimpleName)_testObj.getTeamExpression();
-
+
assertEquals("within: Team expression is not a SimpleName",
"myTeam", teamExpression.toString());
}
@@ -291,17 +291,17 @@ public class WithinStatementTest extends FileBasedDOMTest
_testObj = (WithinStatement) statements.get(0);
String actual = _testObj.toString();
- String expected =
+ String expected =
"within(new Team1()) {\n"+
" foo();\n"+
"}\n";
-
+
assertEquals(
"within statement: wrong naive flat string representation",
- expected,
+ expected,
actual);
}
-
+
public void testSubtreeMatch1()
{
MethodDeclaration methodDecl = WithinStatementTest.getMethodDeclarationByName(_typeDecl, "withinNewTeam");
@@ -313,32 +313,32 @@ public class WithinStatementTest extends FileBasedDOMTest
assertTrue("Within statements don't match", actual);
}
-
+
/**
* Helper method to find the named MethodDeclaration
* in the given TypeDeclaration.
- *
+ *
* @return the found MethodDeclaration or null
*/
private static MethodDeclaration getMethodDeclarationByName(TypeDeclaration type, String name)
{
MethodDeclaration[] methods = type.getMethods();
int numberOfMethods = methods.length;
-
+
if (numberOfMethods == 0)
{
return null;
}
-
+
for (int idx = 0; idx < numberOfMethods; idx++)
{
if (name.equals(methods[idx].getName().getIdentifier()))
{
return methods[idx];
}
-
+
}
-
+
return null; // method not found
};
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewriteFlattenerTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewriteFlattenerTest.java
index fe0454d4d..9838ed74c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewriteFlattenerTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewriteFlattenerTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -57,422 +57,422 @@ import org.eclipse.jdt.internal.core.dom.rewrite.RewriteEventStore;
* @author ikeman
*/
public class ASTRewriteFlattenerTest extends TestCase {
-
+
public static final String TEST_PROJECT = "DOM_AST";
private static final int JAVA_LANGUAGE_SPEC_LEVEL = AST.JLS4;
-
-
+
+
private ASTRewriteFlattener _rewriteFlattener;
private AST _newAst;
private RewriteEventStore _store;
-
+
public ASTRewriteFlattenerTest(String name)
{
super(name);
}
-
- protected void setUp() throws Exception
+
+ protected void setUp() throws Exception
{
super.setUp();
_store = new RewriteEventStore();
_rewriteFlattener = new ASTRewriteFlattener(_store);
_newAst = AST.newAST(JAVA_LANGUAGE_SPEC_LEVEL);
}
-
+
public void testNewCuCreation()
{
PackageDeclaration newPack = _newAst.newPackageDeclaration();
newPack.setName(_newAst.newQualifiedName(_newAst.newSimpleName("testmain"), _newAst.newSimpleName("testsub")));
-
+
ImportDeclaration newImport = _newAst.newImportDeclaration();
newImport.setName(_newAst.newQualifiedName(_newAst.newSimpleName("testpackage"), _newAst.newSimpleName("TestClass")));
newImport.setOnDemand(false);
List importList = new ArrayList();
importList.add(newImport);
-
+
CompilationUnit newCU = createCU(newPack, importList, null);
-
+
newCU.accept(_rewriteFlattener);
String actual = _rewriteFlattener.getResult();
String expected = "package testmain.testsub;import testpackage.TestClass;";
-
+
assertEquals("Wrong CU-Code", expected, actual);
}
public void testNewTeamCreation()
{
- TypeDeclaration newTypeDecl = createTeam(null, (Modifier.PUBLIC | Modifier.OT_TEAM),
- false, false, "GeneratedClass", null, null, null);
-
+ TypeDeclaration newTypeDecl = createTeam(null, (Modifier.PUBLIC | Modifier.OT_TEAM),
+ false, false, "GeneratedClass", null, null, null);
+
newTypeDecl.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "public team class GeneratedClass {}";
-
+
assertEquals("Wrong TeamCode", expected, actual);
}
-
+
public void testNewRoleCreation()
{
-
- RoleTypeDeclaration role = createRole(null, 1, "GeneratedRoleClass", "GeneratedBaseClass",
+
+ RoleTypeDeclaration role = createRole(null, 1, "GeneratedRoleClass", "GeneratedBaseClass",
"GeneratedTeamClass", null, null , false, null);
-
+
role.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "public class GeneratedRoleClass playedBy GeneratedBaseClass {}";
-
+
assertEquals("Wrong RoleCode", expected, actual);
}
public void testNewParameterMappingCreation()
{
MethodInvocation methodInv = (MethodInvocation)createExpression("integer", "intValue");
- ParameterMapping newParameterMapping =
+ ParameterMapping newParameterMapping =
createParameterMapping(methodInv, "value", "->", false);
newParameterMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "integer.intValue() -> value";
-
+
assertEquals("Wrong ParameterMappingCode", expected, actual);
}
-
+
public void testNewParameterMappingCreation1()
{
SimpleName argumentName = _newAst.newSimpleName("val");
List arguments = new ArrayList();
arguments.add(argumentName);
-
+
ClassInstanceCreation cIC = (ClassInstanceCreation)createExpression(null,"Integer", arguments, null);
- ParameterMapping newParameterMapping =
+ ParameterMapping newParameterMapping =
createParameterMapping(cIC, "integer", "->",false);
newParameterMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "new Integer(val) -> integer";
-
+
assertEquals("Wrong ParameterMappingCode", expected, actual);
}
public void testNewCalloutMappingCreation()
{
//Callout - roleMethodSpec - Parameter
- SingleVariableDeclaration roleMethodSpecParameter =
+ SingleVariableDeclaration roleMethodSpecParameter =
createMethodParameter(0, "Integer", null, "integer", 0, null);
List roleMethodParameters = new ArrayList();
roleMethodParameters.add(roleMethodSpecParameter);
-
+
//Callout - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("roleMethod0", PrimitiveType.VOID, roleMethodParameters, true);
-
+
//Callout - baseMethodSpec - Parameter
- SingleVariableDeclaration baseMethodSpecParameter =
+ SingleVariableDeclaration baseMethodSpecParameter =
createMethodParameter(0, null, PrimitiveType.INT, "value", 0, null);
List baseMethodParameters = new ArrayList();
baseMethodParameters.add(baseMethodSpecParameter);
-
+
//Callout - baseMethodSpec
MethodSpec baseMethodSpec = createMethodSpec("baseMethod0", PrimitiveType.VOID, baseMethodParameters, true);
-
- //Callout - ParameterMapping
+
+ //Callout - ParameterMapping
MethodInvocation methodInv = (MethodInvocation)createExpression("integer", "intValue");
- ParameterMapping newParameterMapping =
+ ParameterMapping newParameterMapping =
createParameterMapping(methodInv, "value", "->", false);
List parameterMappingList = new ArrayList();
parameterMappingList.add(newParameterMapping);
-
+
//build CalloutMapping
CalloutMappingDeclaration newCalloutMapping = createCalloutMapping(null, 0, roleMethodSpec, baseMethodSpec, parameterMappingList, false, true);
-
+
newCalloutMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
- String expected =
+ String expected =
"void roleMethod0(Integer integer) -> void baseMethod0(int value) with {\n" +
" integer.intValue() -> value\n" +
"}";
-
+
assertEquals("Wrong CalloutMappingCode", expected, actual);
}
-
+
public void testNewCalloutMappingCreation1()
{
//Callout - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("roleMethod3", PrimitiveType.INT, null, false);
-
+
//Callout - baseMethodSpec(s)
MethodSpec baseMethodSpec = createMethodSpec("baseMethod3", PrimitiveType.INT, null, false);
//build CalloutMapping
CalloutMappingDeclaration newCalloutMapping = createCalloutMapping(null, 0, roleMethodSpec, baseMethodSpec, null, false, false);
-
+
newCalloutMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "roleMethod3 -> baseMethod3;";
-
+
assertEquals("Wrong CalloutMappingCode", expected, actual);
}
-
+
public void testNewCalloutMappingCreation2()
{
//Callout - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("getTestString", PrimitiveType.VOID, null, false);
-
+
//Callout - baseMethodSpec
FieldAccessSpec newFieldAcc = createFieldAccSpec("_string", PrimitiveType.VOID, null, false);
-
+
//build CalloutMapping
CalloutMappingDeclaration newCalloutMapping = createCalloutMapping(null, 0, roleMethodSpec, newFieldAcc, null, false, false);
newCalloutMapping.bindingOperator().setBindingModifier(Modifier.OT_GET_CALLOUT);
-
+
newCalloutMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "getTestString -> get _string;";
-
+
assertEquals("Wrong CalloutMappingCode", expected, actual);
- }
-
+ }
+
public void testNewCalloutMappingCreation3()
{
//Callout - roleMethodSpec - Parameter
- SingleVariableDeclaration roleMethodSpecParameter =
+ SingleVariableDeclaration roleMethodSpecParameter =
createMethodParameter(0, "Integer", null, "i", 0, null);
List roleMethodParameters = new ArrayList();
roleMethodParameters.add(roleMethodSpecParameter);
-
-
+
+
//Callout - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("setTestInteger", PrimitiveType.VOID, roleMethodParameters, true);
-
+
//Callout - baseMethodSpec
FieldAccessSpec newFieldAcc = createFieldAccSpec("_integer", null, "Integer", true);
-
+
//build CalloutMapping
CalloutMappingDeclaration newCalloutMapping = createCalloutMapping(null, 0, roleMethodSpec, newFieldAcc, null, false, true);
newCalloutMapping.bindingOperator().setBindingModifier(Modifier.OT_SET_CALLOUT);
-
+
newCalloutMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "void setTestInteger(Integer i) -> set Integer _integer;";
-
+
assertEquals("Wrong CalloutMappingCode", expected, actual);
}
-
+
public void testNewCallinMappingCreation()
{
int callinMappingModifier = Modifier.OT_REPLACE_CALLIN;
-
+
//Callin - roleMethodSpec - Parameter
- SingleVariableDeclaration roleMethodSpecParameter =
+ SingleVariableDeclaration roleMethodSpecParameter =
createMethodParameter(0, "Integer", null, "roleInteger", 0, null);
List roleMethodParameters = new ArrayList();
roleMethodParameters.add(roleMethodSpecParameter);
-
+
//Callin - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("roleMethod1", PrimitiveType.INT, roleMethodParameters, true);
-
+
//Callin - baseMethodSpec - Parameter
- SingleVariableDeclaration baseMethodSpecParameter =
+ SingleVariableDeclaration baseMethodSpecParameter =
createMethodParameter(0, "Integer", null, "integer", 0, null);
List baseMethodParameters = new ArrayList();
baseMethodParameters.add(baseMethodSpecParameter);
-
+
//Callin - baseMethodSpec(s)
MethodSpec baseMethodSpec = createMethodSpec("baseMethod1", PrimitiveType.INT, baseMethodParameters, true);
List baseMethods = new ArrayList();
baseMethods.add(baseMethodSpec);
-
+
//Callin - ParameterMapping
SimpleName expressionName1 = (SimpleName)createExpression("integer");
- ParameterMapping newParameterMappingInt =
+ ParameterMapping newParameterMappingInt =
createParameterMapping(expressionName1, "roleInteger", "<-", false);
-
+
SimpleName expressionName2 = (SimpleName)createExpression("result");
- ParameterMapping newParameterMappingRes =
+ ParameterMapping newParameterMappingRes =
createParameterMapping(expressionName2, "result", "->", true);
List paramMappings = new ArrayList();
paramMappings.add(newParameterMappingInt);
paramMappings.add(newParameterMappingRes);
-
+
//build CallinMapping
CallinMappingDeclaration newCallinMapping = createCallinMappingDeclaration(null, callinMappingModifier, roleMethodSpec, baseMethods, paramMappings);
-
+
newCallinMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
- String expected =
+ String expected =
"int roleMethod1(Integer roleInteger) <- replace int baseMethod1(Integer integer) with {\n"+
- " roleInteger <- integer,\n"+
+ " roleInteger <- integer,\n"+
" result -> result\n" +
"}";
-
+
assertEquals("Wrong CallinMappingCode", expected, actual);
}
-
+
public void testNewCallinMappingCreation1()
{
//Callin - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("roleMethod2", PrimitiveType.INT, null, false);
-
+
//Callin - baseMethodSpec(s)
MethodSpec baseMethodSpec = createMethodSpec("baseMethod2", PrimitiveType.INT, null, false);
List baseMethods = new ArrayList();
baseMethods.add(baseMethodSpec);
-
+
//build CallinMapping
CallinMappingDeclaration newCallinMapping = createCallinMappingDeclaration(null, Modifier.OT_BEFORE_CALLIN, roleMethodSpec, baseMethods, null);
-
+
newCallinMapping.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "roleMethod2 <- before baseMethod2;";
-
+
assertEquals("Wrong CallinMappingCode", expected, actual);
}
-
+
public void testNewFieldAccSpecCreation()
{
FieldAccessSpec newFieldAcc = createFieldAccSpec("_string", PrimitiveType.VOID, null, false);
-
+
newFieldAcc.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "_string";
-
+
assertEquals("Wrong FieldAccSpecCode", expected, actual);
}
-
+
public void testNewFieldAccSpecCreation1()
{
FieldAccessSpec newFieldAcc = createFieldAccSpec("_integer", null,"Integer", true);
-
+
newFieldAcc.accept(_rewriteFlattener);
-
+
String actual = _rewriteFlattener.getResult();
String expected = "Integer _integer";
-
+
assertEquals("Wrong FieldAccSpecCode", expected, actual);
}
-
+
public void testNewFullyCuCreation()
{
PackageDeclaration newPack = _newAst.newPackageDeclaration();
newPack.setName(_newAst.newQualifiedName(_newAst.newSimpleName("testmain"), _newAst.newSimpleName("testsub")));
-
+
ImportDeclaration newImport = _newAst.newImportDeclaration();
newImport.setName(_newAst.newQualifiedName(_newAst.newSimpleName("testpackage"), _newAst.newSimpleName("TestClass")));
newImport.setOnDemand(false);
List importList = new ArrayList();
importList.add(newImport);
-
-
+
+
int callinMappingModifier = Modifier.OT_REPLACE_CALLIN;
-
+
//Callin - roleMethodSpec - Parameter
- SingleVariableDeclaration roleMethodSpecParameter =
+ SingleVariableDeclaration roleMethodSpecParameter =
createMethodParameter(0, "Integer", null, "roleInteger", 0, null);
List roleMethodParameters = new ArrayList();
roleMethodParameters.add(roleMethodSpecParameter);
-
+
//Callin - roleMethodSpec
MethodSpec roleMethodSpec = createMethodSpec("roleMethod1", PrimitiveType.INT, roleMethodParameters, true);
-
+
//Callin - baseMethodSpec - Parameter
- SingleVariableDeclaration baseMethodSpecParameter =
+ SingleVariableDeclaration baseMethodSpecParameter =
createMethodParameter(0, "Integer", null, "integer", 0, null);
List baseMethodParameters = new ArrayList();
baseMethodParameters.add(baseMethodSpecParameter);
-
+
//Callin - baseMethodSpec(s)
MethodSpec baseMethodSpec = createMethodSpec("baseMethod1", PrimitiveType.INT, baseMethodParameters, true);
List baseMethods = new ArrayList();
baseMethods.add(baseMethodSpec);
-
+
//Callin - ParameterMapping
SimpleName expressionName1 = (SimpleName)createExpression("integer");
- ParameterMapping newParameterMappingInt =
+ ParameterMapping newParameterMappingInt =
createParameterMapping(expressionName1, "roleInteger", "<-", false);
-
+
SimpleName expressionName2 = (SimpleName)createExpression("result");
- ParameterMapping newParameterMappingRes =
+ ParameterMapping newParameterMappingRes =
createParameterMapping(expressionName2, "result", "->", true);
List paramMappings = new ArrayList();
paramMappings.add(newParameterMappingInt);
paramMappings.add(newParameterMappingRes);
-
+
//build CallinMapping
CallinMappingDeclaration newCallinMapping = createCallinMappingDeclaration(null, callinMappingModifier, roleMethodSpec, baseMethods, paramMappings);
List roleBodyDecl = new ArrayList();
roleBodyDecl.add(newCallinMapping);
-
- RoleTypeDeclaration role = createRole(null, 1, "GeneratedRoleClass", "GeneratedBaseClass",
+
+ RoleTypeDeclaration role = createRole(null, 1, "GeneratedRoleClass", "GeneratedBaseClass",
"GeneratedTeamClass", null, null , false, roleBodyDecl);
List typeBodyDecl = new ArrayList();
typeBodyDecl.add(role);
-
- TypeDeclaration newTypeDecl = createTeam(null, (Modifier.PUBLIC | Modifier.OT_TEAM),
+
+ TypeDeclaration newTypeDecl = createTeam(null, (Modifier.PUBLIC | Modifier.OT_TEAM),
false, false, "GeneratedClass", null, null, typeBodyDecl);
List typeList = new ArrayList();
typeList.add(newTypeDecl);
CompilationUnit newCU = createCU(newPack, importList, typeList);
-
+
newCU.accept(_rewriteFlattener);
String cUString ="package testmain.testsub;import testpackage.TestClass;public team class GeneratedClass {";
String roleString = "public class GeneratedRoleClass playedBy GeneratedBaseClass {";
String bodyDeclString = "int roleMethod1(Integer roleInteger) <- replace int baseMethod1(Integer integer)";
- String paramMappingString =
+ String paramMappingString =
" with {\n" +
" roleInteger <- integer,\n" +
" result -> result\n" +
"}}}";
-
+
String actual = _rewriteFlattener.getResult();
String expected = cUString + roleString + bodyDeclString + paramMappingString;
-
+
assertEquals("Wrong CU-Code", expected, actual);
}
-
-
+
+
// form here there are only HELPER - METHODS
-
+
private CompilationUnit createCU(PackageDeclaration pack, List importList, List typeList)
{
CompilationUnit newCU = _newAst.newCompilationUnit();
-
+
if (pack != null)
newCU.setPackage(pack);
-
+
if (importList != null && importList.size()!= 0)
{
List cuImportList = newCU.imports();
for (int idx = 0; idx < importList.size(); idx++)
{
ImportDeclaration tmp = (ImportDeclaration)importList.get(idx);
- cuImportList.add(tmp);
+ cuImportList.add(tmp);
}
}
-
+
if (typeList != null && typeList.size()!= 0)
{
List cuTypeList = newCU.types();
for (int idx = 0; idx < typeList.size(); idx++)
{
TypeDeclaration tmp = (TypeDeclaration)typeList.get(idx);
- cuTypeList.add(tmp);
+ cuTypeList.add(tmp);
}
}
return newCU;
}
-
+
private TypeDeclaration createTeam(Javadoc javadoc, int modifiers, boolean isInterface, boolean isRole,
String teamClassName, String superClassName, List superInterfaces, List bodyDeclarations)
{
@@ -486,16 +486,16 @@ public class ASTRewriteFlattenerTest extends TestCase {
if (javadoc != null)
newTypeDecl.setJavadoc(javadoc);
- if (superClassName != null)
+ if (superClassName != null)
newTypeDecl.setSuperclass(_newAst.newSimpleName(superClassName));
-
+
if (superInterfaces != null && superInterfaces.size()!= 0)
{
List superInterfacesList = newTypeDecl.superInterfaces();
for (int idx = 0; idx < superInterfaces.size(); idx++)
{
SimpleName tmp = (SimpleName)superInterfaces.get(idx);
- superInterfacesList.add(tmp);
+ superInterfacesList.add(tmp);
}
}
@@ -505,40 +505,40 @@ public class ASTRewriteFlattenerTest extends TestCase {
for (int idx = 0; idx < bodyDeclarations.size(); idx++)
{
Object tmp = bodyDeclarations.get(idx);
- bodyDeclarationList.add(tmp);
+ bodyDeclarationList.add(tmp);
}
}
return newTypeDecl;
}
-
- private RoleTypeDeclaration createRole(Javadoc javadoc, int modifier, String roleName, String baseClassName,
+
+ private RoleTypeDeclaration createRole(Javadoc javadoc, int modifier, String roleName, String baseClassName,
String teamClassName, String superClassName, List superInterfaces, boolean isTeam,
List bodyDeclarations)
{
RoleTypeDeclaration role = _newAst.newRoleTypeDeclaration();
-
+
role.modifiers().addAll(_newAst.newModifiers(modifier));
role.setName(_newAst.newSimpleName(roleName));
role.setTeamClassType(_newAst.newSimpleType((_newAst.newSimpleName(teamClassName))));
role.setTeam(isTeam);
- role.setRole(true);
+ role.setRole(true);
if (javadoc != null)
role.setJavadoc(javadoc);
-
- if (baseClassName != null)
+
+ if (baseClassName != null)
role.setBaseClassType(_newAst.newSimpleType(_newAst.newSimpleName(baseClassName)));
-
- if (superClassName != null)
+
+ if (superClassName != null)
role.setSuperclass(_newAst.newSimpleName(superClassName));
-
+
if (superInterfaces != null && superInterfaces.size()!= 0)
{
List superInterfacesList = role.superInterfaceTypes();
for (int idx = 0; idx < superInterfaces.size(); idx++)
{
SimpleName tmp = (SimpleName)superInterfaces.get(idx);
- superInterfacesList.add(tmp);
+ superInterfacesList.add(tmp);
}
}
@@ -548,7 +548,7 @@ public class ASTRewriteFlattenerTest extends TestCase {
for (int idx = 0; idx < bodyDeclarations.size(); idx++)
{
Object tmp = bodyDeclarations.get(idx);
- bodyDeclarationList.add(tmp);
+ bodyDeclarationList.add(tmp);
}
}
return role;
@@ -560,10 +560,10 @@ public class ASTRewriteFlattenerTest extends TestCase {
CallinMappingDeclaration newCallinMapping = _newAst.newCallinMappingDeclaration();
newCallinMapping.setCallinModifier(callinModifier);
newCallinMapping.setRoleMappingElement(roleMethod);
-
+
if (javadoc != null)
newCallinMapping.setJavadoc(javadoc);
-
+
if (baseMethods != null && baseMethods.size()!= 0)
{
List baseMappingList = newCallinMapping.getBaseMappingElements();
@@ -579,50 +579,50 @@ public class ASTRewriteFlattenerTest extends TestCase {
for (int idx = 0; idx < paramMappings.size(); idx++)
{
ParameterMapping tmp = (ParameterMapping)paramMappings.get(idx);
- parameterMappingList.add(tmp);
+ parameterMappingList.add(tmp);
}
}
return newCallinMapping;
}
-
+
private CalloutMappingDeclaration createCalloutMapping(Javadoc javadoc, int modifier, MethodSpec roleMethod,
MethodMappingElement baseMethod, List paramMappings, boolean calloutOverride, boolean signatureFlag)
{
CalloutMappingDeclaration newCalloutMapping = _newAst.newCalloutMappingDeclaration();
-
+
if (javadoc != null)
newCalloutMapping.setJavadoc(javadoc);
-
+
newCalloutMapping.modifiers().addAll(_newAst.newModifiers(modifier));
newCalloutMapping.setSignatureFlag(signatureFlag);
newCalloutMapping.setRoleMappingElement(roleMethod);
newCalloutMapping.setBaseMappingElement(baseMethod);
if (calloutOverride)
newCalloutMapping.bindingOperator().setBindingKind(MethodBindingOperator.KIND_CALLOUT_OVERRIDE);
-
+
if (paramMappings != null && paramMappings.size()!= 0)
{
List parameterMapping = newCalloutMapping.getParameterMappings();
for (int idx = 0; idx < paramMappings.size(); idx++)
{
ParameterMapping tmp = (ParameterMapping)paramMappings.get(idx);
- parameterMapping.add(tmp);
+ parameterMapping.add(tmp);
}
}
return newCalloutMapping;
}
-
+
private FieldAccessSpec createFieldAccSpec(String fieldName, PrimitiveType.Code simpleType, String type, boolean hasSignature)
{
FieldAccessSpec newFieldAcc = _newAst.newFieldAccessSpec();
newFieldAcc.setName(_newAst.newSimpleName(fieldName));
-
+
if (simpleType!= null)
newFieldAcc.setFieldType(_newAst.newPrimitiveType(simpleType));
-
+
if (type!= null)
newFieldAcc.setFieldType(_newAst.newSimpleType(_newAst.newSimpleName(type)));
-
+
newFieldAcc.setSignatureFlag(hasSignature);
return newFieldAcc;
}
@@ -633,43 +633,43 @@ public class ASTRewriteFlattenerTest extends TestCase {
methodSpec.setName(_newAst.newSimpleName(methodName));
methodSpec.setReturnType2(_newAst.newPrimitiveType(returnType));
methodSpec.setSignatureFlag(signatureFlag);
-
+
if (parameters!=null && parameters.size()!=0)
{
List methodParameters = methodSpec.parameters();
for (int idx = 0; idx < parameters.size(); idx++)
{
VariableDeclaration tmp = (VariableDeclaration)parameters.get(idx);
- methodParameters.add(tmp);
+ methodParameters.add(tmp);
}
}
return methodSpec;
}
-
+
private SingleVariableDeclaration createMethodParameter(int modifier, String parameterType, PrimitiveType.Code primitiveType, String parameterName, int dimension,
Expression initializer)
{
SingleVariableDeclaration methodSpecParameter = _newAst.newSingleVariableDeclaration();
methodSpecParameter.modifiers().addAll(_newAst.newModifiers(modifier));
-
+
if(primitiveType!= null)
{
PrimitiveType primitiveRoleParameterType = _newAst.newPrimitiveType(primitiveType);
methodSpecParameter.setType(primitiveRoleParameterType);
}
-
+
if (parameterType!= null)
{
SimpleType simpleRoleParameterType = _newAst.newSimpleType(_newAst.newSimpleName(parameterType));
methodSpecParameter.setType(simpleRoleParameterType);
}
-
+
methodSpecParameter.setName(_newAst.newSimpleName(parameterName));
methodSpecParameter.setExtraDimensions(dimension);
methodSpecParameter.setInitializer(initializer);
return methodSpecParameter;
}
-
+
private ParameterMapping createParameterMapping(Expression expression, String identName,
String direction, boolean resultFlag)
{
@@ -680,7 +680,7 @@ public class ASTRewriteFlattenerTest extends TestCase {
newParameterMapping.setResultFlag(resultFlag);
return newParameterMapping;
}
-
+
private Expression createExpression(String expressionName, String methodName)
{
MethodInvocation expression = _newAst.newMethodInvocation();
@@ -694,7 +694,7 @@ public class ASTRewriteFlattenerTest extends TestCase {
Expression expression= _newAst.newSimpleName(expressionName);
return expression;
}
-
+
private Expression createExpression(Expression innerExpression, String className,
List arguments, AnonymousClassDeclaration anonymousClass)
{
@@ -709,7 +709,7 @@ public class ASTRewriteFlattenerTest extends TestCase {
for (int idx = 0; idx < arguments.size(); idx++)
{
Expression tmp = (Expression)arguments.get(idx);
- classArguments.add(tmp);
+ classArguments.add(tmp);
}
}
return expression;
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCallinMappingDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCallinMappingDeclarationTest.java
index 7da3994b3..7f06b7f2d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCallinMappingDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCallinMappingDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -51,15 +51,15 @@ import org.eclipse.text.edits.MalformedTreeException;
@SuppressWarnings("nls")
public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewritingModifyingTest {
private static final Class<?> THIS = ASTRewritingModifyingCallinMappingDeclarationTest.class;
-
+
public ASTRewritingModifyingCallinMappingDeclarationTest(String name) {
super(name);
}
-
+
public static Test allTests() {
return new Suite(THIS);
}
-
+
public static Test suite() {
if (true) {
return allTests();
@@ -68,12 +68,12 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
suite.addTest(new ASTRewritingModifyingCallinMappingDeclarationTest("test0009"));
return suite;
}
-
+
/**
* add 2 parameter mappings to callinMappingDeclaration without parameter mappings
*/
@SuppressWarnings("unchecked") // callin.getParameterMappings().add(..);
- public void test0001() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0001() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0001", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0001;\n");
@@ -83,23 +83,23 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
Expression expression1 = ASTNodeCreator.createExpression(ast,"s1+\"Test\"");
ParameterMapping mapping1 = ASTNodeCreator.createParameterMapping(ast,expression1,ast.newSimpleName("s2"),"<-",false);
-
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.getParameterMappings().add(mapping1);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0001;\n");
buf.append("public team class Team {\n");
@@ -111,11 +111,11 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* delete all parameter mappings from callinMappingDeclaration
*/
- public void test0002() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0002() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0002", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0002;\n");
@@ -127,21 +127,21 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.getParameterMappings().remove(1);
callin.getParameterMappings().remove(0);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0002;\n");
buf.append("public team class Team {\n");
@@ -149,15 +149,15 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" String roleMethod(String s1) <- before String baseMethod(String s2);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
* add one parameter mapping
*/
@SuppressWarnings("unchecked") // callin.getParameterMappings().add(..);
- public void test0003() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0003() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0003", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0003;\n");
@@ -168,25 +168,25 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- Expression expression1 = ASTNodeCreator.createExpression(ast,"result+\"addOnString\"");
+ Expression expression1 = ASTNodeCreator.createExpression(ast,"result+\"addOnString\"");
ParameterMapping mapping1 = ASTNodeCreator.createParameterMapping(ast,expression1,ast.newSimpleName("result"),"->",false);
-
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.getParameterMappings().add(mapping1);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0003;\n");
buf.append("public team class Team {\n");
@@ -197,14 +197,14 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* change callin modifier
*/
- public void test0004() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0004() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0004", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0004;\n");
@@ -215,21 +215,21 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.setCallinModifier(Modifier.OT_AFTER_CALLIN);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0004;\n");
buf.append("public team class Team {\n");
@@ -239,19 +239,19 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
- * change role methodSpec in callinMappingDeclaration
+ * change role methodSpec in callinMappingDeclaration
* @throws JavaModelException
* @throws BadLocationException
* @throws MalformedTreeException
*/
@SuppressWarnings("unchecked") // argList1.add(..)
public void test0005() throws MalformedTreeException, JavaModelException, BadLocationException {
-
+
IPackageFragment pack1= sourceFolder.createPackageFragment("test0005", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0005;\n");
@@ -262,33 +262,33 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
List<SingleVariableDeclaration> argList1 = new ArrayList<SingleVariableDeclaration>();
argList1.add(ASTNodeCreator.createArgument(ast,0,ASTNodeCreator.createType(ast, "String"),"s1",null));
-
+
MethodSpec methodSpec1 = ASTNodeCreator.createMethodSpec(
ast,
"newRoleMethod",
ASTNodeCreator.createType(ast, "String"),
argList1,
true);
-
+
callin.setRoleMappingElement(methodSpec1);
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0005;\n");
buf.append("public team class Team {\n");
@@ -298,7 +298,7 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
@@ -306,8 +306,8 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
* add base mapping element (guard present)
*/
@SuppressWarnings("unchecked") // argList1.add(..)
- public void test0006() throws MalformedTreeException, JavaModelException, BadLocationException {
-
+ public void test0006() throws MalformedTreeException, JavaModelException, BadLocationException {
+
IPackageFragment pack1= sourceFolder.createPackageFragment("test0006", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0006;\n");
@@ -318,33 +318,33 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
List<SingleVariableDeclaration> argList1 = new ArrayList<SingleVariableDeclaration>();
argList1.add(ASTNodeCreator.createArgument(ast,0,ASTNodeCreator.createType(ast, "String"),"s3",null));
-
+
MethodSpec methodSpec1 = ASTNodeCreator.createMethodSpec(
ast,
"fooBaseMethod",
ASTNodeCreator.createType(ast, "String"),
argList1,
true);
-
+
callin.getBaseMappingElements().add(methodSpec1);
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0006;\n");
buf.append("public team class Team {\n");
@@ -354,17 +354,17 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove first base mapping element
*/
- public void test0007() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0007() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0007", false, null);
StringBuffer buf= new StringBuffer();
-
+
buf.append("package test0007;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
@@ -373,20 +373,20 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.getBaseMappingElements().remove(0);
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0007;\n");
buf.append("public team class Team {\n");
@@ -396,16 +396,16 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
-
+
+
/**
* add guard predicate
*/
- public void test0008() throws MalformedTreeException, JavaModelException, BadLocationException {
-
+ public void test0008() throws MalformedTreeException, JavaModelException, BadLocationException {
+
IPackageFragment pack1= sourceFolder.createPackageFragment("test0008", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0008;\n");
@@ -416,25 +416,25 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
-
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+
GuardPredicateDeclaration guard = ASTNodeCreator.createGuardPredicate(ast, /*isBase*/false, ast.newBooleanLiteral(true));
-
+
callin.setGuardPredicate(guard);
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0008;\n");
buf.append("public team class Team {\n");
@@ -444,37 +444,37 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* remove signatures, 2 base methods.
*/
- public void test0009() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0009() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0009", false, null);
StringBuffer buf= new StringBuffer();
-
+
buf.append("package test0009;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
buf.append(" String roleMethod(String s1) <- before String baseMethod(String s2), String fooBaseMethod(String s3);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.removeSignatures();
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0009;\n");
buf.append("public team class Team {\n");
@@ -482,17 +482,17 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" roleMethod <- before baseMethod, fooBaseMethod;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* remove signatures, 2 base methods, some arg-lists are empty, w/ linebreaks
*/
- public void test0010() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0010() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0010", false, null);
StringBuffer buf= new StringBuffer();
-
+
buf.append("package test0010;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
@@ -502,20 +502,20 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" String fooBaseMethod(String s3);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.removeSignatures();
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0010;\n");
buf.append("public team class Team {\n");
@@ -523,40 +523,40 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" roleMethod// should keep this comment\n");
buf.append(" <- before\n");
buf.append(" baseMethod,\n");
- buf.append(" fooBaseMethod;\n");
+ buf.append(" fooBaseMethod;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* remove signatures, 1 base method, type parameter
*/
- public void test0011() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0011() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0011", false, null);
StringBuffer buf= new StringBuffer();
-
+
buf.append("package test0011;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
buf.append(" <E> String roleMethod(E s1) <- before String baseMethod(String s2);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
callin.removeSignatures();
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0011;\n");
buf.append("public team class Team {\n");
@@ -564,33 +564,33 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" roleMethod <- before baseMethod;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* add signatures, 2 base methods.
*/
- public void test0012() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0012() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0012", false, null);
StringBuffer buf= new StringBuffer();
-
+
buf.append("package test0012;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
buf.append(" roleMethod <- before baseMethod, fooBaseMethod;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
addSignature(astRoot.getAST(),
(MethodSpec)callin.getRoleMappingElement(),
"String", new String[] {"String"}, new String[] {"s1"} );
@@ -602,7 +602,7 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
"String", new String[] {"String", "Object"}, new String[] {"s3", "ignored"} );
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0012;\n");
buf.append("public team class Team {\n");
@@ -610,34 +610,34 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" String roleMethod(String s1) <- before String baseMethod(String s2), String fooBaseMethod(String s3, Object ignored);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* add signatures, 1 base method, type parameter
*/
- public void test0013() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0013() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0013", false, null);
StringBuffer buf= new StringBuffer();
-
+
buf.append("package test0013;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
buf.append(" roleMethod <- before baseMethod;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu = pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
AST ast = astRoot.getAST();
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
+ CallinMappingDeclaration callin = (CallinMappingDeclaration) role.bodyDeclarations().get(0);
MethodSpec roleMethodSpec = (MethodSpec)callin.getRoleMappingElement();
TypeParameter typeParameter = ast.newTypeParameter();
typeParameter.setName(ast.newSimpleName("E"));
@@ -650,7 +650,7 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
"E", new String[] {"String"}, new String[] {"s2"} );
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0013;\n");
buf.append("public team class Team {\n");
@@ -658,7 +658,7 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
buf.append(" <E> E roleMethod(String s1) <- before E baseMethod(String s2);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
@@ -674,4 +674,3 @@ public class ASTRewritingModifyingCallinMappingDeclarationTest extends ASTRewrit
}
}
}
- \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCalloutMappingDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCalloutMappingDeclarationTest.java
index 12b3fe3a6..d6617c9df 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCalloutMappingDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingCalloutMappingDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -50,15 +50,15 @@ import org.eclipse.text.edits.MalformedTreeException;
// TODO(jsv) create own OT package for this test
public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewritingModifyingTest {
private static final Class THIS = ASTRewritingModifyingCalloutMappingDeclarationTest.class;
-
+
public ASTRewritingModifyingCalloutMappingDeclarationTest(String name) {
super(name);
}
-
+
public static Test allTests() {
return new Suite(THIS);
}
-
+
public static Test suite() {
if (true) {
return allTests();
@@ -67,11 +67,11 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
suite.addTest(new ASTRewritingModifyingCalloutMappingDeclarationTest("test0009"));
return suite;
}
-
+
/**
* add 2 parameter mappings to calloutMappingDeclaration without parameter mappings
*/
- public void test0001() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0001() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0001", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0001;\n");
@@ -81,26 +81,26 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
Expression expression1 = ASTNodeCreator.createExpression(ast,"s1+\"Test\"");
ParameterMapping mapping1 = ASTNodeCreator.createParameterMapping(ast,expression1,ast.newSimpleName("s2"),"->",false);
- Expression expression2 = ASTNodeCreator.createExpression(ast,"result+\"addOnString\"");
+ Expression expression2 = ASTNodeCreator.createExpression(ast,"result+\"addOnString\"");
ParameterMapping mapping2 = ASTNodeCreator.createParameterMapping(ast,expression2,ast.newSimpleName("result"),"<-",false);
-
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
+
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
callout.getParameterMappings().add(mapping1);
callout.getParameterMappings().add(mapping2);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0001;\n");
buf.append("public team class Team {\n");
@@ -113,11 +113,11 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* delete all parameter mappings from calloutMappingDeclaration
*/
- public void test0002() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0002() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0002", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0002;\n");
@@ -129,23 +129,23 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
callout.getParameterMappings().remove(1);
callout.getParameterMappings().remove(0);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0002;\n");
buf.append("public team class Team {\n");
@@ -153,14 +153,14 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" String roleMethod(String s1) -> String baseMethod(String s2);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
* add one parameter mapping
*/
- public void test0003() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0003() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0003", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0003;\n");
@@ -171,25 +171,25 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- Expression expression1 = ASTNodeCreator.createExpression(ast,"result+\"addOnString\"");
+ Expression expression1 = ASTNodeCreator.createExpression(ast,"result+\"addOnString\"");
ParameterMapping mapping1 = ASTNodeCreator.createParameterMapping(ast,expression1,ast.newSimpleName("result"),"<-",false);
-
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
+
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
callout.getParameterMappings().add(mapping1);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0003;\n");
buf.append("public team class Team {\n");
@@ -200,14 +200,14 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* change callout kind
*/
- public void test0004() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0004() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0004", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0004;\n");
@@ -218,23 +218,23 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
+
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
callout.bindingOperator().setBindingKind(MethodBindingOperator.KIND_CALLOUT_OVERRIDE);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0004;\n");
buf.append("public team class Team {\n");
@@ -244,17 +244,17 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
- * change role and base methodSpec in calloutMappingDeclaration
+ * change role and base methodSpec in calloutMappingDeclaration
*/
- public void test0005() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0005() throws MalformedTreeException, JavaModelException, BadLocationException {
//FIXME(jsv): Handling of MethodSpecs needs to be implemented in Parser!
//fail("Feature not yet implemented!");
-
+
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0005", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0005;\n");
@@ -265,45 +265,45 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
-
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(0);
+
List<SingleVariableDeclaration> argList1 = new ArrayList<SingleVariableDeclaration>();
argList1.add(ASTNodeCreator.createArgument(ast,0,ASTNodeCreator.createType(ast, "String"),"s1",null));
-
+
List<SingleVariableDeclaration> argList2 = new ArrayList<SingleVariableDeclaration>();
- argList2.add(ASTNodeCreator.createArgument(ast,0,ASTNodeCreator.createType(ast, "String"),"s2",null));
-
+ argList2.add(ASTNodeCreator.createArgument(ast,0,ASTNodeCreator.createType(ast, "String"),"s2",null));
+
MethodSpec methodSpec1 = ASTNodeCreator.createMethodSpec(
ast,
"newRoleMethod",
ASTNodeCreator.createType(ast, "String"),
argList1,
true);
-
+
MethodSpec methodSpec2 = ASTNodeCreator.createMethodSpec(
ast,
"newBaseMethod",
ASTNodeCreator.createType(ast, "String"),
argList2,
true);
-
+
callout.setRoleMappingElement(methodSpec1);
callout.setBaseMappingElement(methodSpec2);
callout.bindingOperator().setBindingKind(MethodBindingOperator.KIND_CALLOUT_OVERRIDE);
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0005;\n");
buf.append("public team class Team {\n");
@@ -313,15 +313,15 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" }\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove signatures, regular callout.
*/
- public void test0006() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0006() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0006", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0006;\n");
@@ -331,21 +331,21 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" String roleMethod(String s1) -> String baseMethod(String s2);\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
+
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
callout.removeSignatures();
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0006;\n");
buf.append("public team class Team {\n");
@@ -354,7 +354,7 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" roleMethod -> baseMethod;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
@@ -362,7 +362,7 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
/**
* remove signatures, callout-to-field (get)
*/
- public void test0007() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0007() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0007", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0007;\n");
@@ -372,21 +372,21 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" String getField() -> get String baseField;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
+
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
callout.removeSignatures();
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0007;\n");
buf.append("public team class Team {\n");
@@ -395,15 +395,15 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" getField -> get baseField;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove signatures, callout-to-field (set)
*/
- public void test0008() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0008() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0008", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0008;\n");
@@ -413,21 +413,21 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" void setField(String val) -> set String baseField;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
- CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
+
+ CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
callout.removeSignatures();
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0008;\n");
buf.append("public team class Team {\n");
@@ -436,7 +436,7 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" setField -> set baseField;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
@@ -444,7 +444,7 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
/**
* add signatures, callout-to-field (set)
*/
- public void test0009() throws MalformedTreeException, JavaModelException, BadLocationException {
+ public void test0009() throws MalformedTreeException, JavaModelException, BadLocationException {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0009", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0009;\n");
@@ -454,17 +454,17 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" setField -> set baseField;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
AST ast = astRoot.getAST();
-
+
astRoot.recordModifications();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
CalloutMappingDeclaration callout = (CalloutMappingDeclaration) role.bodyDeclarations().get(1);
// role side:
MethodSpec roleMethodSpec = (MethodSpec)callout.getRoleMappingElement();
@@ -474,14 +474,14 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
arg.setName(ast.newSimpleName("val"));
arg.setType(ast.newSimpleType(ast.newSimpleName("String")));
roleMethodSpec.parameters().add(arg);
-
+
// base side:
FieldAccessSpec fieldAccessSpec = (FieldAccessSpec)callout.getBaseMappingElement();
fieldAccessSpec.setSignatureFlag(true);
fieldAccessSpec.setFieldType(ast.newSimpleType(ast.newSimpleName("String")));
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0009;\n");
buf.append("public team class Team {\n");
@@ -490,8 +490,7 @@ public class ASTRewritingModifyingCalloutMappingDeclarationTest extends ASTRewri
buf.append(" void setField(String val) -> set String baseField;\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
}
- \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingRoleTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingRoleTest.java
index 40e6df952..7f1d97166 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingRoleTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingRoleTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -44,15 +44,15 @@ import org.eclipse.jdt.core.dom.InfixExpression.Operator;
// TODO(jsv) create own OT package for this test
public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
private static final Class THIS = ASTRewritingModifyingRoleTest.class;
-
+
public ASTRewritingModifyingRoleTest(String name) {
super(name);
}
-
+
public static Test allTests() {
return new Suite(THIS);
}
-
+
public static Test suite() {
if (true) {
return allTests();
@@ -61,11 +61,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
suite.addTest(new ASTRewritingModifyingRoleTest("test0009"));
return suite;
}
-
+
/**
* change name of role
*/
- public void test0001() throws Exception {
+ public void test0001() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0001", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0001;\n");
@@ -74,19 +74,19 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
role.setName(ast.newSimpleName("NewRole"));
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0001;\n");
buf.append("public team class Team {\n");
@@ -95,11 +95,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* delete base class
*/
- public void test0002() throws Exception {
+ public void test0002() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0002", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0002;\n");
@@ -108,19 +108,19 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
role.setBaseClassType(null);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0002;\n");
buf.append("public team class Team {\n");
@@ -129,11 +129,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* add base class
*/
- public void test0003() throws Exception {
+ public void test0003() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0003", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0003;\n");
@@ -142,19 +142,19 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
role.setBaseClassType(ast.newSimpleType(ast.newName(new String[] {"Base"})));
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0003;\n");
buf.append("public team class Team {\n");
@@ -163,11 +163,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* change base class
*/
- public void test0004() throws Exception {
+ public void test0004() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0004", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0004;\n");
@@ -176,19 +176,19 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
role.setBaseClassType(ast.newSimpleType(ast.newName(new String[] {"NewBase"})));
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0004;\n");
buf.append("public team class Team {\n");
@@ -197,11 +197,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* add calloutmappingdeclaration
*/
- public void test0005() throws Exception {
+ public void test0005() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0005", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0005;\n");
@@ -210,35 +210,35 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
CalloutMappingDeclaration callout = ast.newCalloutMappingDeclaration();
MethodSpec baseMethodSpec = ast.newMethodSpec();
MethodSpec roleMethodSpec = ast.newMethodSpec();
-
+
baseMethodSpec.setName(ast.newSimpleName("baseMethodSpec"));
roleMethodSpec.setName(ast.newSimpleName("roleMethodSpec"));
baseMethodSpec.setSignatureFlag(true);
baseMethodSpec.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
roleMethodSpec.setSignatureFlag(true);
roleMethodSpec.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
-
+
callout.setBaseMappingElement(baseMethodSpec);
callout.setRoleMappingElement(roleMethodSpec);
- callout.setSignatureFlag(true);
-
+ callout.setSignatureFlag(true);
+
role.bodyDeclarations().add(callout);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0005;\n");
buf.append("public team class Team {\n");
@@ -249,11 +249,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove calloutMappingDeclaration
- */
- public void test0006() throws Exception {
+ */
+ public void test0006() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0006", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0006;\n");
@@ -263,35 +263,35 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" void roleMethodSpec() -> void baseMethodSpec();\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
role.bodyDeclarations().remove(0);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0006;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
+
/**
* add callinmappingdeclaration
*/
- public void test0007() throws Exception {
+ public void test0007() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0007", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0007;\n");
@@ -300,36 +300,36 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
CallinMappingDeclaration callin = ast.newCallinMappingDeclaration();
-
+
MethodSpec baseMethodSpec = ast.newMethodSpec();
MethodSpec roleMethodSpec = ast.newMethodSpec();
-
+
baseMethodSpec.setName(ast.newSimpleName("baseMethodSpec"));
roleMethodSpec.setName(ast.newSimpleName("roleMethodSpec"));
baseMethodSpec.setSignatureFlag(true);
baseMethodSpec.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
roleMethodSpec.setSignatureFlag(true);
roleMethodSpec.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));
-
+
callin.getBaseMappingElements().add(baseMethodSpec);
callin.setRoleMappingElement(roleMethodSpec);
-
+
callin.setCallinModifier(Modifier.OT_BEFORE_CALLIN);
role.bodyDeclarations().add(callin);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0007;\n");
buf.append("public team class Team {\n");
@@ -340,11 +340,11 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove callinmappingdeclaration
*/
- public void test0008() throws Exception {
+ public void test0008() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0008", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0008;\n");
@@ -354,35 +354,35 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" void roleMethodSpec() <- before void baseMethodSpec();\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
role.bodyDeclarations().remove(0);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0008;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base {\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
/**
* add role guard predicate
*/
- public void test0009() throws Exception {
+ public void test0009() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0009", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0009;\n");
@@ -392,20 +392,20 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
GuardPredicateDeclaration guard = ast.newGuardPredicateDeclaration();
-
+
guard.setBase(true);
-
+
InfixExpression expr = ast.newInfixExpression();
NumberLiteral lhs = ast.newNumberLiteral();
lhs.setToken("4");
@@ -417,24 +417,24 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
guard.setExpression(expr);
role.setGuardPredicate(guard);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0009;\n");
buf.append("public team class Team {\n");
buf.append(" public class Role playedBy Base\n");
- buf.append(" base when (4 == 5)\n");
+ buf.append(" base when (4 == 5)\n");
buf.append(" {\n");
buf.append(" }\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove role guard predicate
*/
- public void test0010() throws Exception {
+ public void test0010() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0010", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0010;\n");
@@ -445,22 +445,22 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
role.setGuardPredicate(null);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0010;\n");
buf.append("public team class Team {\n");
@@ -469,15 +469,15 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
-
+
+
/**
* changed role guard predicate
*/
- public void test0011() throws Exception {
+ public void test0011() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test0011", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0011;\n");
@@ -488,22 +488,22 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = (RoleTypeDeclaration) aTeam.bodyDeclarations().get(0);
-
+
GuardPredicateDeclaration guard = role.getGuardPredicate();
-
+
guard.setBase(true);
-
+
InfixExpression expr = ast.newInfixExpression();
NumberLiteral lhs = ast.newNumberLiteral();
lhs.setToken("23");
@@ -513,9 +513,9 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
expr.setRightOperand(rhs);
expr.setOperator(Operator.NOT_EQUALS);
guard.setExpression(expr);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0011;\n");
buf.append("public team class Team {\n");
@@ -525,8 +525,7 @@ public class ASTRewritingModifyingRoleTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
}
- \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTeamTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTeamTest.java
index 860e0bb11..cf301f00d 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTeamTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTeamTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -49,15 +49,15 @@ import org.eclipse.text.edits.TextEdit;
//TODO(jsv) create own OT package for this test
public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
private static final Class THIS = ASTRewritingModifyingTeamTest.class;
-
+
public ASTRewritingModifyingTeamTest(String name) {
super(name);
}
-
+
public static Test allTests() {
return new Suite(THIS);
}
-
+
public static Test suite() {
if (true) {
return allTests();
@@ -66,32 +66,32 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
suite.addTest(new ASTRewritingModifyingTeamTest("test0009"));
return suite;
}
-
+
/**
* insert a new role
*/
- public void test0001() throws Exception {
+ public void test0001() throws Exception {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0001", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0001;\n");
buf.append("public team class X {\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = ast.newRoleTypeDeclaration();
role.setName(ast.newSimpleName("Y"));
role.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
- aTeam.bodyDeclarations().add(role);
-
+ aTeam.bodyDeclarations().add(role);
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0001;\n");
buf.append("public team class X {\n");
@@ -101,11 +101,11 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* Delete role from team
*/
- public void test0002() throws Exception {
+ public void test0002() throws Exception {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0002", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0002;\n");
@@ -114,29 +114,29 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("}\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
- aTeam.bodyDeclarations().remove(0);
-
+ aTeam.bodyDeclarations().remove(0);
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0002;\n");
buf.append("public team class X {\n");
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* Replace role
*/
- public void test0003() throws Exception {
+ public void test0003() throws Exception {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0003", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0003;\n");
@@ -149,22 +149,22 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("X.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
RoleTypeDeclaration role = ast.newRoleTypeDeclaration();
role.setName(ast.newSimpleName("YY"));
role.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
aTeam.bodyDeclarations().remove(1);
aTeam.bodyDeclarations().add(1,role);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0003;\n");
buf.append("public team class X {\n");
@@ -177,27 +177,27 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
// Insert a role with playedBy via modification and cloning.
public void test0004() throws Exception {
-
+
// generate some AST:
- String generated =
- "public team class MyTeam {\n" +
+ String generated =
+ "public team class MyTeam {\n" +
" protected class DisposeWatcher playedBy Item {\n" +
" void bar() { nop(); }\n" +
- " }\n" +
+ " }\n" +
"}\n";
-
+
ASTParser parser = ASTParser.newParser(AST.JLS4);
parser.setKind(ASTParser.K_STATEMENTS);
parser.setSource(generated.toCharArray());
-
+
Block block = (Block) parser.createAST(null);
TypeDeclarationStatement st = (TypeDeclarationStatement) block.statements().get(0);
TypeDeclaration decl = (TypeDeclaration) st.getDeclaration();
ASTNode[] myNodes = (ASTNode[]) decl.bodyDeclarations().toArray(new ASTNode[1]);
-
+
// create a CU to copy into:
String existing =
"public team class MyTeam {\n" +
@@ -209,19 +209,19 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
parser.setSource(existing.toCharArray());
CompilationUnit _astCU = (CompilationUnit)parser.createAST(null);
TypeDeclaration teamDecl = (TypeDeclaration)_astCU.types().get(0);
-
+
// copy generated into CU:
_astCU.recordModifications();
teamDecl.bodyDeclarations().add(ASTNode.copySubtree(_astCU.getAST(), myNodes[0]));
-
+
// apply change:
Document doc = new Document(existing);
TextEdit edits = _astCU.rewrite(doc, null);
edits.apply(doc);
-
+
// compare result with expected:
String newSource = doc.get();
- String expected =
+ String expected =
"public team class MyTeam {\n" +
" protected class OtherRole {}\n" +
" void foo() { System.out.println(this); }\n" +
@@ -233,29 +233,29 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
"}\n";
assertEquals(expected, newSource);
}
-
+
// insert a role with playedBy and base predicate :
public void test0005() throws Exception {
-
+
// generate some AST:
- String generated =
- "public team class MyTeam {\n" +
+ String generated =
+ "public team class MyTeam {\n" +
" protected class DisposeWatcher playedBy Item \n" +
" base when (hasRole(base)) {\n" +
" void bar() { nop(); }\n" +
- " }\n" +
+ " }\n" +
"}\n";
-
+
ASTParser parser = ASTParser.newParser(AST.JLS4);
parser.setKind(ASTParser.K_STATEMENTS);
parser.setSource(generated.toCharArray());
-
+
Block block = (Block) parser.createAST(null);
TypeDeclarationStatement st = (TypeDeclarationStatement) block.statements().get(0);
TypeDeclaration decl = (TypeDeclaration) st.getDeclaration();
ASTNode[] myNodes = (ASTNode[]) decl.bodyDeclarations().toArray(new ASTNode[1]);
-
+
// create a CU to copy into:
String existing =
"public team class MyTeam {\n" +
@@ -267,19 +267,19 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
parser.setSource(existing.toCharArray());
CompilationUnit _astCU = (CompilationUnit)parser.createAST(null);
TypeDeclaration teamDecl = (TypeDeclaration)_astCU.types().get(0);
-
+
// copy generated into CU:
_astCU.recordModifications();
teamDecl.bodyDeclarations().add(ASTNode.copySubtree(_astCU.getAST(), myNodes[0]));
-
+
// apply change:
Document doc = new Document(existing);
TextEdit edits = _astCU.rewrite(doc, null);
edits.apply(doc);
-
+
// compare result with expected:
String newSource = doc.get();
- String expected =
+ String expected =
"public team class MyTeam {\n" +
" protected class OtherRole {}\n" +
" void foo() { System.out.println(this); }\n" +
@@ -293,27 +293,27 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
"}\n";
assertEquals(expected, newSource);
}
-
+
// insert a team with a predicate :
public void test0006() throws Exception {
-
+
// generate some AST:
- String generated =
- "public team class MyTeam \n" +
+ String generated =
+ "public team class MyTeam \n" +
" when (isSunday(today())) {\n" +
" void bar() { nop(); }\n" +
"}\n";
-
+
ASTParser parser = ASTParser.newParser(AST.JLS4);
parser.setKind(ASTParser.K_STATEMENTS);
parser.setSource(generated.toCharArray());
-
+
Block block = (Block) parser.createAST(null);
System.out.println(block);
TypeDeclarationStatement st = (TypeDeclarationStatement) block.statements().get(0);
TypeDeclaration decl = (TypeDeclaration) st.getDeclaration();
-
+
// create a CU to copy into:
String existing =
"import javax.swing.JFrame;\n";
@@ -321,19 +321,19 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(existing.toCharArray());
CompilationUnit _astCU = (CompilationUnit)parser.createAST(null);
-
+
// copy generated into CU:
_astCU.recordModifications();
_astCU.types().add(ASTNode.copySubtree(_astCU.getAST(), decl));
-
+
// apply change:
Document doc = new Document(existing);
TextEdit edits = _astCU.rewrite(doc, null);
edits.apply(doc);
-
+
// compare result with expected:
String newSource = doc.get();
- String expected =
+ String expected =
"import javax.swing.JFrame;\n\n" +
"public team class MyTeam\n" +
" when (isSunday(today()))\n" +
@@ -344,34 +344,34 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
"}\n";
assertEquals(expected, newSource);
}
-
+
/**
* add team guard predicate
*/
- public void test0009() throws Exception {
+ public void test0009() throws Exception {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0009", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0009;\n");
- buf.append("public team class Team\n");
+ buf.append("public team class Team\n");
buf.append("{\n");
buf.append(" public class Role playedBy Base\n");
buf.append(" {\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
GuardPredicateDeclaration guard = ast.newGuardPredicateDeclaration();
-
+
guard.setBase(true);
-
+
InfixExpression expr = ast.newInfixExpression();
NumberLiteral lhs = ast.newNumberLiteral();
lhs.setToken("4");
@@ -383,13 +383,13 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
guard.setExpression(expr);
aTeam.setGuardPredicate(guard);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0009;\n");
buf.append("public team class Team\n");
- buf.append(" base when (4 == 5)\n");
+ buf.append(" base when (4 == 5)\n");
buf.append("{\n");
buf.append(" public class Role playedBy Base\n");
buf.append(" {\n");
@@ -397,11 +397,11 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
+
/**
* remove team guard predicate
*/
- public void test0010() throws Exception {
+ public void test0010() throws Exception {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0010", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0010;\n");
@@ -413,21 +413,21 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
-
+
aTeam.setGuardPredicate(null);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0010;\n");
buf.append("public team class Team\n");
@@ -437,15 +437,15 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
-
-
+
+
/**
* changed team guard predicate
*/
- public void test0011() throws Exception {
+ public void test0011() throws Exception {
IPackageFragment pack1= sourceFolder.createPackageFragment("test0011", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test0011;\n");
@@ -457,21 +457,21 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
ICompilationUnit cu= pack1.createCompilationUnit("Team.java", buf.toString(), false, null);
-
+
CompilationUnit astRoot= createCU(cu, false);
-
+
astRoot.recordModifications();
-
+
AST ast = astRoot.getAST();
-
+
TypeDeclaration aTeam = (TypeDeclaration) astRoot.types().get(0);
-
+
GuardPredicateDeclaration guard = aTeam.getGuardPredicate();
-
+
guard.setBase(true);
-
+
InfixExpression expr = ast.newInfixExpression();
NumberLiteral lhs = ast.newNumberLiteral();
lhs.setToken("23");
@@ -481,9 +481,9 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
expr.setRightOperand(rhs);
expr.setOperator(Operator.NOT_EQUALS);
guard.setExpression(expr);
-
+
String preview = evaluateRewrite(cu.getSource(), astRoot);
-
+
buf= new StringBuffer();
buf.append("package test0011;\n");
buf.append("public team class Team\n");
@@ -494,9 +494,8 @@ public class ASTRewritingModifyingTeamTest extends ASTRewritingModifyingTest {
buf.append("\n");
buf.append(" }\n");
buf.append("}\n");
-
+
assertEqualString(preview, buf.toString());
}
}
- \ No newline at end of file
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTest.java
index 415e48f84..c966e8afc 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/ASTRewritingModifyingTest.java
@@ -1,11 +1,11 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,9 +13,9 @@
*
* SPDX-License-Identifier: EPL-2.0
* $Id$
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -34,8 +34,8 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.objectteams.otdt.core.ext.OTDTPlugin;
// replace cu creation as to use JLS3 instead of JLS2.
-public class ASTRewritingModifyingTest
- extends org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingTest
+public class ASTRewritingModifyingTest
+ extends org.eclipse.jdt.core.tests.rewrite.modifying.ASTRewritingModifyingTest
{
public ASTRewritingModifyingTest(String name) {
@@ -43,7 +43,7 @@ public class ASTRewritingModifyingTest
}
public CompilationUnit createCU(ICompilationUnit unit, boolean resolveBindings) {
-
+
try {
ASTParser c = ASTParser.newParser(AST.JLS4);
c.setSource(unit);
@@ -66,7 +66,7 @@ public class ASTRewritingModifyingTest
return (CompilationUnit) result;
}
- protected IJavaProject createJavaProject(String projectName, String[] sourceFolders, String[] libraries, String output, String compliance)
+ protected IJavaProject createJavaProject(String projectName, String[] sourceFolders, String[] libraries, String output, String compliance)
throws CoreException
{
IJavaProject javaProject = super.createJavaProject(projectName, sourceFolders, libraries, output, compliance);
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/AllTests.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/AllTests.java
index 6c016e97c..1213abb37 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/AllTests.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/AllTests.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/AstRewritingDescribingTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/AstRewritingDescribingTest.java
index 02c02d22f..fb09bdfa6 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/AstRewritingDescribingTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/AstRewritingDescribingTest.java
@@ -1,11 +1,11 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
@@ -13,9 +13,9 @@
*
* SPDX-License-Identifier: EPL-2.0
* $Id$
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -30,14 +30,14 @@ import org.eclipse.objectteams.otdt.ui.tests.util.JavaProjectHelper;
-public class AstRewritingDescribingTest
- extends org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingTest
+public class AstRewritingDescribingTest
+ extends org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingTest
{
public AstRewritingDescribingTest(String name) {
super(name);
}
-
+
public AstRewritingDescribingTest(String name, int apilevel) {
super(name, apilevel);
}
@@ -47,11 +47,11 @@ public class AstRewritingDescribingTest
super.setUp();
JavaProjectHelper.addNatureToProject(project1.getProject(), JavaCore.OTJ_NATURE_ID, null);
}
-
- public static RoleTypeDeclaration findRoleTypeDeclaration (TypeDeclaration teamType, String roleName)
+
+ public static RoleTypeDeclaration findRoleTypeDeclaration (TypeDeclaration teamType, String roleName)
{
for (Object member : teamType.bodyDeclarations()) {
- if (member instanceof RoleTypeDeclaration) {
+ if (member instanceof RoleTypeDeclaration) {
RoleTypeDeclaration roleType = (RoleTypeDeclaration)member;
if (roleType.getName().getIdentifier().equals(roleName))
return (RoleTypeDeclaration)member;
@@ -59,8 +59,8 @@ public class AstRewritingDescribingTest
}
return null;
}
-
- public static CallinMappingDeclaration findCallinMappingDeclaration(RoleTypeDeclaration typeDecl, String roleMethodName)
+
+ public static CallinMappingDeclaration findCallinMappingDeclaration(RoleTypeDeclaration typeDecl, String roleMethodName)
{
CallinMappingDeclaration[] callinCallouts = typeDecl.getCallIns();
for (int i= 0; i < callinCallouts.length; i++) {
@@ -69,6 +69,6 @@ public class AstRewritingDescribingTest
}
}
return null;
- }
+ }
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/CallinMappingDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/CallinMappingDeclarationTest.java
index e4349b5d4..cb405190c 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/CallinMappingDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/CallinMappingDeclarationTest.java
@@ -48,8 +48,8 @@ public class CallinMappingDeclarationTest extends AstRewritingDescribingTest {
suite.addTest(new CallinMappingDeclarationTest("test0009")); // FIXME? Used?
return suite;
}
-
-
+
+
// copied from org.eclipse.jdt.core.tests.rewrite.describing.ASTRewritingMethodDeclTest
// and syntactically adjusted for callins
public void testModifiersAST3WithAnnotations() throws Exception {
@@ -68,15 +68,15 @@ public class CallinMappingDeclarationTest extends AstRewritingDescribingTest {
buf.append(" @ToBeRemoved\n");
buf.append(" @Deprecated\n");
buf.append(" Object foo4() <- after Object bfoo4();\n");
- buf.append("}\n");
- buf.append("}\n");
- ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
-
+ buf.append("}\n");
+ buf.append("}\n");
+ ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+
CompilationUnit astRoot= createAST(cu);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
AST ast= astRoot.getAST();
RoleTypeDeclaration type= findRoleTypeDeclaration(findTypeDeclaration(astRoot, "T"), "E");
-
+
{ // insert annotation first before normal
CallinMappingDeclaration mappingDecl= findCallinMappingDeclaration(type, "foo1");
ListRewrite listRewrite= rewrite.getListRewrite(mappingDecl, CallinMappingDeclaration.MODIFIERS2_PROPERTY);
@@ -90,7 +90,7 @@ public class CallinMappingDeclarationTest extends AstRewritingDescribingTest {
MarkerAnnotation annot= ast.newMarkerAnnotation();
annot.setTypeName(ast.newSimpleName("Override"));
listRewrite.insertFirst(annot, null);
- }
+ }
{ // remove annotation before normal
CallinMappingDeclaration mappingDecl= findCallinMappingDeclaration(type, "foo3");
ListRewrite listRewrite= rewrite.getListRewrite(mappingDecl, CallinMappingDeclaration.MODIFIERS2_PROPERTY);
@@ -101,9 +101,9 @@ public class CallinMappingDeclarationTest extends AstRewritingDescribingTest {
ListRewrite listRewrite= rewrite.getListRewrite(mappingDecl, CallinMappingDeclaration.MODIFIERS2_PROPERTY);
listRewrite.remove((ASTNode) mappingDecl.modifiers().get(0), null);
}
-
+
String preview= evaluateRewrite(cu, rewrite);
-
+
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public team abstract class T {\n");
@@ -118,10 +118,10 @@ public class CallinMappingDeclarationTest extends AstRewritingDescribingTest {
buf.append(" /** javadoc comment */\n");
buf.append(" @Deprecated\n");
buf.append(" Object foo4() <- after Object bfoo4();\n");
- buf.append("}\n");
- buf.append("}\n");
+ buf.append("}\n");
+ buf.append("}\n");
assertEqualString(preview, buf.toString());
}
-
-
+
+
}
diff --git a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java
index 5a40efc4e..d65f07676 100644
--- a/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java
+++ b/testplugins/org.eclipse.objectteams.otdt.ui.tests.dom/src/org/eclipse/objectteams/otdt/ui/tests/dom/rewrite/describing/TypeDeclarationTest.java
@@ -1,20 +1,20 @@
/**********************************************************************
* This file is part of "Object Teams Development Tooling"-Software
- *
+ *
* Copyright 2004, 2010 Fraunhofer Gesellschaft, Munich, Germany,
* for its Fraunhofer Institute and Computer Architecture and Software
* Technology (FIRST), Berlin, Germany and Technical University Berlin,
* Germany.
- *
+ *
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
- *
+ *
* Please visit http://www.eclipse.org/objectteams for updates and contact.
- *
+ *
* Contributors:
* Fraunhofer FIRST - Initial API and implementation
* Technical University Berlin - Initial API and implementation
@@ -55,30 +55,30 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
public static Test suite() {
return createSuite(TypeDeclarationTest.class, AST.JLS3);
}
-
-
+
+
public void testRoleTypeDeclChanges1() throws Exception {
IPackageFragment pack1= this.sourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public team class T {\n");
buf.append(" public class R extends java.util.List implements Runnable, Serializable playedBy String {\n");
- buf.append(" }\n");
+ buf.append(" }\n");
buf.append("}\n");
- ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+ ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
CompilationUnit astRoot= createAST(cu);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
AST ast= astRoot.getAST();
-
+
{ // change to protected team, rename type, rename supertype, rename first interface, rename base-class
TypeDeclaration teamType= findTypeDeclaration(astRoot, "T");
RoleTypeDeclaration roleType= findRoleTypeDeclaration(teamType, "R");
// change flags
rewrite.getListRewrite(roleType, RoleTypeDeclaration.MODIFIERS2_PROPERTY).replace(
- (Modifier)roleType.modifiers().get(0),
- ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),
+ (Modifier)roleType.modifiers().get(0),
+ ast.newModifier(Modifier.ModifierKeyword.PROTECTED_KEYWORD),
null);
// change to team
@@ -88,7 +88,7 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
SimpleName name= roleType.getName();
SimpleName newName= ast.newSimpleName("R1");
rewrite.replace(name, newName, null);
-
+
Type superClass= roleType.getSuperclassType();
assertTrue("Has super type", superClass != null);
SimpleType newSuperclass= ast.newSimpleType(ast.newSimpleName("Object"));
@@ -98,7 +98,7 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
assertTrue("Has super interfaces", !superInterfaces.isEmpty());
SimpleType newSuperinterface= ast.newSimpleType(ast.newSimpleName("Cloneable"));
rewrite.replace((ASTNode) superInterfaces.get(0), newSuperinterface, null);
-
+
Type baseClass= roleType.getBaseClassType();
assertTrue("Has base type", baseClass != null);
SimpleType newBaseclass= ast.newSimpleType(ast.newSimpleName("System"));
@@ -107,13 +107,13 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
}
String preview= evaluateRewrite(cu, rewrite);
-
+
buf= new StringBuffer();
buf.append("package test1;\n");
buf.append("public team class T {\n");
buf.append(" protected team class R1 extends Object implements Cloneable, Serializable playedBy System {\n");
- buf.append(" }\n");
- buf.append("}\n");
+ buf.append(" }\n");
+ buf.append("}\n");
assertEqualString(preview, buf.toString());
}
@@ -125,14 +125,14 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
buf.append(" public team class R1 implements Runnable, Serializable playedBy String {}\n");
buf.append(" public class R2 extends Object implements Runnable {}\n");
buf.append("}\n");
- ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
+ ICompilationUnit cu= pack1.createCompilationUnit("T.java", buf.toString(), false, null);
CompilationUnit astRoot= createAST(cu);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
AST ast= astRoot.getAST();
-
+
TypeDeclaration teamType= findTypeDeclaration(astRoot, "T");
- {
+ {
// change R1 to non-team, add supertype, remmove first interface, remove base-class
RoleTypeDeclaration role1Type= findRoleTypeDeclaration(teamType, "R1");
@@ -148,13 +148,13 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
List superInterfaces= role1Type.superInterfaceTypes();
assertTrue("Has super interfaces", !superInterfaces.isEmpty());
rewrite.getListRewrite(role1Type, RoleTypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY).remove((Type)superInterfaces.get(0), null);
-
+
Type baseClass= role1Type.getBaseClassType();
assertTrue("Has base type", baseClass != null);
rewrite.remove(baseClass, null);
}
- {
+ {
// change R2: remove supertype, add super-interface, add base-class
RoleTypeDeclaration role2Type= findRoleTypeDeclaration(teamType, "R2");
@@ -166,9 +166,9 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
assertTrue("Has super interfaces", !superInterfaces.isEmpty());
Type newSuperInterface = ast.newSimpleType(ast.newSimpleName("Cloneable"));
rewrite.getListRewrite(role2Type, RoleTypeDeclaration.SUPER_INTERFACE_TYPES_PROPERTY).insertLast(
- newSuperInterface,
+ newSuperInterface,
null);
-
+
Type baseClass= role2Type.getBaseClassType();
assertTrue("Has no base type", baseClass == null);
SimpleType newBaseclass= ast.newSimpleType(ast.newSimpleName("System"));
@@ -177,13 +177,13 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
}
String preview= evaluateRewrite(cu, rewrite);
-
+
buf= new StringBuffer();
buf.append("package test2;\n");
buf.append("public team class T {\n");
buf.append(" public class R1 extends Object implements Serializable {}\n");
buf.append(" public class R2 implements Runnable, Cloneable playedBy System {}\n");
- buf.append("}\n");
+ buf.append("}\n");
assertEqualString(preview, buf.toString());
}
@@ -194,14 +194,14 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
buf.append("package test2;\n");
buf.append("public class R1 implements Runnable, Serializable playedBy String {\n");
buf.append("}\n");
- ICompilationUnit cu= pack1.createCompilationUnit("R1.java", buf.toString(), false, null);
+ ICompilationUnit cu= pack1.createCompilationUnit("R1.java", buf.toString(), false, null);
CompilationUnit astRoot= createAST(cu);
ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST());
AST ast= astRoot.getAST();
-
+
PackageDeclaration packageDecl = astRoot.getPackage();
- {
+ {
// change to team
ListRewrite modifiersRewrite = rewrite.getListRewrite(packageDecl, PackageDeclaration.MODIFIERS_PROPERTY);
Modifier teamModifier = ast.newModifier(ModifierKeyword.TEAM_KEYWORD);
@@ -212,7 +212,7 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
}
String preview= evaluateRewrite(cu, rewrite);
-
+
buf= new StringBuffer();
buf.append("@NonNullByDefault ");
buf.append("team package test2.MyTeam;\n");
@@ -222,7 +222,7 @@ public class TypeDeclarationTest extends AstRewritingDescribingTest {
// re-get to also challenge ASTConverter and NaiveASTFlattener:
IPackageFragment pack2 = this.sourceFolder.createPackageFragment("test2.MyTeam", false, null);
- cu= pack2.createCompilationUnit("R1.java", buf.toString(), false, null);
+ cu= pack2.createCompilationUnit("R1.java", buf.toString(), false, null);
astRoot= createAST(cu);
assertEqualString(astRoot.toString(), buf.toString());
}

Back to the top