use of com.thoughtworks.go.config.PipelineConfigSaveValidationContext in project gocd by gocd.
the class PackageMaterialConfigTest method shouldAddErrorIfPackageDoesNotExistsForGivenPackageId.
@Test
public void shouldAddErrorIfPackageDoesNotExistsForGivenPackageId() throws Exception {
PipelineConfigSaveValidationContext configSaveValidationContext = mock(PipelineConfigSaveValidationContext.class);
when(configSaveValidationContext.findPackageById(anyString())).thenReturn(mock(PackageRepository.class));
PackageRepository packageRepository = mock(PackageRepository.class);
when(packageRepository.doesPluginExist()).thenReturn(true);
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("package-name"), "package-id", PackageDefinitionMother.create("package-id"));
packageMaterialConfig.getPackageDefinition().setRepository(packageRepository);
packageMaterialConfig.validateTree(configSaveValidationContext);
assertThat(packageMaterialConfig.errors().getAll().size(), is(1));
assertThat(packageMaterialConfig.errors().on(PackageMaterialConfig.PACKAGE_ID), is("Could not find plugin for given package id:[package-id]."));
}
use of com.thoughtworks.go.config.PipelineConfigSaveValidationContext in project gocd by gocd.
the class PluggableSCMMaterialConfigTest method shouldAddErrorWhenAssociatedSCMPluginIsMissing.
@Test
public void shouldAddErrorWhenAssociatedSCMPluginIsMissing() throws Exception {
PipelineConfigSaveValidationContext configSaveValidationContext = mock(PipelineConfigSaveValidationContext.class);
when(configSaveValidationContext.findScmById(anyString())).thenReturn(mock(SCM.class));
SCM scmConfig = mock(SCM.class);
when(scmConfig.doesPluginExist()).thenReturn(false);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "usr/home", null);
pluggableSCMMaterialConfig.setScmId("scm-id");
pluggableSCMMaterialConfig.validateTree(configSaveValidationContext);
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Could not find plugin for scm-id: [scm-id]."));
}
use of com.thoughtworks.go.config.PipelineConfigSaveValidationContext in project gocd by gocd.
the class PluggableSCMMaterialConfigTest method shouldAddErrorWhenMatchingScmConfigDoesNotExist.
@Test
public void shouldAddErrorWhenMatchingScmConfigDoesNotExist() throws Exception {
PipelineConfigSaveValidationContext validationContext = mock(PipelineConfigSaveValidationContext.class);
when(validationContext.findScmById(anyString())).thenReturn(null);
SCM scmConfig = mock(SCM.class);
when(scmConfig.doesPluginExist()).thenReturn(true);
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = new PluggableSCMMaterialConfig(null, scmConfig, "usr/home", null);
pluggableSCMMaterialConfig.setScmId("scm-id");
pluggableSCMMaterialConfig.validateTree(validationContext);
assertThat(pluggableSCMMaterialConfig.errors().getAll().size(), is(1));
assertThat(pluggableSCMMaterialConfig.errors().on(PluggableSCMMaterialConfig.SCM_ID), is("Could not find SCM for given scm-id: [scm-id]."));
}
use of com.thoughtworks.go.config.PipelineConfigSaveValidationContext in project gocd by gocd.
the class PackageMaterialConfigTest method shouldAddErrorIfPackagePluginDoesNotExistsForGivenPackageId.
@Test
public void shouldAddErrorIfPackagePluginDoesNotExistsForGivenPackageId() throws Exception {
PipelineConfigSaveValidationContext configSaveValidationContext = mock(PipelineConfigSaveValidationContext.class);
when(configSaveValidationContext.findPackageById(anyString())).thenReturn(mock(PackageRepository.class));
PackageRepository packageRepository = mock(PackageRepository.class);
when(packageRepository.doesPluginExist()).thenReturn(false);
PackageMaterialConfig packageMaterialConfig = new PackageMaterialConfig(new CaseInsensitiveString("package-name"), "package-id", PackageDefinitionMother.create("package-id"));
packageMaterialConfig.getPackageDefinition().setRepository(packageRepository);
packageMaterialConfig.validateTree(configSaveValidationContext);
assertThat(packageMaterialConfig.errors().getAll().size(), is(1));
assertThat(packageMaterialConfig.errors().on(PackageMaterialConfig.PACKAGE_ID), is("Could not find plugin for given package id:[package-id]."));
}
Aggregations