use of com.thoughtworks.go.config.OnCancelConfig 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.config.OnCancelConfig in project gocd by gocd.
the class PluggableTaskTest method validateTreeShouldVerifyIfCancelTasksHasNestedCancelTask.
@Test
public void validateTreeShouldVerifyIfCancelTasksHasNestedCancelTask() {
PluggableTask pluggableTask = new PluggableTask(new PluginConfiguration(), new Configuration());
pluggableTask.onCancelConfig = mock(OnCancelConfig.class);
com.thoughtworks.go.domain.Task cancelTask = mock(com.thoughtworks.go.domain.Task.class);
when(pluggableTask.onCancelConfig.getTask()).thenReturn(cancelTask);
when(cancelTask.hasCancelTask()).thenReturn(true);
when(pluggableTask.onCancelConfig.validateTree(null)).thenReturn(true);
assertFalse(pluggableTask.validateTree(null));
assertThat(pluggableTask.errors().get("onCancelConfig").get(0), is("Cannot nest 'oncancel' within a cancel task"));
}
use of com.thoughtworks.go.config.OnCancelConfig 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.config.OnCancelConfig 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