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 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 MaterialRevisions method updateToCommand.
public BuildCommand updateToCommand(String baseDir) {
List<BuildCommand> commands = new ArrayList<>();
for (MaterialRevision revision : revisions) {
Material material = revision.getMaterial();
if (material instanceof ScmMaterial) {
if (material instanceof GitMaterial) {
GitMaterialUpdater updater = new GitMaterialUpdater((GitMaterial) material);
commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
} else if (material instanceof HgMaterial) {
HgMaterialUpdater updater = new HgMaterialUpdater((HgMaterial) material);
commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
} else if (material instanceof SvnMaterial) {
SvnMaterialUpdater updater = new SvnMaterialUpdater((SvnMaterial) material);
commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
} else if (material instanceof PackageMaterial) {
// do nothing
} else if (material instanceof TfsMaterial) {
TfsMaterialUpdater updater = new TfsMaterialUpdater((TfsMaterial) material);
commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
} else if (material instanceof P4Material) {
P4MaterialUpdater updater = new P4MaterialUpdater((P4Material) material);
commands.add(updater.updateTo(baseDir, revision.toRevisionContext()));
} else {
commands.add(BuildCommand.fail("%s Material is not supported for new build command agent", material.getTypeForDisplay()));
}
}
}
return BuildCommand.compose(commands);
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class HgMaterialInstance method toOldMaterial.
@Override
public Material toOldMaterial(String name, String folder, String password) {
HgMaterial hg = new HgMaterial(url, folder);
setName(name, hg);
hg.setId(id);
return hg;
}
use of com.thoughtworks.go.config.materials.mercurial.HgMaterial in project gocd by gocd.
the class MaterialsTest method shouldGetMaterialByFolderWhenHasOnlyOneMaterial.
@Test
public void shouldGetMaterialByFolderWhenHasOnlyOneMaterial() {
Materials materials = new Materials();
HgMaterial material1 = MaterialsMother.hgMaterial();
materials.add(material1);
assertThat(materials.byFolder(material1.getFolder()), is(material1));
}
Aggregations