Search in sources :

Example 21 with PluggableSCMMaterial

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

the class PipelineMother method pipelineWithAllTypesOfMaterials.

public static Pipeline pipelineWithAllTypesOfMaterials(String pipelineName, String stageName, String jobName, String fixedMaterialRevisionForAllMaterials) {
    GitMaterial gitMaterial = MaterialsMother.gitMaterial("http://user:password@gitrepo.com", null, "branch");
    HgMaterial hgMaterial = MaterialsMother.hgMaterial("http://user:password@hgrepo.com");
    SvnMaterial svnMaterial = MaterialsMother.svnMaterial("http://user:password@svnrepo.com", null, "username", "password", false, null);
    TfsMaterial tfsMaterial = MaterialsMother.tfsMaterial("http://user:password@tfsrepo.com");
    P4Material p4Material = MaterialsMother.p4Material("127.0.0.1:1666", "username", "password", "view", false);
    DependencyMaterial dependencyMaterial = MaterialsMother.dependencyMaterial();
    PackageMaterial packageMaterial = MaterialsMother.packageMaterial();
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    Materials materials = new Materials(gitMaterial, hgMaterial, svnMaterial, tfsMaterial, p4Material, dependencyMaterial, packageMaterial, pluggableSCMMaterial);
    return new Pipeline(pipelineName, BuildCause.createWithModifications(ModificationsMother.modifyOneFile(materials, fixedMaterialRevisionForAllMaterials), ""), StageMother.passedStageInstance(stageName, jobName, pipelineName));
}
Also used : TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) Materials(com.thoughtworks.go.config.materials.Materials) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material)

Example 22 with PluggableSCMMaterial

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

the class PluggableSCMPostCommitHookImplementer method prune.

@Override
public Set<Material> prune(Set<Material> materials, Map params) {
    HashSet<Material> prunedCollection = new HashSet<>();
    String paramSCMName = (String) params.get(SCM_NAME);
    if (StringUtils.isNotBlank(paramSCMName)) {
        for (Material material : materials) {
            if (material instanceof PluggableSCMMaterial && paramSCMName.equalsIgnoreCase(((PluggableSCMMaterial) material).getScmConfig().getName())) {
                prunedCollection.add(material);
            }
        }
    }
    return prunedCollection;
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) Material(com.thoughtworks.go.domain.materials.Material) HashSet(java.util.HashSet)

Example 23 with PluggableSCMMaterial

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

the class PluggableSCMMaterialUpdaterIntegrationTest method shouldUpdateMaterialInstanceWhenAdditionalDataIsUpdatedDuringLatestModification.

@Test
public void shouldUpdateMaterialInstanceWhenAdditionalDataIsUpdatedDuringLatestModification() throws Exception {
    final PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    final MaterialInstance materialInstance = material.createMaterialInstance();
    materialRepository.saveOrUpdate(materialInstance);
    Map<String, String> data = new HashMap<>();
    data.put("k1", "v1");
    when(scmExtension.getLatestRevision(any(String.class), any(SCMPropertyConfiguration.class), any(Map.class), any(String.class))).thenReturn(new MaterialPollResult(data, new SCMRevision()));
    mockSCMExtensionInPoller();
    scmMaterialUpdater = new ScmMaterialUpdater(materialRepository, materialChecker, subprocessExecutionContext, materialService);
    pluggableSCMMaterialUpdater = new PluggableSCMMaterialUpdater(materialRepository, scmMaterialUpdater, transactionTemplate);
    transactionTemplate.execute(new TransactionCallback() {

        @Override
        public Object doInTransaction(TransactionStatus transactionStatus) {
            pluggableSCMMaterialUpdater.insertLatestOrNewModifications(material, materialInstance, new File(""), new Modifications());
            return null;
        }
    });
    MaterialInstance actualInstance = materialRepository.findMaterialInstance(material);
    assertThat(actualInstance.getAdditionalDataMap(), is(data));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HashMap(java.util.HashMap) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) TransactionStatus(org.springframework.transaction.TransactionStatus) Modifications(com.thoughtworks.go.domain.materials.Modifications) TransactionCallback(org.springframework.transaction.support.TransactionCallback) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) Test(org.junit.Test)

Example 24 with PluggableSCMMaterial

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

the class FaninDependencyResolutionTest method shouldResolveDiamondDependencyWithPluggableSCMMaterial.

@Test
public void shouldResolveDiamondDependencyWithPluggableSCMMaterial() {
    /*
            +---> P1 ---+
            |           v
           scm1         P3
            |           ^
            +--> P2 ----+
        */
    int i = 1;
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    u.addSCMConfig(pluggableSCMMaterial.getScmConfig());
    String[] pkg_revs = { "scm1-1", "scm1-2" };
    u.checkinInOrder(pluggableSCMMaterial, u.d(i++), pkg_revs);
    ScheduleTestUtil.AddedPipeline p1 = u.saveConfigWith("p1", u.m(pluggableSCMMaterial));
    ScheduleTestUtil.AddedPipeline p2 = u.saveConfigWith("p2", u.m(pluggableSCMMaterial));
    ScheduleTestUtil.AddedPipeline p3 = u.saveConfigWith("p3", u.m(p1), u.m(p2));
    String p1_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p1, u.d(i++), "scm1-1");
    String p2_1 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "scm1-1");
    String p2_2 = u.runAndPassWithGivenMDUTimestampAndRevisionStrings(p2, u.d(i++), "scm1-2");
    MaterialRevisions given = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_2));
    MaterialRevisions expected = u.mrs(u.mr(p1, true, p1_1), u.mr(p2, true, p2_1));
    assertThat(getRevisionsBasedOnDependencies(p3, goConfigDao.load(), given), is(expected));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) MaterialRevisions(com.thoughtworks.go.domain.MaterialRevisions) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 25 with PluggableSCMMaterial

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

the class MaterialInstanceTest method shouldAnswerRequiresUpdate.

@Test
public void shouldAnswerRequiresUpdate() {
    PluggableSCMMaterial material = MaterialsMother.pluggableSCMMaterial();
    MaterialInstance materialInstance = material.createMaterialInstance();
    // null
    materialInstance.setAdditionalData(null);
    assertThat(materialInstance.requiresUpdate(null), is(false));
    assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(false));
    // empty
    materialInstance.setAdditionalData(JsonHelper.toJsonString(new HashMap<String, String>()));
    assertThat(materialInstance.requiresUpdate(null), is(false));
    assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(false));
    // with data
    Map<String, String> data = new HashMap<>();
    data.put("k1", "v1");
    data.put("k2", "v2");
    materialInstance.setAdditionalData(JsonHelper.toJsonString(data));
    assertThat(materialInstance.requiresUpdate(null), is(true));
    assertThat(materialInstance.requiresUpdate(new HashMap<>()), is(true));
    assertThat(materialInstance.requiresUpdate(data), is(false));
    // missing key-value
    Map<String, String> dataWithMissingKey = new HashMap<>(data);
    dataWithMissingKey.remove("k1");
    assertThat(materialInstance.requiresUpdate(dataWithMissingKey), is(true));
    // extra key-value
    Map<String, String> dataWithExtraKey = new HashMap<>(data);
    dataWithExtraKey.put("k3", "v3");
    assertThat(materialInstance.requiresUpdate(dataWithExtraKey), is(true));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HashMap(java.util.HashMap) Test(org.junit.Test)

Aggregations

PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)63 Test (org.junit.Test)55 SCM (com.thoughtworks.go.domain.scm.SCM)24 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)18 File (java.io.File)13 Modification (com.thoughtworks.go.domain.materials.Modification)11 Modifications (com.thoughtworks.go.domain.materials.Modifications)10 Date (java.util.Date)10 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)9 HashMap (java.util.HashMap)8 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)7 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)7 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)7 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)6 Map (java.util.Map)6 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)5 Material (com.thoughtworks.go.domain.materials.Material)5 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)5 LinkedHashMap (java.util.LinkedHashMap)5 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)4