use of com.thoughtworks.gauge.core.GaugeService 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.core.GaugeService 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.core.GaugeService in project Intellij-Plugin by getgauge.
the class ExtractConceptRequest method makeExtractConceptRequest.
public Api.ExtractConceptResponse makeExtractConceptRequest(PsiElement element) {
GaugeService gaugeService = Gauge.getGaugeService(ModuleUtil.findModuleForPsiElement(element), true);
String message = "Cannot connect to gauge service.";
if (gaugeService != null)
try {
return gaugeService.getGaugeConnection().sendGetExtractConceptRequest(steps, concept, refactorOtherUsages, fileName, textInfo);
} catch (Exception ignored) {
message = "Something went wrong during extract concept request.";
LOG.debug(ignored);
}
return Api.ExtractConceptResponse.newBuilder().setIsSuccess(false).setError(message).build();
}
use of com.thoughtworks.gauge.core.GaugeService in project Intellij-Plugin by getgauge.
the class StepCompletionProviderTest method testStepAutoCompletion.
public void testStepAutoCompletion() throws Exception {
myFixture.configureByFiles("SimpleSpec.spec", "SimpleSpec.txt");
Gauge.addModule(myFixture.getModule(), new GaugeService(mockProcess, mockGaugeConnection));
StepValue stepValue1 = new StepValue("This is a step", "This is a step");
StepValue stepValue2 = new StepValue("Hello", "Hello");
StepValue stepValue3 = new StepValue("The step", "The step");
when(mockGaugeConnection.fetchAllSteps()).thenReturn(asList(stepValue1, stepValue2, stepValue3));
myFixture.getEditor().getCaretModel().moveToOffset(49);
myFixture.complete(CompletionType.BASIC, 1);
List<String> strings = myFixture.getLookupElementStrings();
assertEquals(2, strings.size());
assertTrue(strings.containsAll(asList("This is a step", "The step")));
}
use of com.thoughtworks.gauge.core.GaugeService in project Intellij-Plugin by getgauge.
the class StepCompletionProviderTest method testStepAutoCompleteShouldReplaceBracesOfOnlyParams.
public void testStepAutoCompleteShouldReplaceBracesOfOnlyParams() 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 {} and >", "This is a step with <param> and >", 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\" and >";
String actual = myFixture.getEditor().getDocument().getText(new TextRange(47, 81));
assertEquals(expected, actual);
}
Aggregations