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;
}
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);
}
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;
}
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");
}
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");
}
Aggregations