Search in sources :

Example 1 with P4Material

use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method shouldBeAbleToPersistAMaterialWithNullBooleans.

@Test
public void shouldBeAbleToPersistAMaterialWithNullBooleans() throws Exception {
    P4Material p4Material = new P4Material("serverAndPort", "view");
    MaterialInstance original = p4Material.createMaterialInstance();
    repo.saveOrUpdate(original);
    MaterialInstance loaded = repo.find(original.getId());
    Material restored = loaded.toOldMaterial(null, null, null);
    assertThat(restored, is(p4Material));
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) 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 2 with P4Material

use of com.thoughtworks.go.config.materials.perforce.P4Material 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 3 with P4Material

use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials.

@Test
public void shouldHaveServerAndPortAndViewAndUseTicketsInP4Materials() throws SQLException {
    String p4view = "//depot/... //localhost/...";
    Materials p4Materials = MaterialsMother.p4Materials(p4view);
    P4Material p4Material = (P4Material) p4Materials.first();
    p4Material.setUseTickets(true);
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(p4Materials.convertToConfigs());
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(modifyOneFile(pipelineConfig), Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    Materials materials = pipelineFromDB.getMaterials();
    assertThat(materials.get(0), is(p4Material));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) Test(org.junit.jupiter.api.Test)

Example 4 with P4Material

use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method shouldFetchDetailsRelatedToP4.

@Test
public void shouldFetchDetailsRelatedToP4() {
    P4Material material = new P4Material("localhost:1666", "view");
    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(P4MaterialInstance.class));
    assertThat(instance.getFingerprint(), is(material.getFingerprint()));
    assertThat(instance.getUrl(), is(material.getUrl()));
    assertThat(instance.getUsername(), is(material.getUserName()));
    assertThat(instance.getView(), is(material.getView()));
    assertThat(instance.getUseTickets(), is(material.getUseTickets()));
}
Also used : P4MaterialInstance(com.thoughtworks.go.domain.materials.perforce.P4MaterialInstance) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) 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 5 with P4Material

use of com.thoughtworks.go.config.materials.perforce.P4Material in project gocd by gocd.

the class MaterialsMother method p4Material.

public static P4Material p4Material(String serverAndPort, String userName, String password, String view, boolean useTickets) {
    final P4Material material = new P4Material(serverAndPort, view, userName);
    material.setAutoUpdate(true);
    material.setPassword(password);
    material.setUseTickets(useTickets);
    return material;
}
Also used : P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Aggregations

P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)18 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)9 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)8 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)8 Test (org.junit.jupiter.api.Test)8 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)7 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)5 Materials (com.thoughtworks.go.config.materials.Materials)3 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)3 ScmMaterial (com.thoughtworks.go.config.materials.ScmMaterial)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 ArrayList (java.util.ArrayList)3 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)2 Material (com.thoughtworks.go.domain.materials.Material)2 HgMaterialInstance (com.thoughtworks.go.domain.materials.mercurial.HgMaterialInstance)2 PackageMaterialInstance (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialInstance)2 P4MaterialInstance (com.thoughtworks.go.domain.materials.perforce.P4MaterialInstance)2 PluggableSCMMaterialInstance (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialInstance)2 SvnMaterialInstance (com.thoughtworks.go.domain.materials.svn.SvnMaterialInstance)2