use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method currentPipelineShouldHaveWarningsIfBuiltFromIncompatibleRevisions.
@Test
public void currentPipelineShouldHaveWarningsIfBuiltFromIncompatibleRevisions() {
String current = "current";
ValueStreamMap valueStreamMap = new ValueStreamMap(current, null);
SCMDependencyNode scmDependencyNode = new SCMDependencyNode("id", "git_node", "git");
MaterialRevision rev1 = new MaterialRevision(MaterialsMother.gitMaterial("git/repo/url"), ModificationsMother.oneModifiedFile("rev1"));
MaterialRevision rev2 = new MaterialRevision(MaterialsMother.gitMaterial("git/repo/url"), ModificationsMother.oneModifiedFile("rev2"));
valueStreamMap.addUpstreamMaterialNode(scmDependencyNode, new CaseInsensitiveString("git"), valueStreamMap.getCurrentPipeline().getId(), rev1);
valueStreamMap.addUpstreamMaterialNode(scmDependencyNode, new CaseInsensitiveString("git"), valueStreamMap.getCurrentPipeline().getId(), rev2);
valueStreamMap.addWarningIfBuiltFromInCompatibleRevisions();
assertThat(valueStreamMap.getCurrentPipeline().getViewType(), is(is(VSMViewType.WARNING)));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ValueStreamMapTest method shouldNotPopulateDuplicateNamesForAMaterial.
@Test
public void shouldNotPopulateDuplicateNamesForAMaterial() {
/*
git_fingerprint -> P1 -> P2
|_________________________^
*/
String P1 = "P1";
String currentPipeline = "P2";
ValueStreamMap graph = new ValueStreamMap(currentPipeline, null);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "git", "git"), new CaseInsensitiveString("git1"), currentPipeline, new MaterialRevision(null));
graph.addUpstreamNode(new PipelineDependencyNode(P1, P1), null, currentPipeline);
graph.addUpstreamMaterialNode(new SCMDependencyNode("git_fingerprint", "git", "git"), new CaseInsensitiveString("git1"), P1, new MaterialRevision(null));
SCMDependencyNode node = (SCMDependencyNode) graph.findNode("git_fingerprint");
HashSet<String> materialNames = new HashSet<>();
materialNames.add("git1");
assertThat(node.getMaterialNames(), is(materialNames));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method shouldUnderstandChangedMaterial_forManual_triggerWithOptions_DoneWithANewRevision.
@Test
public void shouldUnderstandChangedMaterial_forManual_triggerWithOptions_DoneWithANewRevision() throws Exception {
SvnMaterial svn = SvnMaterial.createSvnMaterialWithMock(repository);
MaterialRevisions revsAfterFoo = checkinFile(svn, "foo.c", svnRepository);
String revisionForFingerPrint = revsAfterFoo.findRevisionForFingerPrint(svn.getFingerprint()).getRevision().getRevision();
scheduleHelper.manuallySchedulePipelineWithRealMaterials(MINGLE_PIPELINE_NAME, new Username(new CaseInsensitiveString("loser")), m(new MaterialConfigConverter().toMaterial(mingleConfig.materialConfigs().get(0)).getPipelineUniqueFingerprint(), revisionForFingerPrint));
assertThat(pipelineScheduleQueue.toBeScheduled().keySet(), hasItem(MINGLE_PIPELINE_NAME));
BuildCause bisectAfterBisectBuildCause = pipelineScheduleQueue.toBeScheduled().get(MINGLE_PIPELINE_NAME);
for (MaterialRevision materialRevision : bisectAfterBisectBuildCause.getMaterialRevisions()) {
assertThat("material revision " + materialRevision + " should have been considered changed.", materialRevision.isChanged(), is(true));
}
assertThat(bisectAfterBisectBuildCause.getMaterialRevisions().getRevisions().size(), is(1));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class BuildCauseProducerServiceIntegrationTest method verifyChanged.
private void verifyChanged(Material material, BuildCause bc, final boolean changed) {
MaterialRevision svn2MaterialRevision = bc.getMaterialRevisions().findRevisionForFingerPrint(material.getFingerprint());
assertThat("material revision " + svn2MaterialRevision + " was marked as" + (changed ? " not" : "") + " changed", svn2MaterialRevision.isChanged(), is(changed));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class ChangesetServiceIntegrationTest method shouldReturnModsOfItsOwnAndAllUpstreamPipelinesForTheGivenCounter.
@Test
public void shouldReturnModsOfItsOwnAndAllUpstreamPipelinesForTheGivenCounter() {
SvnMaterial svn = MaterialsMother.svnMaterial("http://svn");
PipelineConfig grandFatherPipeline = configHelper.addPipeline("granpa", "stage", svn.config(), "job");
DependencyMaterial parentDependencyMaterial = MaterialsMother.dependencyMaterial("granpa", "stage");
PipelineConfig upstreamPipeline = configHelper.addPipeline("upstream", "stage", git.config(), "job");
upstreamPipeline.addMaterialConfig(parentDependencyMaterial.config());
DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial("upstream", "stage");
pipelineConfigWithTwoMaterials.addMaterialConfig(dependencyMaterial.config());
pipelineConfigWithTwoMaterials.removeMaterialConfig(git.config());
Username username = new Username(new CaseInsensitiveString("user1"));
// Schedule grandfather
List<MaterialRevision> revisionsForGrandfather1 = new ArrayList<>();
addRevisionWith2Mods(revisionsForGrandfather1, svn);
Pipeline grandFatherOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), grandFatherPipeline, revisionsForGrandfather1);
// Schedule upstream
List<MaterialRevision> revisionsForUpstream1 = new ArrayList<>();
addRevisionWith2Mods(revisionsForUpstream1, git);
dbHelper.addDependencyRevisionModification(revisionsForUpstream1, parentDependencyMaterial, grandFatherOne);
Pipeline upstreamOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), upstreamPipeline, revisionsForUpstream1);
// Schedule downstream
List<MaterialRevision> revisionsForPipeline1 = new ArrayList<>();
addRevisionWith2Mods(revisionsForPipeline1, hg);
dbHelper.addDependencyRevisionModification(revisionsForPipeline1, dependencyMaterial, upstreamOne);
Pipeline pipelineOne = dbHelper.checkinRevisionsToBuild(new ManualBuild(username), pipelineConfigWithTwoMaterials, revisionsForPipeline1);
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
List<MaterialRevision> actual = changesetService.revisionsBetween(CaseInsensitiveString.str(pipelineConfigWithTwoMaterials.name()), pipelineOne.getCounter(), pipelineOne.getCounter(), username, result, true, false);
List<MaterialRevision> expectedRevisions = groupByMaterial(revisionsForGrandfather1, revisionsForUpstream1, revisionsForPipeline1);
assertMaterialRevisions(expectedRevisions, actual);
assertThat(result.isSuccessful(), is(true));
}
Aggregations