Search in sources :

Example 16 with PackageRevision

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());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) HashMap(java.util.HashMap) PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 17 with PackageRevision

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\"}");
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) Test(org.junit.jupiter.api.Test)

Aggregations

PackageRevision (com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision)17 Test (org.junit.jupiter.api.Test)14 Date (java.util.Date)9 Modification (com.thoughtworks.go.domain.materials.Modification)7 PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)6 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)6 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)4 PackageConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration)4 SimpleDateFormat (java.text.SimpleDateFormat)3 Configuration (com.thoughtworks.go.domain.config.Configuration)2 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)2 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)2 HashMap (java.util.HashMap)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1