Search in sources :

Example 66 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class FaninDependencyResolutionTest method shouldResolveWithModifiedMaterialDefinitionOfRoot.

@Test
public void shouldResolveWithModifiedMaterialDefinitionOfRoot() throws Exception {
    /*
             +---> P1 ---+
             |           v
            git-------> P2 <---- hg
         */
    int i = 1;
    GitMaterial git1 = u.wf(new GitMaterial("git1"), "folder");
    String[] git_revs1 = { "g11" };
    u.checkinInOrder(git1, u.d(i++), git_revs1);
    HgMaterial hg = u.wf(new HgMaterial("hg", null), "folder1");
    String[] hg_revs1 = { "h11" };
    u.checkinInOrder(hg, u.d(i++), hg_revs1);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(git1));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(git1), u.m(p1));
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "g11");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "g11", p1_1);
    p2 = u.addMaterialToPipeline(p2, u.m(hg));
    MaterialRevisions given = u.mrs(u.mr(git1, true, "g11"), u.mr(p1, true, p1_1), u.mr(hg, true, "h11"));
    assertThat(getRevisionsBasedOnDependencies(p2, goConfigDao.load(), given), is(given));
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 67 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class MaterialRevisionTest method shouldUseLatestMaterial.

@Test
public void shouldUseLatestMaterial() throws Exception {
    MaterialRevision original = new MaterialRevision(hgMaterial, hgMaterial.modificationsSince(workingFolder, REVISION_0, new TestSubprocessExecutionContext()));
    HgMaterial newMaterial = MaterialsMother.hgMaterial(hgMaterial.getUrl());
    newMaterial.setFilter(new Filter(new IgnoredFiles("**/*.txt")));
    final MaterialRevision after = findNewRevision(original, newMaterial, workingFolder, new TestSubprocessExecutionContext());
    assertThat(after.getMaterial(), is(newMaterial));
}
Also used : Filter(com.thoughtworks.go.config.materials.Filter) IgnoredFiles(com.thoughtworks.go.config.materials.IgnoredFiles) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 68 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class MaterialInstanceTest method shouldSerializeAndUnserializeAllAttributes.

@Test
public void shouldSerializeAndUnserializeAllAttributes() throws IOException, ClassNotFoundException {
    HgMaterial m = MaterialsMother.hgMaterial("url");
    MaterialInstance materialInstance = m.createMaterialInstance();
    materialInstance.setId(10);
    ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);
    objectOutputStream.writeObject(materialInstance);
    ObjectInputStream inputStream1 = new ObjectInputStream(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
    MaterialInstance unserializedMaterial = (MaterialInstance) inputStream1.readObject();
    assertThat(unserializedMaterial, Matchers.is(materialInstance));
    assertThat(unserializedMaterial.getId(), is(10L));
    assertThat(unserializedMaterial, is(materialInstance));
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Test(org.junit.Test)

Example 69 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineInstanceModelTest method shouldReturnIfAnyMaterialHasModifications.

@Test
public void shouldReturnIfAnyMaterialHasModifications() {
    final SvnMaterial svnMaterial = svnMaterial("http://svnurl");
    final HgMaterial hgMaterial = hgMaterial("http://hgurl", "hgdir");
    MaterialRevisions currentRevisions = ModificationsMother.getMaterialRevisions(new HashMap<Material, String>() {

        {
            put(svnMaterial, "1");
            put(hgMaterial, "a");
        }
    });
    MaterialRevisions latestRevisions = ModificationsMother.getMaterialRevisions(new HashMap<Material, String>() {

        {
            put(svnMaterial, "1");
            put(hgMaterial, "b");
        }
    });
    MaterialConfigs materialConfigs = new MaterialConfigs();
    materialConfigs.add(svnMaterial.config());
    materialConfigs.add(hgMaterial.config());
    StageInstanceModels stages = new StageInstanceModels();
    stages.addStage("unit1", JobHistory.withJob("test", JobState.Completed, JobResult.Passed, new Date()));
    stages.addFutureStage("unit2", false);
    PipelineInstanceModel model = PipelineInstanceModel.createPipeline("pipeline", -1, "label", BuildCause.createWithModifications(currentRevisions, ""), stages);
    model.setLatestRevisions(latestRevisions);
    model.setMaterialConfigs(materialConfigs);
    assertThat("svnMaterial hasNewRevisions", model.hasNewRevisions(svnMaterial.config()), is(false));
    assertThat("hgMaterial hasNewRevisions", model.hasNewRevisions(hgMaterial.config()), is(true));
    assertThat("all materials hasNewRevisions", model.hasNewRevisions(), is(true));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) Material(com.thoughtworks.go.domain.materials.Material) MaterialsMother.hgMaterial(com.thoughtworks.go.helper.MaterialsMother.hgMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) MaterialsMother.svnMaterial(com.thoughtworks.go.helper.MaterialsMother.svnMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) Test(org.junit.Test)

Example 70 with HgMaterial

use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.

the class PipelineInstanceModelTest method shouldThrowExceptionWhenCurrentRevisionForUnknownMaterialNameRequested.

@Test
public void shouldThrowExceptionWhenCurrentRevisionForUnknownMaterialNameRequested() {
    HgMaterial material = MaterialsMother.hgMaterial();
    material.setName(new CaseInsensitiveString("foo"));
    try {
        assertThat(setUpModificationFor(material).getCurrentRevision("blah").getRevision(), is("a087402bd2a7828a130c1bdf43f2d9ef8f48fd46"));
        fail("should have raised an exeption for unknown material name");
    } catch (Exception ignored) {
    }
}
Also used : HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)119 Test (org.junit.Test)106 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)35 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)28 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)23 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)22 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)19 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)17 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)17 Material (com.thoughtworks.go.domain.materials.Material)15 Date (java.util.Date)10 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)9 ScheduleTestUtil (com.thoughtworks.go.server.service.ScheduleTestUtil)9 ServerHealthStateOperationResult (com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult)9 HgMaterialConfig (com.thoughtworks.go.config.materials.mercurial.HgMaterialConfig)8 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)7 Pagination (com.thoughtworks.go.server.util.Pagination)7 Modification (com.thoughtworks.go.domain.materials.Modification)6 File (java.io.File)6 MaterialUpdateStatusListener (com.thoughtworks.go.server.materials.MaterialUpdateStatusListener)5