1 /**
2  * Copyright (c) 2014 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 
15 package org.eclipse.jdt.ui.tests.refactoring;
16 
17 import org.junit.Rule;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 
21 import org.eclipse.jdt.testplugin.JavaProjectHelper;
22 
23 import org.eclipse.ltk.core.refactoring.RefactoringCore;
24 
25 import org.eclipse.jdt.core.IJavaProject;
26 
27 import org.eclipse.jdt.internal.corext.refactoring.ParameterInfo;
28 
29 import org.eclipse.jdt.ui.tests.CustomBaseRunner;
30 import org.eclipse.jdt.ui.tests.IgnoreInheritedTests;
31 import org.eclipse.jdt.ui.tests.core.rules.Java1d8ProjectTestSetup;
32 
33 /**
34  * Those tests are made to run on Java Spider 1.8 .
35  */
36 @IgnoreInheritedTests
37 @RunWith(CustomBaseRunner.class)
38 public class ChangeSignatureTests1d8 extends ChangeSignatureTests {
39 	@Rule
40 	public Java1d8ProjectTestSetup jps= new Java1d8ProjectTestSetup();
41 
42 	private IJavaProject fJProject1;
43 
44 	@Override
getRefactoringPath()45 	protected String getRefactoringPath() {
46 		return "ChangeSignature18/";
47 	}
48 
49 	@Override
genericafter()50 	public void genericafter() throws Exception {
51 		JavaProjectHelper.clear(fJProject1, Java1d8ProjectTestSetup.getDefaultClasspath());
52 	}
53 
54 	@Override
genericbefore()55 	public void genericbefore() throws Exception {
56 		fJProject1= Java1d8ProjectTestSetup.getProject();
57 		fRoot= JavaProjectHelper.addSourceContainer(fJProject1, "src");
58 		fPackageP= fRoot.createPackageFragment("p", true, null);
59 		fIsPreDeltaTest= false;
60 		RefactoringCore.getUndoManager().flush();
61 	}
62 
63 	// Exchange the method parameters
64 	@Test
testLambda0()65 	public void testLambda0() throws Exception {
66 		helper1(new String[]{"j", "i"}, new String[]{"I", "I"});
67 	}
68 
69 	// Add an extra method parameter
70 	@Test
testLambda1()71 	public void testLambda1() throws Exception {
72 		String[] signature= { "I" };
73 		String[] newNames= { "j" };
74 		String[] newTypes= { "int" };
75 		String[] newDefaultValues= { "0" };
76 		ParameterInfo[] newParamInfo= createNewParamInfos(newTypes, newNames, newDefaultValues);
77 		int[] newIndices= { 1 };
78 		helperAdd(signature, newParamInfo, newIndices);
79 	}
80 
81 	// Add a new method parameter to an empty parameter method
82 	@Test
testLambda2()83 	public void testLambda2() throws Exception {
84 		String[] signature= {};
85 		String[] newNames= { "x" };
86 		String[] newTypes= { "int" };
87 		String[] newDefaultValues= { "0" };
88 		ParameterInfo[] newParamInfo= createNewParamInfos(newTypes, newNames, newDefaultValues);
89 		int[] newIndices= { 0 };
90 		helperAdd(signature, newParamInfo, newIndices);
91 	}
92 
93 	// Rename method
94 	@Test
testLambda3()95 	public void testLambda3() throws Exception {
96 		String[] signature= { "QString;" };
97 		helperRenameMethod(signature, "newName", false, true);
98 	}
99 
100 	// Rename method involving method reference
101 	@Test
testMethodReference0()102 	public void testMethodReference0() throws Exception {
103 		String[] signature= {};
104 		helperRenameMethod(signature, "newName", false, true);
105 	}
106 
107 	// TODO Remove a method parameter
108 }