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));
}
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));
}
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));
}
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();
}
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;
}
Aggregations