Search in sources :

Example 1 with StepValue

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

the class StepUtil method getStepValue.

public static StepValue getStepValue(final GaugeConnection connection, final String text, Boolean hasInlineTable) {
    String stepText = hasInlineTable ? text + " <table>" : text;
    StepValue value = stepValueCache.get(stepText);
    if (value == null || value.getStepText().isEmpty()) {
        value = connection.getStepValue(text, hasInlineTable);
        stepValueCache.put(stepText, value);
    }
    return value;
}
Also used : StepValue(com.thoughtworks.gauge.StepValue)

Example 2 with StepValue

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

the class StepCompletionProviderTest method testStepAutoCompletionWithParams.

public void testStepAutoCompletionWithParams() throws Exception {
    myFixture.configureByFiles("SimpleSpec.spec", "SimpleSpec.txt");
    Gauge.addModule(myFixture.getModule(), new GaugeService(mockProcess, mockGaugeConnection));
    StepValue stepValue1 = new StepValue("This is a step with {}", "This is a step with <param>", asList("param"));
    when(mockGaugeConnection.fetchAllSteps()).thenReturn(asList(stepValue1));
    myFixture.getEditor().getCaretModel().moveToOffset(49);
    myFixture.complete(CompletionType.BASIC, 1);
    String expected = "*This is a step with \"param\"";
    String actual = myFixture.getEditor().getDocument().getText(new TextRange(47, 75));
    assertEquals(expected, actual);
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) GaugeService(com.thoughtworks.gauge.core.GaugeService) TextRange(com.intellij.openapi.util.TextRange)

Example 3 with StepValue

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

the class SpecPsiImplUtil method getStepValueFor.

public static StepValue getStepValueFor(Module module, PsiElement element, String stepText, Boolean hasInlineTable) {
    GaugeService gaugeService = Gauge.getGaugeService(module, false);
    if (gaugeService == null) {
        return getDefaultStepValue(element);
    }
    GaugeConnection apiConnection = gaugeService.getGaugeConnection();
    if (apiConnection == null) {
        return getDefaultStepValue(element);
    }
    StepValue value = StepUtil.getStepValue(apiConnection, stepText, hasInlineTable);
    return value == null ? getDefaultStepValue(element) : value;
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) GaugeService(com.thoughtworks.gauge.core.GaugeService) GaugeConnection(com.thoughtworks.gauge.connection.GaugeConnection)

Example 4 with StepValue

use of com.thoughtworks.gauge.StepValue 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 5 with StepValue

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

the class ReferenceSearchHelperTest method testGetReferenceElementsForConceptStep.

@Test
public void testGetReferenceElementsForConceptStep() throws Exception {
    ConceptStepImpl element = mock(ConceptStepImpl.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) ConceptStepImpl(com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl) ReferencesSearch(com.intellij.psi.search.searches.ReferencesSearch) Test(org.junit.Test)

Aggregations

StepValue (com.thoughtworks.gauge.StepValue)8 GaugeService (com.thoughtworks.gauge.core.GaugeService)4 TextRange (com.intellij.openapi.util.TextRange)3 ReferencesSearch (com.intellij.psi.search.searches.ReferencesSearch)2 Test (org.junit.Test)2 TemplateBuilder (com.intellij.codeInsight.template.TemplateBuilder)1 Editor (com.intellij.openapi.editor.Editor)1 OpenFileDescriptor (com.intellij.openapi.fileEditor.OpenFileDescriptor)1 PopupStep (com.intellij.openapi.ui.popup.PopupStep)1 BaseListPopupStep (com.intellij.openapi.ui.popup.util.BaseListPopupStep)1 Step (com.thoughtworks.gauge.Step)1 GaugeConnection (com.thoughtworks.gauge.connection.GaugeConnection)1 SpecStep (com.thoughtworks.gauge.language.psi.SpecStep)1 ConceptStepImpl (com.thoughtworks.gauge.language.psi.impl.ConceptStepImpl)1 SpecStepImpl (com.thoughtworks.gauge.language.psi.impl.SpecStepImpl)1