Search in sources :

Example 61 with PluggableSCMMaterial

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

the class MaterialServiceTest method shouldGetLatestModification_PluggableSCMMaterial.

@Test
public void shouldGetLatestModification_PluggableSCMMaterial() {
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    MaterialInstance materialInstance = pluggableSCMMaterial.createMaterialInstance();
    when(materialRepository.findMaterialInstance(any(Material.class))).thenReturn(materialInstance);
    MaterialPollResult materialPollResult = new MaterialPollResult(null, new SCMRevision("blah-123", new Date(), "user", "comment", null, null));
    when(scmExtension.getLatestRevision(any(String.class), any(SCMPropertyConfiguration.class), any(Map.class), any(String.class))).thenReturn(materialPollResult);
    List<Modification> modifications = materialService.latestModification(pluggableSCMMaterial, new File("/tmp/flyweight"), null);
    assertThat(modifications.get(0).getRevision(), is("blah-123"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) 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) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Map(java.util.Map) File(java.io.File) Date(java.util.Date) Test(org.junit.Test)

Example 62 with PluggableSCMMaterial

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

the class MaterialServiceTest method shouldGetModificationSince_PluggableSCMMaterial.

@Test
public void shouldGetModificationSince_PluggableSCMMaterial() {
    PluggableSCMMaterial pluggableSCMMaterial = MaterialsMother.pluggableSCMMaterial();
    MaterialInstance materialInstance = pluggableSCMMaterial.createMaterialInstance();
    when(materialRepository.findMaterialInstance(any(Material.class))).thenReturn(materialInstance);
    MaterialPollResult materialPollResult = new MaterialPollResult(null, asList(new SCMRevision("new-revision-456", new Date(), "user", "comment", null, null)));
    when(scmExtension.latestModificationSince(any(String.class), any(SCMPropertyConfiguration.class), any(Map.class), any(String.class), any(SCMRevision.class))).thenReturn(materialPollResult);
    PluggableSCMMaterialRevision previouslyKnownRevision = new PluggableSCMMaterialRevision("revision-124", new Date());
    List<Modification> modifications = materialService.modificationsSince(pluggableSCMMaterial, new File("/tmp/flyweight"), previouslyKnownRevision, null);
    assertThat(modifications.get(0).getRevision(), is("new-revision-456"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) 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) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) TfsMaterial(com.thoughtworks.go.config.materials.tfs.TfsMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) Date(java.util.Date) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) GitMaterialInstance(com.thoughtworks.go.domain.materials.git.GitMaterialInstance) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) Map(java.util.Map) File(java.io.File) Test(org.junit.Test)

Example 63 with PluggableSCMMaterial

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

the class PluggableSCMMaterialPollerTest method setup.

@Before
public void setup() {
    initMocks(this);
    ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
    ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", true, "v2");
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(k1, k2));
    material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    MaterialInstance materialInstance = material.createMaterialInstance();
    Map<String, String> data = new HashMap<>();
    data.put("mk-1", "mv-1");
    materialInstance.setAdditionalData(JsonHelper.toJsonString(data));
    when(materialRepository.findMaterialInstance(material)).thenReturn(materialInstance);
    poller = new PluggableSCMMaterialPoller(materialRepository, scmExtension, transactionTemplate);
    scmConfiguration = ArgumentCaptor.forClass(SCMPropertyConfiguration.class);
    materialData = ArgumentCaptor.forClass(Map.class);
    flyweightFolderPath = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
}
Also used : ConfigurationProperty(com.thoughtworks.go.domain.config.ConfigurationProperty) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) SCM(com.thoughtworks.go.domain.scm.SCM) MaterialInstance(com.thoughtworks.go.domain.MaterialInstance) ModifiedFile(com.thoughtworks.go.plugin.access.scm.revision.ModifiedFile) File(java.io.File) Before(org.junit.Before)

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