Search in sources :

Example 1 with GaugeConnection

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

the class GaugeModuleComponent method initializeGaugeConnection.

private static GaugeConnection initializeGaugeConnection(int apiPort) {
    if (apiPort != -1) {
        LOG.warn("Initializing Gauge connection");
        GaugeConnection gaugeConn = null;
        for (int i = 1; i <= 10; i++) {
            try {
                gaugeConn = new GaugeConnection(apiPort);
                break;
            } catch (java.lang.RuntimeException ex) {
                LOG.warn("Unable to open connection on try " + i + ".   Waiting and trying again");
                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
        return gaugeConn;
    } else {
        return null;
    }
}
Also used : GaugeConnection(com.thoughtworks.gauge.connection.GaugeConnection)

Example 2 with GaugeConnection

use of com.thoughtworks.gauge.connection.GaugeConnection 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 GaugeConnection

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

the class GaugeLibHelper method gaugeLib.

private ProjectLib gaugeLib(Module module) {
    String libRoot;
    try {
        GaugeService gaugeService = Gauge.getGaugeService(module, true);
        if (gaugeService == null) {
            gaugeService = GaugeModuleComponent.createGaugeService(module);
        }
        GaugeConnection gaugeConnection = gaugeService.getGaugeConnection();
        if (gaugeConnection == null) {
            throw new IOException("Gauge api connection not established");
        }
        libRoot = gaugeConnection.getLibPath("java");
    } catch (IOException e) {
        System.err.println("Could not add gauge lib, add it manually: " + e.getMessage());
        LOG.debug("Could not add gauge lib, add it manually: " + e.getMessage());
        return null;
    } catch (PluginNotInstalledException e) {
        throw new RuntimeException("Gauge " + JAVA + " plugin is not installed.");
    }
    return new ProjectLib(GAUGE_LIB, new File(libRoot));
}
Also used : GaugeService(com.thoughtworks.gauge.core.GaugeService) GaugeConnection(com.thoughtworks.gauge.connection.GaugeConnection) IOException(java.io.IOException) PluginNotInstalledException(com.thoughtworks.gauge.PluginNotInstalledException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 4 with GaugeConnection

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

the class StepCompletionProvider method getStepsInModule.

private Collection<Type> getStepsInModule(Module module) {
    Map<String, Type> steps = getImplementedSteps(module);
    try {
        GaugeService gaugeService = Gauge.getGaugeService(module, true);
        if (gaugeService == null)
            return steps.values();
        GaugeConnection gaugeConnection = gaugeService.getGaugeConnection();
        if (gaugeConnection != null) {
            gaugeConnection.fetchAllSteps().forEach(s -> addStep(steps, s, STEP));
            gaugeConnection.fetchAllConcepts().forEach(concept -> addStep(steps, concept.getStepValue(), CONCEPT));
        }
    } catch (IOException ignored) {
        LOG.debug(ignored);
    }
    return steps.values();
}
Also used : GaugeService(com.thoughtworks.gauge.core.GaugeService) GaugeConnection(com.thoughtworks.gauge.connection.GaugeConnection) IOException(java.io.IOException)

Example 5 with GaugeConnection

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

the class GaugeModuleComponent method createGaugeService.

/**
 * Creates a gauge service for the particular module. GaugeService is used to make api calls to the gauge daemon process.
 *
 * @param module
 * @return
 */
public static GaugeService createGaugeService(Module module) {
    int freePortForApi = SocketUtils.findFreePortForApi();
    Process gaugeProcess = initializeGaugeProcess(freePortForApi, module);
    GaugeConnection gaugeConnection = initializeGaugeConnection(freePortForApi);
    GaugeService gaugeService = new GaugeService(gaugeProcess, gaugeConnection);
    Gauge.addModule(module, gaugeService);
    return gaugeService;
}
Also used : GaugeService(com.thoughtworks.gauge.core.GaugeService) GaugeConnection(com.thoughtworks.gauge.connection.GaugeConnection)

Aggregations

GaugeConnection (com.thoughtworks.gauge.connection.GaugeConnection)5 GaugeService (com.thoughtworks.gauge.core.GaugeService)4 IOException (java.io.IOException)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PluginNotInstalledException (com.thoughtworks.gauge.PluginNotInstalledException)1 StepValue (com.thoughtworks.gauge.StepValue)1 File (java.io.File)1