Search in sources :

Example 61 with Modification

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)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) JSONObject(com.sdicons.json.model.JSONObject) HashMap(java.util.HashMap) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) JSONArray(com.sdicons.json.model.JSONArray) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) Date(java.util.Date) Test(org.junit.Test)

Example 62 with Modification

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));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ValueStreamMap(com.thoughtworks.go.domain.valuestreammap.ValueStreamMap) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PipelineDependencyNode(com.thoughtworks.go.domain.valuestreammap.PipelineDependencyNode) SCMDependencyNode(com.thoughtworks.go.domain.valuestreammap.SCMDependencyNode) Node(com.thoughtworks.go.domain.valuestreammap.Node) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) ScheduleTestUtil(com.thoughtworks.go.server.service.ScheduleTestUtil) Test(org.junit.Test)

Example 63 with Modification

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())));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Graph(com.thoughtworks.studios.shine.semweb.Graph) StageXmlViewModel(com.thoughtworks.go.server.domain.xml.StageXmlViewModel) JobXmlViewModel(com.thoughtworks.go.server.domain.xml.JobXmlViewModel) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) Stage(com.thoughtworks.go.domain.Stage) Date(java.util.Date) Pipeline(com.thoughtworks.go.domain.Pipeline) Test(org.junit.Test)

Example 64 with Modification

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);
    }
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Graph(com.thoughtworks.studios.shine.semweb.Graph) TestFailureSetup(com.thoughtworks.go.server.dao.sparql.TestFailureSetup) XSLTTransformerRegistry(com.thoughtworks.studios.shine.semweb.grddl.XSLTTransformerRegistry) Date(java.util.Date) Test(org.junit.Test)

Example 65 with Modification

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);
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) ArrayList(java.util.ArrayList) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Date(java.util.Date)

Aggregations

Modification (com.thoughtworks.go.domain.materials.Modification)246 Test (org.junit.Test)176 Date (java.util.Date)76 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)65 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)54 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)40 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)38 ArrayList (java.util.ArrayList)35 File (java.io.File)25 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)21 Modifications (com.thoughtworks.go.domain.materials.Modifications)21 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)20 Material (com.thoughtworks.go.domain.materials.Material)20 Username (com.thoughtworks.go.server.domain.Username)17 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)16 HashMap (java.util.HashMap)16 StringContains.containsString (org.hamcrest.core.StringContains.containsString)15 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)14 Stage (com.thoughtworks.go.domain.Stage)13 ModifiedFile (com.thoughtworks.go.domain.materials.ModifiedFile)13