use of com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision in project gocd by gocd.
the class PackageMaterialTest method shouldGetJsonRepresentationForPackageMaterial.
@Test
void shouldGetJsonRepresentationForPackageMaterial() {
PackageMaterial material = new PackageMaterial();
PackageRepository repository = create("repo-id", "repo-name", "pluginid", "version", new Configuration(ConfigurationPropertyMother.create("k1", false, "v1")));
material.setPackageDefinition(PackageDefinitionMother.create("p-id", "package-name", new Configuration(ConfigurationPropertyMother.create("k2", false, "v2")), repository));
Map<String, String> jsonMap = new LinkedHashMap<>();
material.toJson(jsonMap, new PackageMaterialRevision("rev123", new Date()));
assertThat(jsonMap.get("scmType")).isEqualTo("Package");
assertThat(jsonMap.get("materialName")).isEqualTo("repo-name_package-name");
assertThat(jsonMap.get("action")).isEqualTo("Modified");
assertThat(jsonMap.get("location")).isEqualTo(material.getUriForDisplay());
}
use of com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision in project gocd by gocd.
the class ModificationsTest method shouldGetLatestModificationsForPackageMaterial.
@Test
public void shouldGetLatestModificationsForPackageMaterial() {
Date timestamp = new Date();
String revisionString = "123";
HashMap<String, String> data = new HashMap<>();
data.put("1", "one");
data.put("2", "two");
Modification modification = new Modification(null, null, null, timestamp, revisionString, JsonHelper.toJsonString(data));
Modifications modifications = new Modifications(modification);
Revision revision = modifications.latestRevision(new PackageMaterial());
assertThat(revision instanceof PackageMaterialRevision, is(true));
PackageMaterialRevision packageMaterialRevision = (PackageMaterialRevision) revision;
assertThat(packageMaterialRevision.getRevision(), is(revisionString));
assertThat(packageMaterialRevision.getTimestamp(), is(timestamp));
assertThat(packageMaterialRevision.getData().size(), is(data.size()));
assertThat(packageMaterialRevision.getData().get("1"), is(data.get("1")));
assertThat(packageMaterialRevision.getData().get("2"), is(data.get("2")));
}
use of com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision in project gocd by gocd.
the class MaterialServiceTest method shouldGetModificationSinceAGivenRevision.
@Test
public void shouldGetModificationSinceAGivenRevision() {
PackageMaterial material = new PackageMaterial();
PackageDefinition packageDefinition = create("id", "package", new Configuration(), PackageRepositoryMother.create("id", "name", "plugin-id", "plugin-version", new Configuration()));
material.setPackageDefinition(packageDefinition);
when(packageRepositoryExtension.latestModificationSince(eq("plugin-id"), any(PackageConfiguration.class), any(RepositoryConfiguration.class), any(PackageRevision.class))).thenReturn(new PackageRevision("new-revision-456", new Date(), "user"));
List<Modification> modifications = materialService.modificationsSince(material, null, new PackageMaterialRevision("revision-124", new Date()), null);
assertThat(modifications.get(0).getRevision(), is("new-revision-456"));
}
Aggregations