use of com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration 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.SCMPropertyConfiguration in project gocd by gocd.
the class SCMsTest method shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound.
@Test
void shouldFailValidationIfMaterialWithDuplicateFingerprintIsFound() {
String pluginId = "plugin-id";
SCMPropertyConfiguration scmConfiguration = new SCMPropertyConfiguration();
scmConfiguration.add(new SCMProperty("k1"));
scmConfiguration.add(new SCMProperty("k2").with(REQUIRED, false).with(PART_OF_IDENTITY, false));
SCMMetadataStore.getInstance().addMetadataFor(pluginId, new SCMConfigurations(scmConfiguration), null);
SCM scm1 = SCMMother.create("1", "scm1", pluginId, "1.0", new Configuration(create("k1", false, "v1")));
SCM scm2 = SCMMother.create("2", "scm2", pluginId, "1.0", new Configuration(create("k1", false, "v2")));
SCM scm3 = SCMMother.create("3", "scm3", pluginId, "1.0", new Configuration(create("k1", false, "v1")));
SCM scm4 = SCMMother.create("4", "scm4", pluginId, "1.0", new Configuration(create("k1", false, "V1")));
SCM scm5 = SCMMother.create("5", "scm5", pluginId, "1.0", new Configuration(create("k1", false, "v1"), create("k2", false, "v2")));
SCMs scms = new SCMs(scm1, scm2, scm3, scm4, scm5);
scms.validate(null);
assertThat(scm2.getFingerprint().equals(scm1.getFingerprint())).isFalse();
assertThat(scm3.getFingerprint().equals(scm1.getFingerprint())).isTrue();
assertThat(scm4.getFingerprint().equals(scm1.getFingerprint())).isFalse();
assertThat(scm5.getFingerprint().equals(scm1.getFingerprint())).isTrue();
String expectedErrorMessage = "Cannot save SCM, found duplicate SCMs. scm1, scm3, scm5";
assertThat(scm1.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
assertThat(scm2.errors().getAllOn(SCM.SCM_ID)).isEmpty();
assertThat(scm3.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
assertThat(scm4.errors().getAllOn(SCM.SCM_ID)).isEmpty();
assertThat(scm5.errors().getAllOn(SCM.SCM_ID)).isEqualTo(asList(expectedErrorMessage));
}
Aggregations