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(""));
}
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"));
}
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));
}
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;
}
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;
}
Aggregations