use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.
the class PluggableSCMMaterialAgent method prepare.
@Override
public void prepare() {
PluggableSCMMaterial material = (PluggableSCMMaterial) revision.getMaterial();
Modification latestModification = revision.getLatestModification();
SCMRevision scmRevision = new SCMRevision(latestModification.getRevision(), latestModification.getModifiedTime(), null, null, latestModification.getAdditionalDataMap(), null);
File destinationFolder = material.workingDirectory(workingDirectory);
Result result = scmExtension.checkout(material.getScmConfig().getPluginConfiguration().getId(), buildSCMPropertyConfigurations(material.getScmConfig()), destinationFolder.getAbsolutePath(), scmRevision);
if (!result.isSuccessful()) {
// handle
}
// handle messages
}
use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.
the class JsonMessageHandler1_0Test method shouldBuildRequestBodyForLatestRevisionsSinceRequest.
@Test
public void shouldBuildRequestBodyForLatestRevisionsSinceRequest() throws Exception {
Date timestamp = new SimpleDateFormat(DATE_FORMAT).parse("2011-07-13T19:43:37.100Z");
Map data = new LinkedHashMap();
data.put("dataKeyOne", "data-value-one");
data.put("dataKeyTwo", "data-value-two");
SCMRevision previouslyKnownRevision = new SCMRevision("abc.rpm", timestamp, "someuser", "comment", data, null);
String requestBody = messageHandler.requestMessageForLatestRevisionsSince(scmPropertyConfiguration, materialData, "flyweight", previouslyKnownRevision);
String expectedValue = "{\"scm-configuration\":{\"key-one\":{\"value\":\"value-one\"},\"key-two\":{\"value\":\"value-two\"}},\"scm-data\":{\"key-one\":\"value-one\"},\"flyweight-folder\":\"flyweight\"," + "\"previous-revision\":{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-13T19:43:37.100Z\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}}";
assertThat(requestBody, is(expectedValue));
}
use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.
the class JsonMessageHandler1_0Test method shouldBuildRequestBodyForCheckoutRequest.
@Test
public void shouldBuildRequestBodyForCheckoutRequest() throws Exception {
Date timestamp = new SimpleDateFormat(DATE_FORMAT).parse("2011-07-13T19:43:37.100Z");
Map data = new LinkedHashMap();
data.put("dataKeyOne", "data-value-one");
data.put("dataKeyTwo", "data-value-two");
SCMRevision revision = new SCMRevision("abc.rpm", timestamp, "someuser", "comment", data, null);
String requestBody = messageHandler.requestMessageForCheckout(scmPropertyConfiguration, "destination", revision);
String expectedValue = "{\"scm-configuration\":{\"key-one\":{\"value\":\"value-one\"},\"key-two\":{\"value\":\"value-two\"}},\"destination-folder\":\"destination\"," + "\"revision\":{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-13T19:43:37.100Z\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}}";
assertThat(requestBody, is(expectedValue));
}
use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision in project gocd by gocd.
the class PluggableSCMMaterialPoller method latestModification.
@Override
public List<Modification> latestModification(final PluggableSCMMaterial material, File baseDir, SubprocessExecutionContext execCtx) {
SCMPropertyConfiguration scmPropertyConfiguration = buildSCMPropertyConfigurations(material.getScmConfig());
final MaterialInstance materialInstance = materialRepository.findMaterialInstance(material);
MaterialPollResult pollResult = scmExtension.getLatestRevision(material.getPluginId(), scmPropertyConfiguration, materialInstance.getAdditionalDataMap(), baseDir.getAbsolutePath());
final Map<String, String> materialData = pollResult.getMaterialData();
if (materialInstance.requiresUpdate(materialData)) {
updateAdditionalData(materialInstance.getId(), materialData);
}
SCMRevision scmRevision = pollResult.getLatestRevision();
return scmRevision == null ? new Modifications() : new Modifications(getModification(scmRevision));
}
use of com.thoughtworks.go.plugin.access.scm.revision.SCMRevision 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"));
}
Aggregations