use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class ApiNamespaceInspectionTest method runQuickFixTest.
private void runQuickFixTest(String annotationString, String expectedString) {
final Project myProject = myFixture.getProject();
PsiAnnotation annotation = JavaPsiFacade.getInstance(myProject).getElementFactory().createAnnotationFromText(annotationString, null);
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(annotation, "", ProblemHighlightType.ERROR);
ApiNamespaceInspection.MyQuickFix myQuickFix = new ApiNamespaceInspection().new MyQuickFix();
myQuickFix.applyFix(myProject, problemDescriptor);
assertEquals(expectedString, annotation.getText());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class FullMethodNameInspectionTest method testQuickFix_ApiMethodAnnotation.
/**
* Tests that the FullMethodNameInspection's quick fix updates the name attribute of {@link
* GctConstants.APP_ENGINE_ANNOTATION_API_METHOD} by adding "_1" as a suffix.
*/
public void testQuickFix_ApiMethodAnnotation() {
Project myProject = myFixture.getProject();
String annotationString = "@" + GctConstants.APP_ENGINE_ANNOTATION_API_METHOD + "(name = \"someName\")";
PsiAnnotation annotation = JavaPsiFacade.getInstance(myProject).getElementFactory().createAnnotationFromText(annotationString, null);
FullMethodNameInspection.MyQuickFix myQuickFix = new FullMethodNameInspection().new MyQuickFix();
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(annotation, "", ProblemHighlightType.ERROR);
myQuickFix.applyFix(myProject, problemDescriptor);
Assert.assertEquals("@" + GctConstants.APP_ENGINE_ANNOTATION_API_METHOD + "(name = \"someName_1\")", annotation.getText());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class FullJavaNameInspectionTest method testQuickFix.
public void testQuickFix() {
PsiMethod someFunction = JavaPsiFacade.getInstance(myFixture.getProject()).getElementFactory().createMethod("someFunction", PsiType.VOID);
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(someFunction, "", ProblemHighlightType.ERROR);
FullJavaNameInspection.MyQuickFix myQuickFix = new FullJavaNameInspection().new MyQuickFix();
myQuickFix.applyFix(myFixture.getProject(), problemDescriptor);
assertEquals("someFunction_1", someFunction.getName());
myQuickFix.applyFix(myFixture.getProject(), problemDescriptor);
assertEquals("someFunction_1_1", someFunction.getName());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class InvalidParameterAnnotationsInspectionTest method runQuickFixTest.
private void runQuickFixTest(PsiParameter parameter, String expectedString) {
InvalidParameterAnnotationsInspection.MyQuickFix myQuickFix = new InvalidParameterAnnotationsInspection.MyQuickFix();
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(parameter, "", ProblemHighlightType.ERROR);
myQuickFix.applyFix(myFixture.getProject(), problemDescriptor);
assertEquals(expectedString, parameter.getText());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class NamedResourceInspectionTest method testQuickFix_duplicateParameter.
/**
* Tests that the NamedResourceInspection's quick fix flagged with {@link
* NamedResourceError#DUPLICATE_PARAMETER} for an @Named annotation updates the query name by
* adding "_1" as a suffix.
*/
public void testQuickFix_duplicateParameter() {
Project myProject = myFixture.getProject();
String annotationString = "@" + GctConstants.APP_ENGINE_ANNOTATION_NAMED + "(\"someName\")";
PsiAnnotation annotation = JavaPsiFacade.getInstance(myProject).getElementFactory().createAnnotationFromText(annotationString, null);
NamedResourceInspection.DuplicateNameQuickFix myQuickFix = new NamedResourceInspection().new DuplicateNameQuickFix();
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(annotation, "", ProblemHighlightType.ERROR);
myQuickFix.applyFix(myProject, problemDescriptor);
assertEquals("@" + GctConstants.APP_ENGINE_ANNOTATION_NAMED + "(\"someName_1\")", annotation.getText());
}
Aggregations