use of com.thoughtworks.go.config.materials.tfs.TfsMaterial in project gocd by gocd.
the class Materials method latestModification.
@TestOnly
public MaterialRevisions latestModification(File baseDir, final SubprocessExecutionContext execCtx) {
MaterialRevisions revisions = new MaterialRevisions();
for (Material material : this) {
List<Modification> modifications = new ArrayList<>();
if (material instanceof SvnMaterial) {
modifications = ((SvnMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof HgMaterial) {
modifications = ((HgMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof GitMaterial) {
modifications = ((GitMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof P4Material) {
modifications = ((P4Material) material).latestModification(baseDir, execCtx);
}
if (material instanceof TfsMaterial) {
modifications = ((TfsMaterial) material).latestModification(baseDir, execCtx);
}
if (material instanceof DependencyMaterial) {
modifications = ((DependencyMaterial) material).latestModification(baseDir, execCtx);
}
revisions.addRevision(material, modifications);
}
return revisions;
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterial in project gocd by gocd.
the class MaterialRepositoryIntegrationTest method shouldFetchDetailsRelatedToTfs.
@Test
public void shouldFetchDetailsRelatedToTfs() {
TfsMaterial material = MaterialsMother.tfsMaterial("http://tfs.com");
MaterialRevisions materialRevisions = saveModifications(material, 1);
Modifications modificationList = materialRevisions.getModifications(material);
List<Modification> modifications = repo.getLatestModificationForEachMaterial();
assertThat(modifications.size(), is(1));
assertModificationAreEqual(modifications.get(0), modificationList.get(0));
MaterialInstance instance = modifications.get(0).getMaterialInstance();
assertThat(instance, instanceOf(TfsMaterialInstance.class));
assertThat(instance.getFingerprint(), is(material.getFingerprint()));
assertThat(instance.getUrl(), is(material.getUrl()));
assertThat(instance.getUsername(), is(material.getUserName()));
assertThat(instance.getProjectPath(), is(material.getProjectPath()));
assertThat(instance.getDomain(), is(material.getDomain()));
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterial in project gocd by gocd.
the class SvnPostCommitHookImplementerTest method shouldPruneListToGiveOutOnlySvnMaterials.
@Test
void shouldPruneListToGiveOutOnlySvnMaterials() {
final Material svnMaterial1 = mock(SvnMaterial.class);
final Material svnMaterial2 = mock(SvnMaterial.class);
final Material svnMaterial3 = mock(SvnMaterial.class);
final Material hgMaterial = mock(HgMaterial.class);
final Material gitMaterial = mock(GitMaterial.class);
final Material p4Material = mock(P4Material.class);
final Material tfsMaterial = mock(TfsMaterial.class);
final Material dependencyMaterial = mock(DependencyMaterial.class);
final HashSet<Material> allMaterials = new HashSet<>(Arrays.asList(svnMaterial1, svnMaterial2, svnMaterial3, gitMaterial, hgMaterial, p4Material, tfsMaterial, dependencyMaterial));
final SvnPostCommitHookImplementer spy = spy(implementer);
doAnswer(invocation -> Boolean.TRUE).when(spy).isQualified(anyString(), any(SvnMaterial.class), any(HashMap.class));
doAnswer(invocation -> new HashMap()).when(spy).createUrlToRemoteUUIDMap(allMaterials);
final HashMap params = new HashMap();
params.put(SvnPostCommitHookImplementer.UUID, "some uuid");
final Set<Material> prunedList = spy.prune(allMaterials, params);
assertThat(prunedList.size()).isEqualTo(3);
assertThat(prunedList).contains(svnMaterial1, svnMaterial2, svnMaterial3);
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterial in project gocd by gocd.
the class TfsMaterialInstance method toOldMaterial.
@Override
public Material toOldMaterial(String name, String folder, String password) {
TfsMaterial tfsMaterial = new TfsMaterial(new UrlArgument(url), username, domain, password, projectPath);
tfsMaterial.setFolder(folder);
setName(name, tfsMaterial);
return tfsMaterial;
}
use of com.thoughtworks.go.config.materials.tfs.TfsMaterial 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);
}
Aggregations