use of com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult in project gocd by gocd.
the class JsonMessageHandler1_0Test method shouldBuildSCMDataFromLatestRevisionResponse.
@Test
public void shouldBuildSCMDataFromLatestRevisionResponse() throws Exception {
String responseBodyWithSCMData = "{\"revision\":{\"revision\":\"r1\",\"timestamp\":\"2011-07-14T19:43:37.100Z\"},\"scm-data\":{\"key-one\":\"value-one\"}}";
MaterialPollResult pollResult = messageHandler.responseMessageForLatestRevision(responseBodyWithSCMData);
Map<String, String> scmData = new HashMap<>();
scmData.put("key-one", "value-one");
assertThat(pollResult.getMaterialData(), is(scmData));
assertThat(pollResult.getRevisions().get(0).getRevision(), is("r1"));
}
use of com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult 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"));
}
use of com.thoughtworks.go.plugin.access.scm.material.MaterialPollResult 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.material.MaterialPollResult 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));
}
Aggregations