Search in sources :

Example 86 with Configuration

use of com.thoughtworks.go.domain.config.Configuration 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.Test)

Example 87 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PluggableTaskTest method isValidShouldVerifyForValidConfigurationProperties.

@Test
public void isValidShouldVerifyForValidConfigurationProperties() {
    PluginConfiguration pluginConfiguration = new PluginConfiguration("github.pr", "1.1");
    Configuration configuration = mock(Configuration.class);
    PluggableTaskConfigStore.store().setPreferenceFor(pluginConfiguration.getId(), mock(TaskPreference.class));
    when(configuration.hasErrors()).thenReturn(true);
    PluggableTask pluggableTask = new PluggableTask(pluginConfiguration, configuration);
    assertFalse(pluggableTask.isValid());
    verify(configuration).validateTree();
    verify(configuration).hasErrors();
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) TaskPreference(com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference) Test(org.junit.Test)

Example 88 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PackageMaterialConfigTest method shouldGetNameFromRepoNameAndPackageName.

@Test
public void shouldGetNameFromRepoNameAndPackageName() {
    PackageMaterialConfig materialConfig = new PackageMaterialConfig();
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo-name", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
    materialConfig.setPackageDefinition(PackageDefinitionMother.create("p-id", "package-name", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2")), repository));
    assertThat(materialConfig.getName().toString(), is("repo-name:package-name"));
    materialConfig.setPackageDefinition(null);
    assertThat(materialConfig.getName(), is(nullValue()));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 89 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class PackageMaterialConfigTest method shouldCheckEquals.

@Test
public void shouldCheckEquals() throws Exception {
    PackageRepository repository = PackageRepositoryMother.create("repo-id", "repo-name", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", "package-name", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2")), repository);
    PackageMaterialConfig p1 = new PackageMaterialConfig();
    p1.setPackageDefinition(packageDefinition);
    PackageMaterialConfig p2 = new PackageMaterialConfig();
    p2.setPackageDefinition(packageDefinition);
    assertThat(p1.equals(p2), is(true));
    p1 = new PackageMaterialConfig();
    p2 = new PackageMaterialConfig();
    assertThat(p1.equals(p2), is(true));
    p2.setPackageDefinition(packageDefinition);
    assertThat(p1.equals(p2), is(false));
    p1.setPackageDefinition(packageDefinition);
    p2 = new PackageMaterialConfig();
    assertThat(p1.equals(p2), is(false));
    assertThat(p1.equals(null), is(false));
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 90 with Configuration

use of com.thoughtworks.go.domain.config.Configuration in project gocd by gocd.

the class MaterialConfigsMother method packageMaterialConfig.

public static PackageMaterialConfig packageMaterialConfig(String repoName, String packageName) {
    PackageMaterialConfig material = new PackageMaterialConfig("p-id");
    PackageRepository repository = PackageRepositoryMother.create("repo-id", repoName, "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "repo-v1"), ConfigurationPropertyMother.create("k2", false, "repo-v2")));
    PackageDefinition packageDefinition = PackageDefinitionMother.create("p-id", packageName, new Configuration(ConfigurationPropertyMother.create("k3", false, "package-v1")), repository);
    material.setPackageDefinition(packageDefinition);
    repository.getPackages().add(packageDefinition);
    return material;
}
Also used : Configuration(com.thoughtworks.go.domain.config.Configuration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository)

Aggregations

Configuration (com.thoughtworks.go.domain.config.Configuration)136 Test (org.junit.Test)114 PluginConfiguration (com.thoughtworks.go.domain.config.PluginConfiguration)97 PackageConfiguration (com.thoughtworks.go.plugin.access.packagematerial.PackageConfiguration)34 ConfigurationProperty (com.thoughtworks.go.domain.config.ConfigurationProperty)29 ConfigurationValue (com.thoughtworks.go.domain.config.ConfigurationValue)20 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)18 SCM (com.thoughtworks.go.domain.scm.SCM)17 SCMConfiguration (com.thoughtworks.go.plugin.access.scm.SCMConfiguration)17 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)17 TaskConfig (com.thoughtworks.go.plugin.api.task.TaskConfig)16 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)15 PackageConfigurations (com.thoughtworks.go.plugin.access.packagematerial.PackageConfigurations)14 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)13 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)12 TaskPreference (com.thoughtworks.go.plugin.access.pluggabletask.TaskPreference)12 EncryptedConfigurationValue (com.thoughtworks.go.domain.config.EncryptedConfigurationValue)11 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)11 SCMConfigurations (com.thoughtworks.go.plugin.access.scm.SCMConfigurations)10 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)9