Search in sources :

Example 11 with PackageDefinition

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

the class MagicalGoConfigXmlWriterTest method shouldWriteToFileWithValueOfFalseForPackageDefinitionAutoUpdateWhenFalse.

@Test
public void shouldWriteToFileWithValueOfFalseForPackageDefinitionAutoUpdateWhenFalse() throws Exception {
    Configuration configuration = new Configuration(getConfigurationProperty("url", false, "http://go"));
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    Packages packages = new Packages();
    PackageDefinition aPackage = new PackageDefinition("package-id", "package-name", configuration);
    aPackage.setAutoUpdate(false);
    packages.add(aPackage);
    PackageRepository repository = createPackageRepository("plugin-id", "version", "id", "name", configuration, packages);
    cruiseConfig.setPackageRepositories(new PackageRepositories(repository));
    xmlWriter.write(cruiseConfig, output, false);
    assertThat(output.toString().contains("autoUpdate=\"false\""), is(true));
}
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 12 with PackageDefinition

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

the class PackageDefinitionServiceIntegrationTest method shouldReturnTheExactLocalizeMessageIfItFailsToCreatePackageDefinition.

@Test
public void shouldReturnTheExactLocalizeMessageIfItFailsToCreatePackageDefinition() throws Exception {
    String packageUuid = "random-uuid";
    String packageName = "prettyjson";
    Configuration configuration = new Configuration();
    configuration.add(new ConfigurationProperty(new ConfigurationKey("PACKAGE_ID"), new ConfigurationValue("prettyjson")));
    PackageDefinition packageDefinition = new PackageDefinition(packageUuid, packageName, configuration);
    HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
    HttpLocalizedOperationResult expectedResult = new HttpLocalizedOperationResult();
    String repositoryId = "Id";
    expectedResult.unprocessableEntity(LocalizedMessage.string("PACKAGE_REPOSITORY_NOT_FOUND", repositoryId));
    assertNull(service.find(packageUuid));
    service.createPackage(packageDefinition, repositoryId, user, result);
    assertThat(result, is(expectedResult));
    assertNull(service.find(packageUuid));
}
Also used : HttpLocalizedOperationResult(com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult) ContextConfiguration(org.springframework.test.context.ContextConfiguration) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) Test(org.junit.Test)

Example 13 with PackageDefinition

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

the class ConfigConverterTest method shouldConvertPackageMaterial.

@Test
public void shouldConvertPackageMaterial() {
    PackageRepositories repositories = new PackageRepositories();
    PackageRepository packageRepository = new PackageRepository();
    PackageDefinition definition = new PackageDefinition("package-id", "n", new Configuration());
    packageRepository.addPackage(definition);
    repositories.add(packageRepository);
    BasicCruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setPackageRepositories(repositories);
    when(cachedGoConfig.currentConfig()).thenReturn(cruiseConfig);
    CRPackageMaterial crPackageMaterial = new CRPackageMaterial("name", "package-id");
    PackageMaterialConfig packageMaterialConfig = (PackageMaterialConfig) configConverter.toMaterialConfig(crPackageMaterial, context);
    assertThat(packageMaterialConfig.getName().toLower(), is("name"));
    assertThat(packageMaterialConfig.getPackageId(), is("package-id"));
    assertThat(packageMaterialConfig.getPackageDefinition(), is(definition));
}
Also used : PackageMaterialConfig(com.thoughtworks.go.config.materials.PackageMaterialConfig) Configuration(com.thoughtworks.go.domain.config.Configuration) PluginConfiguration(com.thoughtworks.go.domain.config.PluginConfiguration) 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 14 with PackageDefinition

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

the class PackageMaterialConfigTest method shouldDelegateToPackageDefinitionForAutoUpdate.

@Test
public void shouldDelegateToPackageDefinitionForAutoUpdate() throws Exception {
    PackageDefinition packageDefinition = mock(PackageDefinition.class);
    when(packageDefinition.isAutoUpdate()).thenReturn(false);
    PackageMaterialConfig materialConfig = new PackageMaterialConfig(new CaseInsensitiveString("name"), "package-id", packageDefinition);
    assertThat(materialConfig.isAutoUpdate(), is(false));
    verify(packageDefinition).isAutoUpdate();
}
Also used : PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 15 with PackageDefinition

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

the class JsonMessageHandler1_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.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)

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