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"));
}
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();
}
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()));
}
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));
}
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;
}
Aggregations