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"));
}
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"));
}
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"));
}
Aggregations