Search in sources :

Example 1 with PipelineConfigSaveValidationContext

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]."));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 2 with PipelineConfigSaveValidationContext

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]."));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 3 with PipelineConfigSaveValidationContext

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]."));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) SCM(com.thoughtworks.go.domain.scm.SCM) Test(org.junit.Test)

Example 4 with PipelineConfigSaveValidationContext

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]."));
}
Also used : PipelineConfigSaveValidationContext(com.thoughtworks.go.config.PipelineConfigSaveValidationContext) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

PipelineConfigSaveValidationContext (com.thoughtworks.go.config.PipelineConfigSaveValidationContext)4 Test (org.junit.Test)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)2 SCM (com.thoughtworks.go.domain.scm.SCM)2