Search in sources :

Example 1 with OnCancelConfig

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

Example 2 with OnCancelConfig

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

Example 3 with OnCancelConfig

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

Example 4 with OnCancelConfig

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

Aggregations

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