Search in sources :

Example 1 with RunIfConfig

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;
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig)

Example 2 with RunIfConfig

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"));
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) Test(org.junit.jupiter.api.Test)

Example 3 with RunIfConfig

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;
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig)

Example 4 with RunIfConfig

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;
}
Also used : RunIfConfig(com.thoughtworks.go.config.RunIfConfig) RunIfConfigs(com.thoughtworks.go.domain.RunIfConfigs) OnCancelConfig(com.thoughtworks.go.config.OnCancelConfig)

Aggregations

RunIfConfig (com.thoughtworks.go.config.RunIfConfig)4 OnCancelConfig (com.thoughtworks.go.config.OnCancelConfig)3 RunIfConfigs (com.thoughtworks.go.domain.RunIfConfigs)3 Test (org.junit.jupiter.api.Test)1