use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class NamedResourceInspectionTest method testQuickFix_noQueryNameSpecifiedWithoutParameter.
/**
* Tests that the NamedResourceInspection's quick fix flagged with {@link
* NamedResourceError#MISSING_NAME} for an @Named annotation with no parent updates the query name
* to "myName".
*/
public void testQuickFix_noQueryNameSpecifiedWithoutParameter() {
Project myProject = myFixture.getProject();
String annotationString = "@" + GctConstants.APP_ENGINE_ANNOTATION_NAMED + "()";
PsiAnnotation annotation = JavaPsiFacade.getInstance(myProject).getElementFactory().createAnnotationFromText(annotationString, null);
NamedResourceInspection.MissingNameQuickFix myQuickFix = new NamedResourceInspection().new MissingNameQuickFix();
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(annotation, "", ProblemHighlightType.ERROR);
myQuickFix.applyFix(myProject, problemDescriptor);
assertEquals("@" + GctConstants.APP_ENGINE_ANNOTATION_NAMED + "(\"myName\")", annotation.getText());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class NamedResourceInspectionTest method testQuickFix_noQueryNameSpecifiedWithParameter.
/**
* Tests that the NamedResourceInspection's quick fix flagged with {@link
* NamedResourceError#MISSING_NAME} for an @Named annotation with a {@link PsiParameter} parent
* updates the query name to to the name of the {@link PsiParameter}.
*/
public void testQuickFix_noQueryNameSpecifiedWithParameter() {
Project myProject = myFixture.getProject();
PsiParameter parameter = JavaPsiFacade.getInstance(myProject).getElementFactory().createParameterFromText("@javax.inject.Named() String foobar", null);
PsiAnnotation[] annotationsList = parameter.getModifierList().getAnnotations();
assert (annotationsList.length == 1);
NamedResourceInspection.MissingNameQuickFix myQuickFix = new NamedResourceInspection().new MissingNameQuickFix();
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(annotationsList[0], "", ProblemHighlightType.ERROR);
myQuickFix.applyFix(myProject, problemDescriptor);
assertEquals("@javax.inject.Named(\"foobar\")", annotationsList[0].getText());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class ApiParameterInspectionTest method runQuickFixTest.
private void runQuickFixTest(String parameterText, String expectedString) {
Project myProject = myFixture.getProject();
PsiParameter parameter = JavaPsiFacade.getInstance(myProject).getElementFactory().createParameterFromText(parameterText, null);
ApiParameterInspection.MyQuickFix myQuickFix = new ApiParameterInspection().new MyQuickFix();
MockProblemDescriptor problemDescriptor = new MockProblemDescriptor(parameter, "", ProblemHighlightType.ERROR);
myQuickFix.applyFix(myFixture.getProject(), problemDescriptor);
Assert.assertEquals(expectedString, parameter.getText());
}
use of com.intellij.testFramework.MockProblemDescriptor in project google-cloud-intellij by GoogleCloudPlatform.
the class FullMethodNameInspectionTest method testQuickFix_NonApiMethodAnnotation.
/**
* Tests that the FullMethodNameInspection's quick fix does not update an annotation that is not
* {@link GctConstants.APP_ENGINE_ANNOTATION_API_METHOD}
*/
public void testQuickFix_NonApiMethodAnnotation() {
Project myProject = myFixture.getProject();
String annotationString = "@" + GctConstants.APP_ENGINE_ANNOTATION_NAMED + "(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(annotationString, annotation.getText());
}
Aggregations