ability to change name of method to any string constant. Detection of incorrect usages
[idea/community.git] / java / java-tests / testSrc / com / intellij / refactoring / ChangeSignatureTargetTest.java
1 /*
2  * User: anna
3  * Date: 25-Nov-2009
4  */
5 package com.intellij.refactoring;
6
7 import com.intellij.JavaTestUtil;
8 import com.intellij.openapi.projectRoots.Sdk;
9 import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
10 import com.intellij.psi.PsiElement;
11 import com.intellij.psi.PsiMember;
12 import com.intellij.refactoring.changeSignature.JavaChangeSignatureHandler;
13 import com.intellij.testFramework.LightCodeInsightTestCase;
14 import org.jetbrains.annotations.NonNls;
15
16 public class ChangeSignatureTargetTest extends LightCodeInsightTestCase {
17   @Override
18   protected String getTestDataPath() {
19     return JavaTestUtil.getJavaTestDataPath();
20   }
21
22   public void testInMethodParameters() throws Exception {
23     doTest("foo");
24   }
25
26   public void testInMethodArguments() throws Exception {
27     doTest("foo");
28   }
29
30   public void testInClassTypeParameters() throws Exception {
31     doTest("A1");
32   }
33
34   public void testInTypeArguments() throws Exception {
35     doTest("A1");
36   }
37
38   @Override
39   protected Sdk getProjectJDK() {
40     return JavaSdkImpl.getMockJdk15("java 1.5");
41   }
42
43   private void doTest(String expectedMemberName) throws Exception {
44     String basePath = "/refactoring/changeSignatureTarget/" + getTestName(true);
45     @NonNls final String filePath = basePath + ".java";
46     configureByFile(filePath);
47     final PsiElement member = new JavaChangeSignatureHandler().findTargetMember(getFile(), getEditor());
48     assertNotNull(member);
49     assertEquals(expectedMemberName, ((PsiMember)member).getName());
50   }
51 }