use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class ChangesetServiceIntegrationTest method testShouldGroupMaterialsBasedOnFingerprint.
@Test
public void testShouldGroupMaterialsBasedOnFingerprint() {
SvnMaterial first = new SvnMaterial("url", "user1", "password", false);
Modification mod1 = new Modification("user1", "comment", "email", new Date(), "revision");
mod1.setMaterialInstance(new SvnMaterialInstance("url", "user1", "flyweight1", false));
Modification mod2 = new Modification("user1", "comment", "email", new Date(), "revision");
mod2.setMaterialInstance(new SvnMaterialInstance("url", "user1", "flyweight1", false));
Map<Material, Modifications> map = changesetService.groupModsByMaterial(Arrays.asList(mod1, mod2));
assertThat(map.size(), is(1));
assertThat(map.get(first), is(new Modifications(mod1, mod2)));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class PackageMaterialUpdaterIntegrationTest method shouldUpdateMaterialInstanceWhenPluginIsUpgraded.
@Test
public void shouldUpdateMaterialInstanceWhenPluginIsUpgraded() throws Exception {
final PackageMaterial material = MaterialsMother.packageMaterial();
final MaterialInstance materialInstance = material.createMaterialInstance();
materialRepository.saveOrUpdate(materialInstance);
addMetadata(material, "fieldX", false);
material.getPackageDefinition().getConfiguration().addNewConfiguration("fieldX", true);
final List<Modification> modifications = ModificationsMother.multipleModificationList();
doNothing().when(scmMaterialUpdater).insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications(modifications));
transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus transactionStatus) {
packageMaterialUpdater.insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications(modifications));
return null;
}
});
MaterialInstance actualInstance = materialRepository.findMaterialInstance(material);
assertThat(actualInstance.getConfiguration(), is(material.createMaterialInstance().getConfiguration()));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class PluggableSCMMaterialUpdaterIntegrationTest method shouldUpdateMaterialInstanceWhenAdditionalDataIsUpdatedDuringLatestModification.
@Test
public void shouldUpdateMaterialInstanceWhenAdditionalDataIsUpdatedDuringLatestModification() throws Exception {
final PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
final MaterialInstance materialInstance = material.createMaterialInstance();
materialRepository.saveOrUpdate(materialInstance);
Map<String, String> data = new HashMap<>();
data.put("k1", "v1");
when(scmExtension.getLatestRevision(any(String.class), any(SCMPropertyConfiguration.class), any(Map.class), any(String.class))).thenReturn(new MaterialPollResult(data, new SCMRevision()));
mockSCMExtensionInPoller();
scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, materialService);
pluggableSCMMaterialUpdater = new PluggableSCMMaterialUpdater(materialRepository, scmMaterialUpdater, transactionTemplate);
transactionTemplate.execute(new TransactionCallback() {
@Override
public Object doInTransaction(TransactionStatus transactionStatus) {
pluggableSCMMaterialUpdater.insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications());
return null;
}
});
MaterialInstance actualInstance = materialRepository.findMaterialInstance(material);
assertThat(actualInstance.getAdditionalDataMap(), is(data));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateAllSCMMaterialRevisionsThatCausedPipelineRun_WhenFaninIsNotObeyed.
@Test
public void shouldPopulateAllSCMMaterialRevisionsThatCausedPipelineRun_WhenFaninIsNotObeyed() {
/*
* git---> p1 --->p2
* | ^
* +-------------+
* **/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
Modification modification1 = checkinWithComment("rev1", "comment1", new Date());
Modification modification2 = checkinWithComment("rev2", "comment2", new Date());
Modification modification3 = checkinWithComment("rev3", "comment3", new Date());
BuildCause p1buildCause = createBuildCauseForRevisions(new ArrayList<>(), asList(git), new Modifications(modification1, modification2));
BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1)), asList(git), new Modifications(modification3));
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config));
when(pipelineService.findPipelineByCounterOrLabel("p2", "1")).thenReturn(new Pipeline("p2", "LABEL-P2", p2buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p2", 1, user, result);
VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"));
VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-P2"));
VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, modification1, modification2), new MaterialRevision(git, false, modification3));
verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
use of com.thoughtworks.go.domain.materials.Modifications in project gocd by gocd.
the class ValueStreamMapServiceTest method shouldPopulateAllMaterialRevisionsThatCausedPipelineRun.
@Test
public void shouldPopulateAllMaterialRevisionsThatCausedPipelineRun() {
/*
* git---> p1 --->p2
* | ^
* +-------------+
* **/
GitMaterial git = new GitMaterial("git");
MaterialConfig gitConfig = git.config();
BuildCause p2buildCause = createBuildCauseForRevisions(asList(dependencyMaterial("p1", 1)), asList(git), ModificationsMother.multipleModificationList(0));
BuildCause p1buildCause = createBuildCause(new ArrayList<>(), asList(git));
Modifications gitModifications = p1buildCause.getMaterialRevisions().getMaterialRevision(0).getModifications();
when(pipelineService.buildCauseFor("p2", 1)).thenReturn(p2buildCause);
when(pipelineService.buildCauseFor("p1", 1)).thenReturn(p1buildCause);
PipelineConfig p1Config = PipelineConfigMother.pipelineConfig("p1", new MaterialConfigs(gitConfig));
PipelineConfig p2Config = PipelineConfigMother.pipelineConfig("p2", new MaterialConfigs(gitConfig));
CruiseConfig cruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(p1Config, p2Config));
when(pipelineService.findPipelineByCounterOrLabel("p2", "1")).thenReturn(new Pipeline("p2", "LABEL-P2", p2buildCause));
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
ValueStreamMapPresentationModel graph = valueStreamMapService.getValueStreamMap("p2", 1, user, result);
VSMTestHelper.assertNodeHasRevisions(graph, "p1", new PipelineRevision("p1", 1, "LABEL-p1-1"));
VSMTestHelper.assertNodeHasRevisions(graph, "p2", new PipelineRevision("p2", 1, "LABEL-P2"));
VSMTestHelper.assertSCMNodeHasMaterialRevisions(graph, git.getFingerprint(), new MaterialRevision(git, false, gitModifications));
verify(runStagesPopulator).apply(any(ValueStreamMap.class));
}
Aggregations