Search in sources :

Example 1 with ModuleHelper

use of com.thoughtworks.gauge.helper.ModuleHelper in project Intellij-Plugin by getgauge.

the class ImplUsageProviderTest method TestIsImplicitUsageForClass.

@Test
public void TestIsImplicitUsageForClass() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    PsiClass c = mock(PsiClassImpl.class);
    PsiMethod method = mock(PsiMethod.class);
    PsiModifierList list = mock(PsiModifierList.class);
    PsiAnnotation annotation = mock(PsiAnnotation.class);
    when(annotation.getQualifiedName()).thenReturn(BeforeStep.class.getCanonicalName());
    when(list.getAnnotations()).thenReturn(new PsiAnnotation[] { annotation });
    when(method.getModifierList()).thenReturn(list);
    when(c.getMethods()).thenReturn(new PsiMethod[] { method });
    when(helper.isGaugeModule(c)).thenReturn(true);
    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(c);
    assertTrue(isUsed);
}
Also used : BeforeStep(com.thoughtworks.gauge.BeforeStep) ModuleHelper(com.thoughtworks.gauge.helper.ModuleHelper) Test(org.junit.Test)

Example 2 with ModuleHelper

use of com.thoughtworks.gauge.helper.ModuleHelper in project Intellij-Plugin by getgauge.

the class ImplUsageProviderTest method TestIsImplicitUsageForMethodParameter.

@Test
public void TestIsImplicitUsageForMethodParameter() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    SpecStep element = mock(SpecStepImpl.class);
    PsiParameter parameter = mock(PsiParameterImpl.class);
    when(parameter.getDeclarationScope()).thenReturn(element);
    when(helper.isGaugeModule(parameter)).thenReturn(true);
    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(parameter);
    assertTrue(isUsed);
}
Also used : ModuleHelper(com.thoughtworks.gauge.helper.ModuleHelper) SpecStep(com.thoughtworks.gauge.language.psi.SpecStep) Test(org.junit.Test)

Example 3 with ModuleHelper

use of com.thoughtworks.gauge.helper.ModuleHelper in project Intellij-Plugin by getgauge.

the class ImplUsageProviderTest method TestIsImplicitUsageForHook.

@Test
public void TestIsImplicitUsageForHook() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    PsiMethod method = mock(PsiMethod.class);
    PsiModifierList list = mock(PsiModifierList.class);
    PsiAnnotation annotation = mock(PsiAnnotation.class);
    when(annotation.getQualifiedName()).thenReturn(BeforeStep.class.getCanonicalName());
    when(list.getAnnotations()).thenReturn(new PsiAnnotation[] { annotation });
    when(method.getModifierList()).thenReturn(list);
    when(helper.isGaugeModule(method)).thenReturn(true);
    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(method);
    assertTrue(isUsed);
}
Also used : BeforeStep(com.thoughtworks.gauge.BeforeStep) ModuleHelper(com.thoughtworks.gauge.helper.ModuleHelper) Test(org.junit.Test)

Example 4 with ModuleHelper

use of com.thoughtworks.gauge.helper.ModuleHelper in project Intellij-Plugin by getgauge.

the class ImplUsageProviderTest method TestIsImplicitUsageForClassWithNoMethods.

@Test
public void TestIsImplicitUsageForClassWithNoMethods() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    PsiClass c = mock(PsiClassImpl.class);
    when(helper.isGaugeModule(c)).thenReturn(true);
    when(c.getMethods()).thenReturn(new PsiMethod[] {});
    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(c);
    assertFalse(isUsed);
}
Also used : ModuleHelper(com.thoughtworks.gauge.helper.ModuleHelper) Test(org.junit.Test)

Example 5 with ModuleHelper

use of com.thoughtworks.gauge.helper.ModuleHelper in project Intellij-Plugin by getgauge.

the class ImplUsageProviderTest method TestIsImplicitUsageWithNoElement.

@Test
public void TestIsImplicitUsageWithNoElement() throws Exception {
    ModuleHelper helper = mock(ModuleHelper.class);
    boolean isUsed = new ImplUsageProvider(null, helper).isImplicitUsage(null);
    assertFalse(isUsed);
}
Also used : ModuleHelper(com.thoughtworks.gauge.helper.ModuleHelper) Test(org.junit.Test)

Aggregations

ModuleHelper (com.thoughtworks.gauge.helper.ModuleHelper)11 Test (org.junit.Test)11 ASTNode (com.intellij.lang.ASTNode)4 PsiReference (com.intellij.psi.PsiReference)4 BeforeStep (com.thoughtworks.gauge.BeforeStep)2 SpecStep (com.thoughtworks.gauge.language.psi.SpecStep)1