Search in sources :

Example 31 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions 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)));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) Username(com.thoughtworks.go.server.domain.Username) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Before(org.junit.Before)

Example 32 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions 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 33 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class EnvironmentTest method shouldBeAbleToTellIfThereAreAnyPiplinesThatHaveNewMaterialRevisions.

@Test
public void shouldBeAbleToTellIfThereAreAnyPiplinesThatHaveNewMaterialRevisions() {
    MaterialRevisions latest = new MaterialRevisions();
    latest.addRevision(MaterialsMother.hgMaterial(), ModificationsMother.aCheckIn("21"));
    assertThat(new Environment("blah", Arrays.asList(pipeline(), pipelineWithLatestRevision(latest))).hasNewRevisions(), is(true));
    assertThat(new Environment("blah", Arrays.asList(pipeline(), pipelineWithLatestRevisionAndMaterialRevision(latest, latest))).hasNewRevisions(), is(false));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Test(org.junit.Test)

Example 34 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class PipelineInstanceModelTest method shouldFallbackToPipelineFingerpringWhenGettingCurrentMaterialRevisionForMaterialIsNull.

@Test
public void shouldFallbackToPipelineFingerpringWhenGettingCurrentMaterialRevisionForMaterialIsNull() {
    MaterialRevisions revisions = new MaterialRevisions();
    HgMaterial material = MaterialsMother.hgMaterial();
    HgMaterial materialWithDifferentDest = MaterialsMother.hgMaterial();
    materialWithDifferentDest.setFolder("otherFolder");
    revisions.addRevision(material, HG_MATERIAL_MODIFICATION);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(revisions, ""), new StageInstanceModels());
    assertThat(model.findCurrentMaterialRevisionForUI(materialWithDifferentDest.config()), is(revisions.getMaterialRevision(0)));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 35 with MaterialRevisions

use of com.thoughtworks.go.domain.MaterialRevisions in project gocd by gocd.

the class PipelineInstanceModelTest method shouldKnowApproverAsApproverForTheFirstStage.

@Test
public void shouldKnowApproverAsApproverForTheFirstStage() {
    MaterialRevisions revisions = new MaterialRevisions();
    StageInstanceModels models = new StageInstanceModels();
    StageInstanceModel firstStage = new StageInstanceModel("dev", "1", new JobHistory());
    firstStage.setApprovedBy("some_user");
    models.add(firstStage);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(revisions, ""), models);
    assertThat(model.getApprovedBy(), is("some_user"));
    assertThat(model.getApprovedByForDisplay(), is("Triggered by some_user"));
}
Also used : MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) Test(org.junit.Test)

Aggregations

MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)212 Test (org.junit.Test)166 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)111 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)68 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)55 Date (java.util.Date)49 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)46 Modification (com.thoughtworks.go.domain.materials.Modification)38 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)33 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)33 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)31 PipelineConfigDependencyGraph (com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph)31 Materials (com.thoughtworks.go.config.materials.Materials)27 Pipeline (com.thoughtworks.go.domain.Pipeline)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 Material (com.thoughtworks.go.domain.materials.Material)16 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)15 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)14 File (java.io.File)12