use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class SvnLogXmlParserTest method shouldParseBJCruiseLogCorrectly.
@Test
public void shouldParseBJCruiseLogCorrectly() {
String firstChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + " revision=\"11238\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:16.598195Z</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "<path\n" + " action=\"M\">/trunk/test/functional/cards_controller_quick_add_test.rb</path>\n" + "<path\n" + " action=\"M\">/trunk/app/controllers/cards_controller.rb</path>\n" + "</paths>\n" + "<msg>#2761, fix random test failure and add quick add card type to session</msg>\n" + "</logentry>\n" + "</log>";
String secondChangeLog = "<?xml version=\"1.0\"?>\n" + "<log>\n" + "<logentry\n" + " revision=\"11239\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:36.209014Z</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>still fix test</msg>\n" + "</logentry>\n" + "<logentry\n" + " revision=\"11240\">\n" + "<author>yxchu</author>\n" + "<date>2008-10-21T14:00:47.614448Z</date>\n" + "<paths>\n" + "<path\n" + " action=\"M\">/trunk/test/unit/card_selection_test.rb</path>\n" + "</paths>\n" + "<msg>fix test remove messaging helper</msg>\n" + "</logentry>\n" + "</log>";
SvnLogXmlParser parser = new SvnLogXmlParser();
List<Modification> mods = parser.parse(firstChangeLog, ".", new SAXBuilder());
assertThat(mods.get(0).getUserName(), is("yxchu"));
List<Modification> mods2 = parser.parse(secondChangeLog, ".", new SAXBuilder());
assertThat(mods2.size(), is(2));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class FanInGraph method createFinalRevisionsForScmChildren.
private List<MaterialRevision> createFinalRevisionsForScmChildren(PipelineTimelineEntry latestRootNodeInstance, List<RootFanInNode> scmChildren, List<DependencyFanInNode> depChildren) {
Set<FaninScmMaterial> scmMaterialsFromDepChildren = scmMaterialsOfDepChildren(depChildren);
List<MaterialRevision> finalRevisions = new ArrayList<>();
for (RootFanInNode child : scmChildren) {
child.setScmRevision(scmMaterialsFromDepChildren);
MaterialConfig materialConfig = child.materialConfig;
Material material = materialConfigConverter.toMaterial(materialConfig);
MaterialRevision revision = new MaterialRevision(material);
if (latestRootNodeInstance != null) {
PipelineInstanceModel pipeline = pipelineDao.findPipelineHistoryByNameAndCounter(latestRootNodeInstance.getPipelineName(), latestRootNodeInstance.getCounter());
for (MaterialRevision materialRevision : pipeline.getCurrentRevisions()) {
if (materialRevision.getMaterial().getFingerprint().equals(child.materialConfig.getFingerprint())) {
List<Modification> modificationsSince = materialRepository.findModificationsSinceAndUptil(material, materialRevision, child.scmRevision);
revision.addModifications(modificationsSince);
break;
}
}
}
if (revision.getModifications().isEmpty() && child.scmRevision == null) {
MaterialRevisions latestRevisions = materialRepository.findLatestRevisions(new MaterialConfigs(materialConfig));
finalRevisions.addAll(latestRevisions.getRevisions());
continue;
}
if (revision.getModifications().isEmpty()) {
revision = new MaterialRevision(material, materialRepository.findModificationWithRevision(material, child.scmRevision.revision));
}
finalRevisions.add(revision);
}
return finalRevisions;
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class FanInGraph method createFinalRevisionsForDepChildren.
private List<MaterialRevision> createFinalRevisionsForDepChildren(List<DependencyFanInNode> depChildren) {
List<MaterialRevision> finalRevisions = new ArrayList<>();
for (DependencyFanInNode child : depChildren) {
final List<Modification> modifications = materialRepository.modificationFor(child.currentRevision);
if (modifications.isEmpty()) {
throw new NoModificationsPresentForDependentMaterialException(child.currentRevision.stageLocator());
}
finalRevisions.add(new MaterialRevision(materialConfigConverter.toMaterial(child.materialConfig), modifications));
}
return finalRevisions;
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldCaptureUniqueModificationAuthorNamesAsBreakers_inCaseOfFailure.
@Test
public void shouldCaptureUniqueModificationAuthorNamesAsBreakers_inCaseOfFailure() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
Modification otherCommitOfUser1 = ModificationsMother.checkinWithComment("125", "comment 3", "user1", "user1@different-email.com", new Date(), "baz.c");
MaterialRevision revision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit, otherCommitOfUser1);
revision.markAsChanged();
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(new MaterialRevisions(revision));
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(failedStage());
assertThat(actualBreakers, is(s("user1", "user2")));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class CcTrayBreakersCalculatorTest method shouldCaptureAuthorNamesOfChangedRevisionsOnlyAsBreakers.
@Test
public void shouldCaptureAuthorNamesOfChangedRevisionsOnlyAsBreakers() throws Exception {
Modification user1Commit = ModificationsMother.checkinWithComment("123", "comment 1", "user1", "user1@domain1.com", new Date(), "foo.c");
Modification user2Commit = ModificationsMother.checkinWithComment("124", "comment 2", "user2", "user2@domain2.com", new Date(), "bar.c");
MaterialRevision changedRevision = new MaterialRevision(MaterialsMother.gitMaterial("foo.com"), user1Commit, user2Commit);
changedRevision.markAsChanged();
Modification user3CommitForUnchangedRevision = ModificationsMother.checkinWithComment("125", "comment 1", "user3", "user3@domain2.com", new Date(), "bar.c");
MaterialRevision unchangedRevision = new MaterialRevision(MaterialsMother.gitMaterial("bar.com"), user3CommitForUnchangedRevision);
MaterialRevisions revisions = new MaterialRevisions(changedRevision, unchangedRevision);
when(materialRepo.findMaterialRevisionsForPipeline(12l)).thenReturn(revisions);
CcTrayBreakersCalculator status = new CcTrayBreakersCalculator(materialRepo);
Set<String> actualBreakers = status.calculateFor(failedStage());
assertThat(actualBreakers, is(s("user1", "user2")));
}
Aggregations