use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class LevelAssignmentTest method shouldAssignLevelsForUpstreamNodesOfCurrentPipeline.
@Test
public void shouldAssignLevelsForUpstreamNodesOfCurrentPipeline() throws Exception {
/*
---> p1 ---
/ \
g -----------p3
\ /
---> p2 ---
*/
String current = "p3";
Node p1 = new PipelineDependencyNode("p1", "p1");
Node p2 = new PipelineDependencyNode("p2", "p2");
Node gitNode = new SCMDependencyNode("git", "g", "git");
ValueStreamMap valueStreamMap = new ValueStreamMap(current, new PipelineRevision(current, 1, "1"));
valueStreamMap.addUpstreamNode(p1, new PipelineRevision("p1", 1, "1"), current);
valueStreamMap.addUpstreamNode(p2, new PipelineRevision("p2", 1, "1"), current);
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("trunk"), "p1", new MaterialRevision(null));
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p3", new MaterialRevision(null));
valueStreamMap.addUpstreamMaterialNode(gitNode, new CaseInsensitiveString("main-branch"), "p2", new MaterialRevision(null));
NodeLevelMap levelToNodeMap = new LevelAssignment().apply(valueStreamMap);
assertThat(valueStreamMap.getCurrentPipeline().getLevel(), is(0));
assertThat(p1.getLevel(), is(-1));
assertThat(p2.getLevel(), is(-1));
assertThat(gitNode.getLevel(), is(-2));
assertThat(levelToNodeMap.get(0), contains(valueStreamMap.getCurrentPipeline()));
assertThat(levelToNodeMap.get(-1), containsInAnyOrder(p1, p2));
assertThat(levelToNodeMap.get(-2), contains(gitNode));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class EnvironmentVariableContextTest method shouldPopulateEnvironmentForMaterialUsingDest.
@Test
public void shouldPopulateEnvironmentForMaterialUsingDest() {
SvnMaterial svn = MaterialsMother.svnMaterial();
svn.setFolder("svn-dir");
MaterialRevision revision = new MaterialRevision(svn, ModificationsMother.oneModifiedFile("revision1"));
MaterialRevisions materialRevisions = new MaterialRevisions(revision);
EnvironmentVariableContext context = new EnvironmentVariableContext();
context.setProperty("GO_SERVER_URL", SystemEnvironment.getProperty("serviceUrl"), false);
jobIdentifier().populateEnvironmentVariables(context);
materialRevisions.populateEnvironmentVariables(context, WORKING_DIR);
assertThat(context.getProperty("GO_REVISION_SVN_DIR"), is("revision1"));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevision.
@Test
public void shouldGetLatestRevision() {
SvnMaterial svn = svnMaterial(svnRepo.projectRepositoryUrl(), null);
SvnMaterial svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
final Materials materials = new Materials(svn, svnExt);
final MaterialRevisions materialRevisions = materials.latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
assertThat(materialRevisions.numberOfRevisions(), is(2));
MaterialRevision main = materialRevisions.getRevisions().get(0);
assertThat(main.getMaterial(), is(svn));
assertThat(main.getModifications().size(), is(1));
assertThat(main.getRevision().getRevision(), is("5"));
MaterialRevision external = materialRevisions.getRevisions().get(1);
assertThat(external.getMaterial(), is(svnExt));
assertThat(external.getRevision().getRevision(), is("4"));
assertThat(external.getModifications().size(), is(1));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class SvnExternalTest method shouldGetLatestRevisionFromExpandedSvnExternalRepository.
@Test
public void shouldGetLatestRevisionFromExpandedSvnExternalRepository() {
MaterialRevisions materialRevisions = new MaterialRevisions();
Material svnExt = svnMaterial(svnRepo.externalRepositoryUrl(), "end2end");
List<Modification> modifications = ((SvnMaterial) svnExt).latestModification(svnRepo.workingFolder(), new TestSubprocessExecutionContext());
materialRevisions.addRevision(svnExt, modifications);
assertThat(materialRevisions.numberOfRevisions(), is(1));
MaterialRevision materialRevision = materialRevisions.getRevisions().get(0);
assertThat(materialRevision.getMaterial(), is(svnExt));
assertThat(materialRevision.getRevision().getRevision(), is("4"));
}
use of com.thoughtworks.go.domain.MaterialRevision in project gocd by gocd.
the class StageConverter method createBuildCause.
private ArrayList<StageNotificationDTO.MaterialRevisionDTO> createBuildCause(BuildCause buildCause) {
ArrayList<StageNotificationDTO.MaterialRevisionDTO> revisions = new ArrayList<>();
for (MaterialRevision currentRevision : buildCause.getMaterialRevisions()) {
Map<String, Object> attributes = currentRevision.getMaterial().getAttributes(false);
ArrayList<StageNotificationDTO.ModificationDTO> modifications = new ArrayList<>();
for (Modification modification : currentRevision.getModifications()) {
modifications.add(new StageNotificationDTO.ModificationDTO(modification.getRevision(), modification.getModifiedTime(), modification.getAdditionalDataMap()));
}
revisions.add(new StageNotificationDTO.MaterialRevisionDTO(attributes, currentRevision.isChanged(), modifications));
}
return revisions;
}
Aggregations