use of com.thoughtworks.go.config.RunIfConfig 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.RunIfConfig in project gocd by gocd.
the class RunIfConfigsTest method shouldAddErrorsToErrorCollectionOfTheCollectionAsWellAsEachRunIfConfig.
@Test
public void shouldAddErrorsToErrorCollectionOfTheCollectionAsWellAsEachRunIfConfig() {
RunIfConfigs configs = new RunIfConfigs();
RunIfConfig config = new RunIfConfig("passed");
config.addError("status", "some error");
configs.add(config);
configs.addError("key", "some error");
assertThat(configs.errors().on("key"), is("some error"));
assertThat(configs.get(0).errors().on("status"), is("some error"));
}
use of com.thoughtworks.go.config.RunIfConfig 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.RunIfConfig 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