use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class MaterialCheckerTest method mod.
private Modification mod(final Long revision) {
Modification modification = new Modification("user", "comment", "em@il", new Date(12121), revision.toString());
modification.setId(revision);
return modification;
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class MaterialCheckerTest method shouldNOTSkipFindingRevisionsSinceForMaterialsThatAreNewlyAdded.
@Test
public void shouldNOTSkipFindingRevisionsSinceForMaterialsThatAreNewlyAdded() throws Exception {
SvnMaterial svnMaterial = new SvnMaterial("svnUrl", null, null, false);
SvnMaterial svnExternalMaterial = new SvnMaterial("svnExternalUrl", null, null, false);
Modification svnExternalModification = new Modification("user", "external commit", "em@il", new Date(), "3");
MaterialRevision previousSvnRevision = new MaterialRevision(svnMaterial, mod(1L));
Modification svnModification = new Modification("user", "commend", "em@il", new Date(), "2");
MaterialRevisions latestRevisions = new MaterialRevisions(new MaterialRevision(svnMaterial, svnModification), new MaterialRevision(svnExternalMaterial, svnExternalModification));
Mockito.when(materialRepository.findModificationsSince(svnMaterial, previousSvnRevision)).thenReturn(modifications(svnModification));
MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(new MaterialRevisions(), new Materials(svnMaterial, svnExternalMaterial), new MaterialRevisions(previousSvnRevision), latestRevisions);
assertThat(revisionsSince, is(new MaterialRevisions(new MaterialRevision(svnMaterial, svnModification), new MaterialRevision(svnExternalMaterial, svnExternalModification))));
Mockito.verify(materialRepository).findModificationsSince(svnMaterial, previousSvnRevision);
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class MaterialCheckerTest method shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision.
@Test
public void shouldUseLatestPipelineInstanceForDependentPipelineGivenThePreviousRevision() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
Stage passedStage = StageMother.passedStageInstance("stage-name", "job-name", "pipeline-name");
MaterialRevisions materialRevisions = new MaterialRevisions();
Modification previous = new Modification("Unknown", "Unknown", null, passedStage.completedDate(), "pipeline-name/1/stage-name/0");
MaterialRevision previousRevision = revisions(dependencyMaterial, previous).getMaterialRevision(0);
when(materialRepository.findModificationsSince(dependencyMaterial, previousRevision)).thenReturn(Arrays.asList(new Modification(new Date(), "pipeline-name/2/stage-name/0", "MOCK_LABEL-12", null)));
MaterialRevisions revisionsSince = materialChecker.findRevisionsSince(materialRevisions, new Materials(dependencyMaterial), new MaterialRevisions(previousRevision), new MaterialRevisions());
assertThat(revisionsSince.getMaterialRevision(0).getRevision().getRevision(), is("pipeline-name/2/stage-name/0"));
}
use of com.thoughtworks.go.domain.materials.Modification 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.Modification in project gocd by gocd.
the class ManualBuildTest method setUp.
@Before
public void setUp() {
manualBuild = new ManualBuild(new Username(new CaseInsensitiveString("cruise-user")));
SvnMaterial material = new SvnMaterial("http://foo.bar/baz", "user", "pass", false);
materialRevisions = new MaterialRevisions(new MaterialRevision(material, new Modification(new Date(), "1234", "MOCK_LABEL-12", null)));
}
Aggregations