use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.
the class PackageMaterialPollerTest method shouldGetLatestModificationsAlongWithAdditionalDataFromThePackageRevision.
@Test
void shouldGetLatestModificationsAlongWithAdditionalDataFromThePackageRevision() {
Date timestamp = new Date();
PackageRevision packageRevision = new PackageRevision("revision-123", timestamp, "user");
String dataKey = "extra_data";
String dataValue = "value";
packageRevision.addData(dataKey, dataValue);
when(packageRepositoryExtension.getLatestRevision(eq(material.getPluginId()), packageConfiguration.capture(), repositoryConfiguration.capture())).thenReturn(packageRevision);
HashMap<String, String> expected = new HashMap<>();
expected.put(dataKey, dataValue);
List<Modification> modifications = poller.latestModification(material, null, null);
assertThat(modifications.get(0).getRevision()).isEqualTo("revision-123");
assertThat(modifications.get(0).getModifiedTime()).isEqualTo(timestamp);
assertThat(modifications.get(0).getUserName()).isEqualTo("user");
assertThat(modifications.get(0).getComment()).isNotNull();
assertThat(modifications.get(0).getAdditionalData()).isEqualTo(JsonHelper.toJsonString(expected));
assertConfiguration(packageConfiguration.getValue(), material.getPackageDefinition().getConfiguration());
assertConfiguration(repositoryConfiguration.getValue(), material.getPackageDefinition().getRepository().getConfiguration());
}
use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.
the class PackageMaterialPollerTest method shouldPopulatePackageModificationComment_WithTrackbackUrlAndComment.
@Test
void shouldPopulatePackageModificationComment_WithTrackbackUrlAndComment() throws Exception {
PackageRevision packageRevision = new PackageRevision(null, null, null, "Built on host1", "http://google.com");
PackageMaterial packageMaterial = MaterialsMother.packageMaterial();
when(packageRepositoryExtension.getLatestRevision(eq(packageMaterial.getPluginId()), any(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration.class), any(RepositoryConfiguration.class))).thenReturn(packageRevision);
List<Modification> modifications = poller.latestModification(packageMaterial, null, null);
JsonFluentAssert.assertThatJson(modifications.get(0).getComment()).isEqualTo("{\"COMMENT\":\"Built on host1\",\"TRACKBACK_URL\":\"http://google.com\",\"TYPE\":\"PACKAGE_MATERIAL\"}");
}
Aggregations