Search in sources :

Example 1 with TfsMaterial

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;
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) ArrayList(java.util.ArrayList) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) TestOnly(org.jetbrains.annotations.TestOnly)

Example 2 with TfsMaterial

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()));
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) TfsMaterialInstance(com.thoughtworks.go.domain.materials.tfs.TfsMaterialInstance) P4MaterialInstance(com.thoughtworks.go.domain.materials.perforce.P4MaterialInstance) PackageMaterialInstance(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance) TfsMaterialInstance(com.thoughtworks.go.domain.materials.tfs.TfsMaterialInstance) HgMaterialInstance(com.thoughtworks.go.domain.materials.mercurial.HgMaterialInstance) PluggableSCMMaterialInstance(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance) SvnMaterialInstance(com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance) Test(org.junit.jupiter.api.Test)

Example 3 with TfsMaterial

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);
}
Also used : HashMap(java.util.HashMap) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Material(com.thoughtworks.go.domain.materials.Material) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 4 with TfsMaterial

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;
}
Also used : UrlArgument(com.thoughtworks.go.util.command.UrlArgument) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial)

Example 5 with 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);
}
Also used : GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) P4MaterialUpdater(com.thoughtworks.go.domain.materials.perforce.P4MaterialUpdater) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) GitMaterialUpdater(com.thoughtworks.go.domain.materials.git.GitMaterialUpdater) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) SvnMaterialUpdater(com.thoughtworks.go.domain.materials.svn.SvnMaterialUpdater) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) HgMaterialUpdater(com.thoughtworks.go.domain.materials.mercurial.HgMaterialUpdater) TfsMaterialUpdater(com.thoughtworks.go.domain.materials.tfs.TfsMaterialUpdater) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)

Aggregations

TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)9 Test (org.junit.jupiter.api.Test)5 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)4 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)4 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)4 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)4 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)4 UrlArgument (com.thoughtworks.go.util.command.UrlArgument)4 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)3 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)2 Material (com.thoughtworks.go.domain.materials.Material)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 Materials (com.thoughtworks.go.config.materials.Materials)1 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)1 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)1 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)1 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)1 GitMaterialUpdater (com.thoughtworks.go.domain.materials.git.GitMaterialUpdater)1 HgMaterialInstance (com.thoughtworks.go.domain.materials.mercurial.HgMaterialInstance)1 HgMaterialUpdater (com.thoughtworks.go.domain.materials.mercurial.HgMaterialUpdater)1