use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision 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"));
}
use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.
the class PluggableSCMMaterialPollerTest method shouldGetLatestModificationAlongWithAdditionalDataFromTheSCMRevision.
@Test
public void shouldGetLatestModificationAlongWithAdditionalDataFromTheSCMRevision() {
Date timestamp = new Date();
Map<String, String> data = new HashMap<>();
String dataKey = "revision_data";
String dataValue = "revision_value";
data.put(dataKey, dataValue);
List<ModifiedFile> modifiedFiles = new ArrayList<>(asList(new ModifiedFile("f1", ModifiedAction.added), new ModifiedFile("f2", ModifiedAction.modified), new ModifiedFile("f3", ModifiedAction.deleted)));
SCMRevision scmRevision = new SCMRevision("revision-123", timestamp, "user", "comment", data, modifiedFiles);
MaterialPollResult materialPollResult = new MaterialPollResult(null, scmRevision);
when(scmExtension.getLatestRevision(eq(material.getPluginId()), scmConfiguration.capture(), materialData.capture(), eq(flyweightFolderPath))).thenReturn(materialPollResult);
List<Modification> modifications = poller.latestModification(material, new File(flyweightFolderPath), null);
assertThat(modifications.get(0).getRevision(), is("revision-123"));
assertThat(modifications.get(0).getModifiedTime(), is(timestamp));
assertThat(modifications.get(0).getUserName(), is("user"));
assertThat(modifications.get(0).getComment(), is("comment"));
assertThat(modifications.get(0).getAdditionalData(), is(JsonHelper.toJsonString(data)));
assertThat(modifications.get(0).getModifiedFiles().size(), is(3));
com.thoughtworks.go.domain.materials.ModifiedFile f1 = new com.thoughtworks.go.domain.materials.ModifiedFile("f1", null, com.thoughtworks.go.domain.materials.ModifiedAction.added);
com.thoughtworks.go.domain.materials.ModifiedFile f2 = new com.thoughtworks.go.domain.materials.ModifiedFile("f2", null, com.thoughtworks.go.domain.materials.ModifiedAction.modified);
com.thoughtworks.go.domain.materials.ModifiedFile f3 = new com.thoughtworks.go.domain.materials.ModifiedFile("f3", null, com.thoughtworks.go.domain.materials.ModifiedAction.deleted);
assertThat(new HashSet(modifications.get(0).getModifiedFiles()), is(new HashSet(asList(f1, f2, f3))));
assertConfiguration(scmConfiguration.getValue(), material.getScmConfig().getConfiguration());
assertThat(materialData.getValue().size(), is(1));
assertThat(materialData.getValue().get("mk-1"), is("mv-1"));
}
Aggregations