Search in sources :

Example 1 with GaugeService

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);
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) GaugeService(com.thoughtworks.gauge.core.GaugeService) TextRange(com.intellij.openapi.util.TextRange)

Example 2 with GaugeService

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;
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) GaugeService(com.thoughtworks.gauge.core.GaugeService) GaugeConnection(com.thoughtworks.gauge.connection.GaugeConnection)

Example 3 with GaugeService

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();
}
Also used : GaugeService(com.thoughtworks.gauge.core.GaugeService)

Example 4 with GaugeService

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")));
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) GaugeService(com.thoughtworks.gauge.core.GaugeService)

Example 5 with GaugeService

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);
}
Also used : StepValue(com.thoughtworks.gauge.StepValue) GaugeService(com.thoughtworks.gauge.core.GaugeService) TextRange(com.intellij.openapi.util.TextRange)

Aggregations

GaugeService (com.thoughtworks.gauge.core.GaugeService)9 StepValue (com.thoughtworks.gauge.StepValue)4 GaugeConnection (com.thoughtworks.gauge.connection.GaugeConnection)4 TextRange (com.intellij.openapi.util.TextRange)2 IOException (java.io.IOException)2 Module (com.intellij.openapi.module.Module)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PluginNotInstalledException (com.thoughtworks.gauge.PluginNotInstalledException)1 UndoHandler (com.thoughtworks.gauge.undo.UndoHandler)1 Api (gauge.messages.Api)1 File (java.io.File)1