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));
}
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));
}
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));
}
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));
}
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) {
}
}
Aggregations