Search in sources :

Example 6 with GaugeSettingsModel

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

the class GaugeInspectionHelper method getErrors.

@NotNull
static List<GaugeError> getErrors(File directory) {
    try {
        GaugeSettingsModel settings = getGaugeSettings();
        ProcessBuilder processBuilder = new ProcessBuilder(settings.getGaugePath(), Constants.VALIDATE);
        GaugeUtil.setGaugeEnvironmentsTo(processBuilder, settings);
        processBuilder.directory(directory);
        Process process = processBuilder.start();
        process.waitFor();
        String[] errors = GaugeUtil.getOutput(process.getInputStream(), "\n").split("\n");
        return Arrays.stream(errors).map(GaugeError::getInstance).filter(Objects::nonNull).collect(Collectors.toList());
    } catch (IOException | InterruptedException | GaugeNotFoundException e) {
        e.printStackTrace();
    }
    return new ArrayList<>();
}
Also used : GaugeNotFoundException(com.thoughtworks.gauge.exception.GaugeNotFoundException) ArrayList(java.util.ArrayList) IOException(java.io.IOException) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with GaugeSettingsModel

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

the class GaugeWebBrowserPreview method getUrl.

@Nullable
@Override
protected Url getUrl(OpenInBrowserRequest request, VirtualFile virtualFile) throws BrowserException {
    try {
        if (!request.isAppendAccessToken())
            return null;
        GaugeSettingsModel settings = getGaugeSettings();
        Spectacle spectacle = new Spectacle(request.getProject(), settings);
        if (spectacle.isInstalled())
            return previewUrl(request, virtualFile, settings);
        spectacle.notifyToInstall();
    } catch (Exception e) {
        Messages.showWarningDialog(String.format("Unable to create html file for %s", virtualFile.getName()), "Error");
    }
    return null;
}
Also used : IOException(java.io.IOException) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel) Nullable(org.jetbrains.annotations.Nullable)

Example 8 with GaugeSettingsModel

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

the class GaugeUtil method getSettingsFromPATH.

private static GaugeSettingsModel getSettingsFromPATH(GaugeSettingsModel model) throws GaugeNotFoundException {
    String path = EnvironmentUtil.getValue("PATH");
    LOG.info("PATH => " + path);
    if (!StringUtils.isEmpty(path)) {
        for (String entry : path.split(File.pathSeparator)) {
            File file = new File(entry, gaugeExecutable());
            if (isValidGaugeExec(file)) {
                LOG.info("executable path from `PATH`: " + file.getAbsolutePath());
                return new GaugeSettingsModel(file.getAbsolutePath(), model.getHomePath(), model.useIntelliJTestRunner());
            }
        }
    }
    String msg = "Could not find executable in `PATH`. Please make sure Gauge is installed." + "\nIf Gauge is installed then set the Gauge executable path in settings -> tools -> gauge.";
    throw new GaugeNotFoundException(msg);
}
Also used : GaugeNotFoundException(com.thoughtworks.gauge.exception.GaugeNotFoundException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File) SpecFile(com.thoughtworks.gauge.language.SpecFile) GaugeSettingsModel(com.thoughtworks.gauge.settings.GaugeSettingsModel)

Aggregations

GaugeSettingsModel (com.thoughtworks.gauge.settings.GaugeSettingsModel)8 GaugeNotFoundException (com.thoughtworks.gauge.exception.GaugeNotFoundException)4 File (java.io.File)3 IOException (java.io.IOException)3 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Gson (com.google.gson.Gson)1 GsonBuilder (com.google.gson.GsonBuilder)1 GeneralCommandLine (com.intellij.execution.configurations.GeneralCommandLine)1 Notification (com.intellij.notification.Notification)1 Document (com.intellij.openapi.editor.Document)1 FileEditorManager (com.intellij.openapi.fileEditor.FileEditorManager)1 Project (com.intellij.openapi.project.Project)1 PsiFile (com.intellij.psi.PsiFile)1 GaugeExceptionHandler (com.thoughtworks.gauge.core.GaugeExceptionHandler)1 SpecFile (com.thoughtworks.gauge.language.SpecFile)1 ArrayList (java.util.ArrayList)1 NotNull (org.jetbrains.annotations.NotNull)1 Nullable (org.jetbrains.annotations.Nullable)1