Search in sources :

Example 6 with PluggableSCMMaterialRevision

use of com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision in project gocd by gocd.

the class PluggableSCMMaterialPollerTest method shouldTalkToPlugInToGetModificationsSinceAGivenRevision.

@Test
public void shouldTalkToPlugInToGetModificationsSinceAGivenRevision() {
    Date timestamp = new Date();
    PluggableSCMMaterialRevision knownRevision = new PluggableSCMMaterialRevision("rev-122", timestamp);
    ArgumentCaptor<SCMRevision> knownSCMRevision = ArgumentCaptor.forClass(SCMRevision.class);
    SCMRevision latestRevision = new SCMRevision("rev-123", timestamp, "user", null, null, null);
    MaterialPollResult materialPollResult = new MaterialPollResult(null, asList(latestRevision));
    when(scmExtension.latestModificationSince(eq(material.getPluginId()), scmConfiguration.capture(), materialData.capture(), eq(flyweightFolderPath), knownSCMRevision.capture())).thenReturn(materialPollResult);
    List<Modification> modifications = poller.modificationsSince(material, new File(flyweightFolderPath), knownRevision, null);
    assertThat(modifications.get(0).getRevision(), is("rev-123"));
    assertThat(modifications.get(0).getModifiedTime(), is(timestamp));
    assertThat(modifications.get(0).getUserName(), is("user"));
    assertThat(modifications.get(0).getComment(), is(nullValue()));
    assertConfiguration(scmConfiguration.getValue(), "k1", "v1");
    assertConfiguration(scmConfiguration.getValue(), "k2", "v2");
    assertThat(knownSCMRevision.getValue().getRevision(), is("rev-122"));
    assertThat(knownSCMRevision.getValue().getTimestamp(), is(timestamp));
    assertThat(materialData.getValue().size(), is(1));
    assertThat(materialData.getValue().get("mk-1"), is("mv-1"));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) MaterialPollResult(com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) SCMRevision(com.thoughtworks.go.plugin.access.scm.revision.SCMRevision) ModifiedFile(com.thoughtworks.go.plugin.access.scm.revision.ModifiedFile) File(java.io.File) Test(org.junit.Test)

Example 7 with PluggableSCMMaterialRevision

use of com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision in project gocd by gocd.

the class PluggableSCMMaterialTest method shouldGetJsonRepresentationForPluggableSCMMaterial.

@Test
public void shouldGetJsonRepresentationForPluggableSCMMaterial() {
    ConfigurationProperty k1 = create("k1", false, "v1");
    SCM scmConfig = SCMMother.create("scm-id", "scm-name", "pluginid", "version", new Configuration(k1));
    PluggableSCMMaterial material = new PluggableSCMMaterial();
    material.setSCMConfig(scmConfig);
    material.setFolder("folder");
    Map<String, String> jsonMap = new LinkedHashMap<>();
    material.toJson(jsonMap, new PluggableSCMMaterialRevision("rev123", new Date()));
    assertThat(jsonMap.get("scmType"), is("SCM"));
    assertThat(jsonMap.get("materialName"), is("scm-name"));
    assertThat(jsonMap.get("location"), is(material.getUriForDisplay()));
    assertThat(jsonMap.get("folder"), is("folder"));
    assertThat(jsonMap.get("action"), is("Modified"));
}
Also used : PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) SCM(com.thoughtworks.go.domain.scm.SCM) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.Test)

Example 8 with PluggableSCMMaterialRevision

use of com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision 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)

Aggregations

PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)8 MaterialPollResult (com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult)6 SCMRevision (com.thoughtworks.go.plugin.access.scm.revision.SCMRevision)6 Test (org.junit.Test)6 File (java.io.File)4 MaterialInstance (com.thoughtworks.go.domain.MaterialInstance)3 Modification (com.thoughtworks.go.domain.materials.Modification)3 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)3 ModifiedFile (com.thoughtworks.go.plugin.access.scm.revision.ModifiedFile)3 Date (java.util.Date)3 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 PluggableSCMMaterial (com.thoughtworks.go.config.materials.PluggableSCMMaterial)2 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)1 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)1 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)1 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)1 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)1 TfsMaterial (com.thoughtworks.go.config.materials.tfs.TfsMaterial)1 GitMaterialInstance (com.thoughtworks.go.domain.materials.git.GitMaterialInstance)1