Search in sources :

Example 36 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialAddWithExistingPackageDefinitionCommandTest method shouldHandleDeletedPackageDefinition.

@Test
public void shouldHandleDeletedPackageDefinition() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    String repoId = packageDefinition.getRepository().getId();
    String pkgId = "deleted-package-definition";
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithExistingPackageDefinitionCommand command = new PackageMaterialAddWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeCreated, admin, params);
    command.update(cruiseConfig);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    assertThat(pipelineConfig.materialConfigs().last() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig packageMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().last();
    assertThat(packageMaterial, is(materialToBeCreated));
    assertThat(packageMaterial.getPackageDefinition(), is(nullValue()));
    assertThat(packageMaterial.getPackageId(), is(nullValue()));
    verify(packageDefinitionService, never()).performPluginValidationsFor(Matchers.<PackageDefinition>any());
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 37 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialAddWithExistingPackageDefinitionCommandTest method shouldUpdateConfigWithNewMaterial.

@Test
public void shouldUpdateConfigWithNewMaterial() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    String repoId = packageDefinition.getRepository().getId();
    String pkgId = packageDefinition.getId();
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithExistingPackageDefinitionCommand command = new PackageMaterialAddWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeCreated, admin, params);
    command.update(cruiseConfig);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    assertThat(pipelineConfig.materialConfigs().last() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig packageMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().last();
    assertThat(packageMaterial, is(materialToBeCreated));
    assertThat(packageMaterial.getPackageDefinition(), is(packageDefinition));
    verify(packageDefinitionService, never()).performPluginValidationsFor(packageDefinition);
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 38 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialAddWithExistingPackageDefinitionCommandTest method shouldHandleDeletedPackageRepo.

@Test
public void shouldHandleDeletedPackageRepo() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    String repoId = "deleted-repo";
    String pkgId = packageDefinition.getId();
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialConfig materialToBeCreated = new PackageMaterialConfig();
    PackageMaterialAddWithExistingPackageDefinitionCommand command = new PackageMaterialAddWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeCreated, admin, params);
    command.update(cruiseConfig);
    PipelineConfig pipelineConfig = cruiseConfig.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
    assertThat(pipelineConfig.materialConfigs().last() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig packageMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().last();
    assertThat(packageMaterial, is(materialToBeCreated));
    assertThat(packageMaterial.getPackageDefinition(), is(nullValue()));
    assertThat(packageMaterial.getPackageId(), is(nullValue()));
    verify(packageDefinitionService, never()).performPluginValidationsFor(Matchers.<PackageDefinition>any());
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 39 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialSaveCommandTestBase method setup.

@Before
public void setup() throws Exception {
    initMocks(this);
    cruiseConfig = GoConfigMother.configWithPackageRepo("repo1");
    pipelineName = "test";
    PipelineConfig pipelineConfig = PipelineConfigMother.pipelineConfig(pipelineName);
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(0);
    pipelineConfig.materialConfigs().add(0, new PackageMaterialConfig(null, "repo1-pkg-1", packageDefinition));
    pipelineGroup = "grp1";
    cruiseConfig.addPipeline(pipelineGroup, pipelineConfig);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Before(org.junit.Before)

Example 40 with PackageDefinition

use of com.thoughtworks.go.domain.packagerepository.PackageDefinition in project gocd by gocd.

the class PackageMaterialUpdateWithExistingPackageDefinitionCommandTest method shouldUpdateMaterialWithExistingPackageDefinition.

@Test
public void shouldUpdateMaterialWithExistingPackageDefinition() {
    PackageDefinition packageDefinition = cruiseConfig.getPackageRepositories().get(0).getPackages().get(1);
    String repoId = packageDefinition.getRepository().getId();
    String pkgId = packageDefinition.getId();
    HashMap<String, Serializable> params = PackageDefinitionMother.paramsForPackageMaterialAssociation(repoId, pkgId);
    PackageMaterialUpdateWithExistingPackageDefinitionCommand command = new PackageMaterialUpdateWithExistingPackageDefinitionCommand(packageDefinitionService, securityService, pipelineName, materialToBeUpdated, admin, params);
    command.update(cruiseConfig);
    assertThat(pipelineConfig.materialConfigs().first() instanceof PackageMaterialConfig, is(true));
    PackageMaterialConfig editedMaterial = (PackageMaterialConfig) pipelineConfig.materialConfigs().first();
    assertThat(editedMaterial, is(materialToBeUpdated));
    assertThat(editedMaterial.getPackageDefinition(), is(packageDefinition));
    verify(packageDefinitionService, never()).performPluginValidationsFor(packageDefinition);
}
Also used : Serializable(java.io.Serializable) PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)68 Test (org.junit.Test)47 PackageRepository (com.thoughtworks.go.domain.packagerepository.PackageRepository)41 PackageRepositories (com.thoughtworks.go.domain.packagerepository.PackageRepositories)28 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)12 PackageMaterialConfig (com.thoughtworks.go.config.materials.PackageMaterialConfig)12 Configuration (com.thoughtworks.go.domain.config.Configuration)12 Packages (com.thoughtworks.go.domain.packagerepository.Packages)12 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)7 Serializable (java.io.Serializable)7 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)6 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)6 Before (org.junit.Before)6 GoConfigInvalidException (com.thoughtworks.go.config.exceptions.GoConfigInvalidException)4 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)4 Matchers.containsString (org.hamcrest.Matchers.containsString)4 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 Username (com.thoughtworks.go.server.domain.Username)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)2