use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class MaterialRevisionsJsonBuilderTest method shouldNotProcessPackageMaterialComment.
@Test
public void shouldNotProcessPackageMaterialComment() throws Exception {
HashMap<String, String> map = new HashMap<>();
map.put("TYPE", "PACKAGE_MATERIAL");
map.put("TRACKBACK_URL", "google.com");
map.put("COMMENT", "comment");
String packageMaterialComment = JsonHelper.toJsonString(map);
Modification modification = new Modification("user", packageMaterialComment, "some@com", new Date(), "1234");
materialRevisions = new MaterialRevisions(new MaterialRevision(MaterialsMother.packageMaterial(), modification));
JSONArray jsonArray = buildJson();
JSONObject modificationJson = (JSONObject) ((JSONArray) ((JSONObject) jsonArray.get(0)).get("modifications")).get(0);
assertThat(modificationJson.get("comment").render(false), is(JsonHelper.toJsonString(packageMaterialComment)));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class DownstreamInstancePopulatorIntegrationTest method shouldPopulateInstancesBuiltFromCurrentMaterial.
@Test
public void shouldPopulateInstancesBuiltFromCurrentMaterial() {
/*
g1 -> P -> P2 --> P4
| \ /
| + P3 +
+-> Q
|
+-> R
*/
GitMaterial g1 = u.wf(new GitMaterial("g1"), "folder3");
u.checkinInOrder(g1, "g_1", "g_2");
ScheduleTestUtil.AddedPipeline p = u.saveConfigWith("p", u.m(g1));
ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(p));
ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p2));
ScheduleTestUtil.AddedPipeline p4 = u.saveConfigWith("p4", u.m(p2), u.m(p3));
ScheduleTestUtil.AddedPipeline q = u.saveConfigWith("q", u.m(g1));
ScheduleTestUtil.AddedPipeline r = u.saveConfigWith("r", u.m(g1));
String p_1 = u.runAndPass(p, "g_1");
String p2_1 = u.runAndPass(p2, p_1);
String p3_1 = u.runAndPass(p3, p2_1);
String p4_1 = u.runAndPass(p4, p2_1, p3_1);
String q_1 = u.runAndPass(q, "g_1");
String q_2 = u.runAndPass(q, "g_1");
MaterialInstance g1Instance = materialRepository.findMaterialInstance(g1);
Modification g1Modification = materialRepository.findModificationWithRevision(g1, "g_1");
ValueStreamMap valueStreamMap = new ValueStreamMap(g1, g1Instance, g1Modification);
Node gitNode = valueStreamMap.getCurrentMaterial();
Node nodep1 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p", "p"), gitNode.getId());
Node nodep2 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p");
Node nodep3 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p2");
Node nodep4 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p3");
valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p4", "p4"), "p2");
Node nodep5 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("q", "q"), gitNode.getId());
Node nodep6 = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("r", "r"), gitNode.getId());
downstreamInstancePopulator.apply(valueStreamMap);
assertInstances(nodep1, "p", 1);
assertInstances(nodep2, "p2", 1);
assertInstances(nodep3, "p3", 1);
assertInstances(nodep4, "p4", 1);
assertInstances(nodep5, "q", 1, 2);
assertThat(nodep6.revisions().size(), is(0));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class BackgroundStageLoaderIntegrationTest method handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage.
@Test
public void handleAStageURLNotYetSeenShouldStoreStageResourceIntoStageStorage() {
TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
loader.handle(feedEntry(savedStage), pipelineInstanceLoader);
assertTrue(stageStorage.isStageStored(savedStage.stageId));
Graph storedGraph = stageStorage.load(savedStage.stageId);
Stage stage = savedStage.stage;
String baseUrl = "https://localhost:8154/go";
String jobUrl = new JobXmlViewModel(stage.getJobInstances().first()).httpUrl(baseUrl);
assertTrue(storedGraph.containsResourceWithURI(jobUrl));
assertTrue(storedGraph.containsResourceWithURI(new StageXmlViewModel(stage).httpUrl(baseUrl)));
Pipeline pipeline = savedStage.pipeline;
assertTrue(storedGraph.containsResourceWithURI(PipelineXmlViewModel.httpUrlForPipeline(baseUrl, pipeline.getId(), pipeline.getName())));
Modification latestModification = pipeline.getMaterialRevisions().getRevisions().get(0).getLatestModification();
assertTrue(storedGraph.containsResourceWithURI(ScmMaterial.changesetUrl(latestModification, baseUrl, latestModification.getMaterialInstance().getId())));
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class StageResourceImporterTest method shouldImportPipelineBuildTriggers.
@Test
public void shouldImportPipelineBuildTriggers() throws Exception {
TestFailureSetup.SavedStage savedStage = failureSetup.setupPipelineInstanceWithoutTestXmlStubbing(true, null, new Date());
Graph graph = importer.load(savedStage.stageId, graphFactory, new XSLTTransformerRegistry());
for (Modification modification : savedStage.pipeline.getMaterialRevisions().getRevisions().get(0).getModifications()) {
String changeSetUri = ScmMaterial.changesetUrl(modification, baseUrl, modification.getMaterialInstance().getId());
assertTrue(graph.containsResourceWithURI(changeSetUri));
String ask = "" + "PREFIX cruise: <" + GoOntology.URI + "> " + "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#> " + "ASK WHERE {" + " <" + PipelineXmlViewModel.httpUrlForPipeline(baseUrl, savedStage.pipeline.getId(), savedStage.pipeline.getName()) + "> cruise:pipelineTrigger <" + changeSetUri + "> . " + "}";
assertAskIsTrue(graph, ask);
}
}
use of com.thoughtworks.go.domain.materials.Modification in project gocd by gocd.
the class DatabaseAccessHelper method addDependencyRevisionModification.
public List<MaterialRevision> addDependencyRevisionModification(List<MaterialRevision> materialRevisions, DependencyMaterial dependencyMaterial, Pipeline... upstreams) {
String stageName = CaseInsensitiveString.str(dependencyMaterial.getStageName());
String label = upstreams[0].getLabel();
List<Modification> modifications = new ArrayList<>();
for (Pipeline upstream : upstreams) {
modifications.add(new Modification(new Date(), DependencyMaterialRevision.create(CaseInsensitiveString.str(dependencyMaterial.getPipelineName()), upstream.getCounter(), label, stageName, upstream.findStage(stageName).getCounter()).getRevision(), label, upstream.getId()));
}
MaterialRevision depRev = addRevisionsWithModifications(dependencyMaterial, modifications.toArray(new Modification[0]));
materialRevisions.add(depRev);
return Arrays.asList(depRev);
}
Aggregations