Search in sources :

Example 6 with SpecStepImpl

use of com.thoughtworks.gauge.language.psi.impl.SpecStepImpl in project Intellij-Plugin by getgauge.

the class ReferenceSearchHelperTest method testGetReferenceElements.

@Test
public void testGetReferenceElements() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    when(element.getProject()).thenReturn(project);
    StepValue stepValue = new StepValue("hello", "", new ArrayList<>());
    ReferencesSearch.SearchParameters searchParameters = new ReferencesSearch.SearchParameters(element, scope, true);
    when(element.getStepValue()).thenReturn(stepValue);
    ReferenceSearchHelper referenceSearchHelper = new ReferenceSearchHelper();
    referenceSearchHelper.getPsiElements(collector, searchParameters.getElementToSearch());
    verify(collector, times(1)).get("hello");
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) ReferencesSearch(com.intellij.psi.search.searches.ReferencesSearch) Test(org.junit.Test)

Example 7 with SpecStepImpl

use of com.thoughtworks.gauge.language.psi.impl.SpecStepImpl in project Intellij-Plugin by getgauge.

the class StepAnnotatorTest method testShouldAnnotateBlankSpecStep.

@Test
public void testShouldAnnotateBlankSpecStep() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    when(helper.isGaugeModule(element)).thenReturn(true);
    when(helper.isEmpty(element)).thenReturn(true);
    when(element.getTextRange()).thenReturn(textRange);
    new StepAnnotator(helper).annotate(element, holder);
    verify(holder, times(1)).createErrorAnnotation(textRange, "Step should not be blank");
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) Test(org.junit.Test)

Example 8 with SpecStepImpl

use of com.thoughtworks.gauge.language.psi.impl.SpecStepImpl in project Intellij-Plugin by getgauge.

the class StepAnnotatorTest method testShouldNotAnnotateInNonGaugeModule.

@Test
public void testShouldNotAnnotateInNonGaugeModule() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    when(helper.isGaugeModule(element)).thenReturn(false);
    new StepAnnotator(helper).annotate(element, holder);
    verify(holder, never()).createErrorAnnotation(any(TextRange.class), any(String.class));
}
Also used : SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) TextRange(com.intellij.openapi.util.TextRange) Test(org.junit.Test)

Example 9 with SpecStepImpl

use of com.thoughtworks.gauge.language.psi.impl.SpecStepImpl in project Intellij-Plugin by getgauge.

the class StepAnnotatorTest method testShouldAnnotateInGaugeModule.

@Test
public void testShouldAnnotateInGaugeModule() throws Exception {
    SpecStepImpl element = mock(SpecStepImpl.class);
    Module module = mock(Module.class);
    when(helper.isGaugeModule(element)).thenReturn(true);
    when(element.getTextRange()).thenReturn(textRange);
    when(helper.getModule(element)).thenReturn(module);
    when(helper.isEmpty(element)).thenReturn(false);
    when(helper.isImplemented(element, module)).thenReturn(false);
    when(holder.createErrorAnnotation(textRange, "Undefined Step")).thenReturn(new Annotation(1, 1, new HighlightSeverity("dsf", 1), "", ""));
    new StepAnnotator(helper).annotate(element, holder);
    verify(holder, times(1)).createErrorAnnotation(textRange, "Undefined Step");
}
Also used : HighlightSeverity(com.intellij.lang.annotation.HighlightSeverity) SpecStepImpl(com.thoughtworks.gauge.language.psi.impl.SpecStepImpl) Module(com.intellij.openapi.module.Module) Annotation(com.intellij.lang.annotation.Annotation) Test(org.junit.Test)

Aggregations

SpecStepImpl (com.thoughtworks.gauge.language.psi.impl.SpecStepImpl)9 Test (org.junit.Test)7 ReferencesSearch (com.intellij.psi.search.searches.ReferencesSearch)4 Annotation (com.intellij.lang.annotation.Annotation)1 HighlightSeverity (com.intellij.lang.annotation.HighlightSeverity)1 Module (com.intellij.openapi.module.Module)1 TextRange (com.intellij.openapi.util.TextRange)1 PsiElement (com.intellij.psi.PsiElement)1 StepValue (com.thoughtworks.gauge.StepValue)1 Nullable (org.jetbrains.annotations.Nullable)1