Search in sources :

Example 16 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class BuildersTest method shouldNotBuildIfTheJobIsCanceled.

@Test
public void shouldNotBuildIfTheJobIsCanceled() throws Exception {
    StubGoPublisher goPublisher = new StubGoPublisher();
    EnvironmentVariableContext environmentVariableContext = new EnvironmentVariableContext();
    CommandBuilder builder = new CommandBuilder("echo", "hello", new File("."), new RunIfConfigs(FAILED), new com.thoughtworks.go.domain.builder.StubBuilder(), "");
    Builders builders = new Builders(Collections.singletonList(builder), goPublisher, null, null, null);
    builders.setIsCancelled(true);
    builders.build(environmentVariableContext, "utf-8");
    assertThat(goPublisher.getMessage(), is(""));
}
Also used : StubGoPublisher(com.thoughtworks.go.domain.StubGoPublisher) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) StubBuilder(com.thoughtworks.go.domain.builder.StubBuilder) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) CommandBuilder(com.thoughtworks.go.domain.builder.CommandBuilder) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 17 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class BuilderTest method shouldLogToConsoleOutWhenCancelling.

@Test
public void shouldLogToConsoleOutWhenCancelling() {
    StubBuilder stubBuilder = new StubBuilder();
    CommandBuilder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
    builder.cancel(goPublisher, environmentVariableContext, null);
    assertThat(goPublisher.getMessage(), containsString("Start to execute cancel task"));
    assertThat(goPublisher.getMessage(), containsString("Task is cancelled"));
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) File(java.io.File) Test(org.junit.Test)

Example 18 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class BuilderTest method shouldRunCancelBuilderWhenCancelled.

@Test
public void shouldRunCancelBuilderWhenCancelled() throws Exception {
    StubBuilder stubBuilder = new StubBuilder();
    CommandBuilder builder = new CommandBuilder("echo", "", new File("."), new RunIfConfigs(FAILED), stubBuilder, "");
    builder.cancel(goPublisher, environmentVariableContext, null);
    assertThat(stubBuilder.wasCalled, is(true));
}
Also used : RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) File(java.io.File) Test(org.junit.Test)

Example 19 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class BaseTaskRepresenter method fromJSON.

public static AbstractTask fromJSON(JsonReader jsonReader, AbstractTask task) {
    RunIfConfigs runIfConfigs = new RunIfConfigs();
    jsonReader.readArrayIfPresent("run_if", configs -> {
        configs.forEach(runIfConfig -> {
            runIfConfigs.add(new RunIfConfig(runIfConfig.getAsString()));
        });
    });
    task.setConditions(runIfConfigs);
    jsonReader.optJsonObject("on_cancel").ifPresent(onCancelReader -> {
        OnCancelConfig onCancelConfig = OnCancelRepresenter.fromJSON(jsonReader.readJsonObject("on_cancel"));
        task.setOnCancelConfig(onCancelConfig);
    });
    return task;
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig)

Example 20 with RunIfConfigs

use of com.thoughtworks.go.domain.RunIfConfigs in project gocd by gocd.

the class BaseTaskRepresenter method fromJSON.

public static AbstractTask fromJSON(JsonReader jsonReader, AbstractTask task) {
    RunIfConfigs runIfConfigs = new RunIfConfigs();
    jsonReader.readArrayIfPresent("run_if", configs -> {
        configs.forEach(runIfConfig -> {
            runIfConfigs.add(new RunIfConfig(runIfConfig.getAsString()));
        });
    });
    task.setConditions(runIfConfigs);
    jsonReader.optJsonObject("on_cancel").ifPresent(onCancelReader -> {
        OnCancelConfig onCancelConfig = OnCancelRepresenter.fromJSON(jsonReader.readJsonObject("on_cancel"));
        task.setOnCancelConfig(onCancelConfig);
    });
    return task;
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig)

Aggregations

RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)29 Test (org.junit.jupiter.api.Test)22 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)10 File (java.io.File)9 Test (org.junit.Test)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)3 OnCancelConfig (com.thoughtworks.go.config.OnCancelConfig)3 RunIfConfig (com.thoughtworks.go.config.RunIfConfig)3 CommandBuilder (com.thoughtworks.go.domain.builder.CommandBuilder)3 StubBuilder (com.thoughtworks.go.domain.builder.StubBuilder)3 Gson (com.google.gson.Gson)2 StubGoPublisher (com.thoughtworks.go.domain.StubGoPublisher)2 Builder (com.thoughtworks.go.domain.builder.Builder)2 HgUrlArgument (com.thoughtworks.go.util.command.HgUrlArgument)2 RunIf (com.googlecode.junit.ext.RunIf)1 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)1 BuildLogElement (com.thoughtworks.go.domain.BuildLogElement)1 FetchArtifactEnvironmentVariable (com.thoughtworks.go.plugin.access.artifact.models.FetchArtifactEnvironmentVariable)1 ArtifactRequestProcessor (com.thoughtworks.go.remote.work.artifact.ArtifactRequestProcessor)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1