use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class SpecificMaterialRevisionFactoryTest method shouldCreateDependencyMaterialForAPipeline.
@Test
public void shouldCreateDependencyMaterialForAPipeline() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream"), new CaseInsensitiveString("blah-stage"));
MaterialConfig dependencyMaterialConfig = dependencyMaterial.config();
MaterialRevision expected = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream/4/blah-stage/2", "MOCK_LABEL-12", null));
String upstreamFingerprint = "234fa4";
when(mockGoConfigService.findMaterial(new CaseInsensitiveString("blahPipeline"), upstreamFingerprint)).thenReturn(dependencyMaterialConfig);
when(materialConfigConverter.toMaterial(dependencyMaterialConfig)).thenReturn(dependencyMaterial);
when(mockMaterialChecker.findSpecificRevision(dependencyMaterial, "upstream/4/blah-stage/2")).thenReturn(expected);
MaterialRevisions materialRevisions = specificMaterialRevisionFactory.create("blahPipeline", Collections.singletonMap(upstreamFingerprint, "upstream/4/blah-stage/2"));
assertThat(materialRevisions, is(new MaterialRevisions(expected)));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldFindMaterialConfigBasedOnFingerprint.
@Test
public void shouldFindMaterialConfigBasedOnFingerprint() throws Exception {
SvnMaterialConfig expected = new SvnMaterialConfig("repo", null, null, false);
cruiseConfig = configWith(GoConfigMother.createPipelineConfigWithMaterialConfig(expected));
when(goConfigDao.load()).thenReturn(cruiseConfig);
MaterialConfig actual = goConfigService.materialForPipelineWithFingerprint("pipeline", expected.getFingerprint());
assertThat(actual, is(expected));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigServiceTest method shouldBeAbleToListAllSCMMaterialConfigs.
@Test
public void shouldBeAbleToListAllSCMMaterialConfigs() {
BasicCruiseConfig config = mock(BasicCruiseConfig.class);
DependencyMaterialConfig dependencyMaterialConfig = MaterialConfigsMother.dependencyMaterialConfig();
SvnMaterialConfig svnMaterialConfig = MaterialConfigsMother.svnMaterialConfig();
PluggableSCMMaterialConfig pluggableSCMMaterialConfig = MaterialConfigsMother.pluggableSCMMaterialConfig();
HashSet<MaterialConfig> materialConfigs = new HashSet<>(Arrays.asList(dependencyMaterialConfig, svnMaterialConfig, pluggableSCMMaterialConfig));
when(goConfigService.getCurrentConfig()).thenReturn(config);
when(config.getAllUniqueMaterialsBelongingToAutoPipelinesAndConfigRepos()).thenReturn(materialConfigs);
Set<MaterialConfig> schedulableDependencyMaterials = goConfigService.getSchedulableSCMMaterials();
assertThat(schedulableDependencyMaterials.size(), is(2));
assertTrue(schedulableDependencyMaterials.contains(svnMaterialConfig));
assertTrue(schedulableDependencyMaterials.contains(pluggableSCMMaterialConfig));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class MaterialConfigServiceTest method shouldPopulateErrorCorrectlyWhenMaterialNotFound_getMaterialConfigByFingerprint.
@Test
public void shouldPopulateErrorCorrectlyWhenMaterialNotFound_getMaterialConfigByFingerprint() {
HttpOperationResult result = new HttpOperationResult();
MaterialConfig materialConfig = materialConfigService.getMaterialConfig(user, "unknown-fingerprint", result);
assertThat(materialConfig, is(nullValue()));
assertThat(result.httpCode(), is(404));
}
use of com.thoughtworks.go.domain.materials.MaterialConfig in project gocd by gocd.
the class GoConfigFileHelper method addMaterialToPipeline.
public PipelineConfig addMaterialToPipeline(String pipelineName, MaterialConfig materialConfig) {
CruiseConfig config = loadForEdit();
PipelineConfig pipelineConfig = config.pipelineConfigByName(new CaseInsensitiveString(pipelineName));
for (MaterialConfig materialConfig1 : new MaterialConfig[] { materialConfig }) {
pipelineConfig.addMaterialConfig(materialConfig1);
}
writeConfigFile(config);
return pipelineConfig;
}
Aggregations