use of com.thoughtworks.go.config.materials.PluggableSCMMaterial 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.config.materials.PluggableSCMMaterial 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.config.materials.PluggableSCMMaterial in project gocd by gocd.
the class PluggableSCMMaterialPollerTest method setup.
@Before
public void setup() {
initMocks(this);
ConfigurationProperty k1 = ConfigurationPropertyMother.create("k1", false, "v1");
ConfigurationProperty k2 = ConfigurationPropertyMother.create("k2", true, "v2");
SCM scmConfig = SCMMother.create("scm-id", "scm-name", "plugin-id", "1.0", new Configuration(k1, k2));
material = new PluggableSCMMaterial();
material.setSCMConfig(scmConfig);
MaterialInstance materialInstance = material.createMaterialInstance();
Map<String, String> data = new HashMap<>();
data.put("mk-1", "mv-1");
materialInstance.setAdditionalData(JsonHelper.toJsonString(data));
when(materialRepository.findMaterialInstance(material)).thenReturn(materialInstance);
poller = new PluggableSCMMaterialPoller(materialRepository, scmExtension, transactionTemplate);
scmConfiguration = ArgumentCaptor.forClass(SCMPropertyConfiguration.class);
materialData = ArgumentCaptor.forClass(Map.class);
flyweightFolderPath = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
}
Aggregations