Search in sources :

Example 56 with PackageDefinition

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

the class UpdatePackageConfigCommandTest method shouldValidateIfPackageNameIsNull.

@Test
public void shouldValidateIfPackageNameIsNull() throws Exception {
    PackageRepository repository = cruiseConfig.getPackageRepositories().find("repoId");
    PackageDefinition pkg = new PackageDefinition("Id", null, new Configuration());
    pkg.setRepository(repository);
    repository.addPackage(pkg);
    cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
    UpdatePackageConfigCommand command = new UpdatePackageConfigCommand(goConfigService, packageUuid, pkg, currentUser, "md5", this.entityHashingService, result, packageDefinitionService);
    command.update(cruiseConfig);
    assertFalse(command.isValid(cruiseConfig));
    assertThat(pkg.errors().size(), is(1));
    assertThat(pkg.errors().firstError(), is("Package name is mandatory"));
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 57 with PackageDefinition

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

the class GoConfigMaterialsTest method getPackageMaterialConfigWithAutoUpdateTrue.

private PackageMaterialConfig getPackageMaterialConfigWithAutoUpdateTrue() {
    PackageDefinition packageDefinition = new PackageDefinition("packageWithAutoUpdateFalse", "DTDC Package", new Configuration());
    packageDefinition.setRepository(PackageRepositoryMother.create("DTDC"));
    packageDefinition.setAutoUpdate(true);
    return new PackageMaterialConfig(new CaseInsensitiveString("Krish"), "packageWithAutoUpdateTrue", packageDefinition);
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Configuration(com.thoughtworks.go.domain.config.Configuration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition)

Example 58 with PackageDefinition

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

the class JsonMessageHandler2_0_Test method createPipeline.

private Pipeline createPipeline() throws Exception {
    Pipeline pipeline = PipelineMother.pipelineWithAllTypesOfMaterials("pipeline-name", "stage-name", "job-name", "1");
    List<MaterialRevision> materialRevisions = pipeline.getMaterialRevisions().getRevisions();
    PackageDefinition packageDefinition = ((PackageMaterial) materialRevisions.get(6).getMaterial()).getPackageDefinition();
    packageDefinition.getRepository().getConfiguration().get(1).handleSecureValueConfiguration(true);
    packageDefinition.getConfiguration().addNewConfigurationWithValue("k4", "package-v2", false);
    packageDefinition.getConfiguration().get(1).handleSecureValueConfiguration(true);
    SCM scm = ((PluggableSCMMaterial) materialRevisions.get(7).getMaterial()).getScmConfig();
    scm.getConfiguration().get(1).handleSecureValueConfiguration(true);
    Stage stage = pipeline.getFirstStage();
    stage.setId(1L);
    stage.setPipelineId(1L);
    stage.setCreatedTime(new Timestamp(getFixedDate().getTime()));
    stage.setLastTransitionedTime(new Timestamp(getFixedDate().getTime()));
    JobInstance job = stage.getJobInstances().get(0);
    job.setScheduledDate(getFixedDate());
    job.getTransition(JobState.Assigned).setStateChangeTime(getFixedDate());
    job.getTransition(JobState.Completed).setStateChangeTime(getFixedDate());
    return pipeline;
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SCM(com.thoughtworks.go.domain.scm.SCM) Timestamp(java.sql.Timestamp)

Example 59 with PackageDefinition

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

the class MagicalGoConfigXmlWriterTest method shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue.

@Test
public void shouldNotWriteToFileWithDefaultValueOfTrueForPackageDefinitionAutoUpdateWhenTrue() throws Exception {
    Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    Packages packages = new Packages();
    PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
    PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
    aPackage.setAutoUpdate(true);
    packages.add(aPackage);
    aPackage.setRepository(repository);
    cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
    xmlWriter.write(cruiseConfig, output, false);
    assertThat(output.toString().contains("autoUpdate=\"true\""), is(false));
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Packages(com.thoughtworks.go.domain.packagerepository.Packages) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Example 60 with PackageDefinition

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

the class MagicalGoConfigXmlWriterTest method shouldWriteRepositoryConfigurationWithPackages.

@Test
public void shouldWriteRepositoryConfigurationWithPackages() throws Exception {
    CruiseConfig configToSave = new BasicCruiseConfig();
    PackageRepository packageRepository = new PackageRepository();
    packageRepository.setId("id");
    packageRepository.setName("name");
    packageRepository.setPluginConfiguration(new PluginConfiguration("plugin-id", "version"));
    packageRepository.setConfiguration(new Configuration(getConfigurationProperty("url", false, "http://go"), getConfigurationProperty("secure", true, "secure")));
    PackageDefinition packageDefinition = new PackageDefinition("id", "name", new Configuration(getConfigurationProperty("name", false, "go-agent")));
    packageDefinition.setRepository(packageRepository);
    packageRepository.getPackages().add(packageDefinition);
    configToSave.getPackageRepositories().add(packageRepository);
    xmlWriter.write(configToSave, output, false);
    GoConfigHolder goConfigHolder = xmlLoader.loadConfigHolder(output.toString());
    PackageRepositories packageRepositories = goConfigHolder.config.getPackageRepositories();
    assertThat(packageRepositories, is(configToSave.getPackageRepositories()));
    assertThat(packageRepositories.get(0).getConfiguration().first().getConfigurationValue().getValue(), is("http://go"));
    assertThat(packageRepositories.get(0).getConfiguration().first().getEncryptedConfigurationValue(), is(nullValue()));
    assertThat(packageRepositories.get(0).getConfiguration().last().getEncryptedValue(), is(new GoCipher().encrypt("secure")));
    assertThat(packageRepositories.get(0).getConfiguration().last().getConfigurationValue(), is(nullValue()));
    assertThat(packageRepositories.get(0).getPackages().get(0), is(packageDefinition));
    assertThat(packageRepositories.get(0).getPackages().get(0).getConfiguration().first().getConfigurationValue().getValue(), is("go-agent"));
    assertThat(packageRepositories.get(0).getPackages().get(0).getConfiguration().first().getEncryptedConfigurationValue(), is(nullValue()));
}
Also used : GoCipher(com.thoughtworks.go.security.GoCipher) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRepositories(com.thoughtworks.go.domain.packagerepository.PackageRepositories) PackageRepository(com.thoughtworks.go.domain.packagerepository.PackageRepository) Test(org.junit.Test)

Aggregations

PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)69 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)9 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)7 Serializable (java.io.Serializable)7 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 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)3 SCM (com.thoughtworks.go.domain.scm.SCM)3 GoConfigMother (com.thoughtworks.go.helper.GoConfigMother)3 Username (com.thoughtworks.go.server.domain.Username)3 Timestamp (java.sql.Timestamp)3