Search in sources :

Example 6 with PackageMaterialRevision

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());
}
Also used : PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Example 7 with PackageMaterialRevision

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")));
}
Also used : PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) PluggableSCMMaterialRevision(com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision) PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) StringRevision(com.thoughtworks.go.domain.materials.mercurial.StringRevision) HashMap(java.util.HashMap) Date(java.util.Date) Test(org.junit.jupiter.api.Test)

Example 8 with PackageMaterialRevision

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"));
}
Also used : PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) SCMPropertyConfiguration(com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration) Configuration(com.thoughtworks.go.domain.config.Configuration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) PackageConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration) PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) PackageDefinition(com.thoughtworks.go.domain.packagerepository.PackageDefinition) PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) PackageConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration) RepositoryConfiguration(com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration) Date(java.util.Date) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

PackageMaterialRevision (com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision)8 Date (java.util.Date)7 Test (org.junit.jupiter.api.Test)7 PackageRevision (com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision)6 Modification (com.thoughtworks.go.domain.materials.Modification)4 RepositoryConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.RepositoryConfiguration)3 PackageMaterial (com.thoughtworks.go.config.materials.PackageMaterial)2 PackageConfiguration (com.thoughtworks.go.plugin.api.material.packagerepository.PackageConfiguration)2 HashMap (java.util.HashMap)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 Configuration (com.thoughtworks.go.domain.config.Configuration)1 StringRevision (com.thoughtworks.go.domain.materials.mercurial.StringRevision)1 PluggableSCMMaterialRevision (com.thoughtworks.go.domain.materials.scm.PluggableSCMMaterialRevision)1 PackageDefinition (com.thoughtworks.go.domain.packagerepository.PackageDefinition)1 SCMPropertyConfiguration (com.thoughtworks.go.plugin.access.scm.SCMPropertyConfiguration)1 LinkedHashMap (java.util.LinkedHashMap)1 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1