Search in sources :

Example 6 with PackageRevision

use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.

the class PackageRepositoryExtensionTest method shouldTalkToPluginToGetLatestModificationSinceLastRevision.

@Test
public void shouldTalkToPluginToGetLatestModificationSinceLastRevision() throws Exception {
    String expectedRequestBody = "{\"repository-configuration\":{\"key-one\":{\"value\":\"value-one\"},\"key-two\":{\"value\":\"value-two\"}}," + "\"package-configuration\":{\"key-three\":{\"value\":\"value-three\"},\"key-four\":{\"value\":\"value-four\"}}," + "\"previous-revision\":{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-13T19:43:37.100Z\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}}";
    String expectedResponseBody = "{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-14T19:43:37.100Z\",\"user\":\"some-user\",\"revisionComment\":\"comment\"," + "\"trackbackUrl\":\"http:\\\\localhost:9999\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}";
    Date timestamp = new SimpleDateFormat(DATE_FORMAT).parse("2011-07-13T19:43:37.100Z");
    Map data = new LinkedHashMap();
    data.put("dataKeyOne", "data-value-one");
    data.put("dataKeyTwo", "data-value-two");
    PackageRevision previouslyKnownRevision = new PackageRevision("abc.rpm", timestamp, "someuser", "comment", null, data);
    when(pluginManager.isPluginOfType(PACKAGE_MATERIAL_EXTENSION, PLUGIN_ID)).thenReturn(true);
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(PACKAGE_MATERIAL_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(expectedResponseBody));
    PackageRevision packageRevision = extension.latestModificationSince(PLUGIN_ID, packageConfiguration, repositoryConfiguration, previouslyKnownRevision);
    assertRequest(requestArgumentCaptor.getValue(), PACKAGE_MATERIAL_EXTENSION, "1.0", PackageRepositoryExtension.REQUEST_LATEST_REVISION_SINCE, expectedRequestBody);
    assertPackageRevision(packageRevision, "abc.rpm", "some-user", "2011-07-14T19:43:37.100Z", "comment", "http:\\localhost:9999");
}
Also used : PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) SimpleDateFormat(java.text.SimpleDateFormat) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) Date(java.util.Date) LinkedHashMap(java.util.LinkedHashMap) Test(org.junit.jupiter.api.Test)

Example 7 with PackageRevision

use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.

the class PackageRepositoryExtensionTest method shouldTalkToPluginToGetLatestModification.

@Test
public void shouldTalkToPluginToGetLatestModification() throws Exception {
    String expectedRequestBody = "{\"repository-configuration\":{\"key-one\":{\"value\":\"value-one\"},\"key-two\":{\"value\":\"value-two\"}}," + "\"package-configuration\":{\"key-three\":{\"value\":\"value-three\"},\"key-four\":{\"value\":\"value-four\"}}}";
    String expectedResponseBody = "{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-14T19:43:37.100Z\",\"user\":\"some-user\",\"revisionComment\":\"comment\"," + "\"trackbackUrl\":\"http:\\\\localhost:9999\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}";
    when(pluginManager.isPluginOfType(PACKAGE_MATERIAL_EXTENSION, PLUGIN_ID)).thenReturn(true);
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(PACKAGE_MATERIAL_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(expectedResponseBody));
    PackageRevision packageRevision = extension.getLatestRevision(PLUGIN_ID, packageConfiguration, repositoryConfiguration);
    assertRequest(requestArgumentCaptor.getValue(), PACKAGE_MATERIAL_EXTENSION, "1.0", PackageRepositoryExtension.REQUEST_LATEST_REVISION, expectedRequestBody);
    assertPackageRevision(packageRevision, "abc.rpm", "some-user", "2011-07-14T19:43:37.100Z", "comment", "http:\\localhost:9999");
}
Also used : PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) Test(org.junit.jupiter.api.Test)

Example 8 with PackageRevision

use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.

the class PackageMaterialPoller method modificationsSince.

@Override
public List<Modification> modificationsSince(final PackageMaterial material, File baseDir, final Revision revision, SubprocessExecutionContext execCtx) {
    PackageMaterialRevision packageMaterialRevision = (PackageMaterialRevision) revision;
    PackageRevision previouslyKnownRevision = new PackageRevision(packageMaterialRevision.getRevision(), packageMaterialRevision.getTimestamp(), null, packageMaterialRevision.getData());
    PackageConfiguration packageConfiguration = buildPackageConfigurations(material.getPackageDefinition());
    RepositoryConfiguration repositoryConfiguration = buildRepositoryConfigurations(material.getPackageDefinition().getRepository());
    PackageRevision packageRevision = packageRepositoryExtension.latestModificationSince(material.getPluginId(), packageConfiguration, repositoryConfiguration, previouslyKnownRevision);
    return getModifications(packageRevision);
}
Also used : PackageMaterialRevision(com.thoughtworks.go.domain.materials.packagematerial.PackageMaterialRevision) 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)

Example 9 with PackageRevision

use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.

the class JsonMessageHandler1_0Test method shouldBuildPackageRevisionFromLatestRevisionResponse.

@Test
public void shouldBuildPackageRevisionFromLatestRevisionResponse() throws Exception {
    String responseBody = "{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-14T19:43:37.100Z\",\"user\":\"some-user\",\"revisionComment\":\"comment\"," + "\"trackbackUrl\":\"http:\\\\localhost:9999\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}";
    PackageRevision packageRevision = messageHandler.responseMessageForLatestRevision(responseBody);
    assertPackageRevision(packageRevision, "abc.rpm", "some-user", "2011-07-14T19:43:37.100Z", "comment", "http:\\localhost:9999");
}
Also used : PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) Test(org.junit.jupiter.api.Test)

Example 10 with PackageRevision

use of com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision in project gocd by gocd.

the class JsonMessageHandler1_0Test method shouldBuildPackageRevisionFromLatestRevisionSinceResponse.

@Test
public void shouldBuildPackageRevisionFromLatestRevisionSinceResponse() throws Exception {
    String responseBody = "{\"revision\":\"abc.rpm\",\"timestamp\":\"2011-07-14T19:43:37.100Z\",\"user\":\"some-user\",\"revisionComment\":\"comment\"," + "\"trackbackUrl\":\"http:\\\\localhost:9999\",\"data\":{\"dataKeyOne\":\"data-value-one\",\"dataKeyTwo\":\"data-value-two\"}}";
    PackageRevision packageRevision = messageHandler.responseMessageForLatestRevisionSince(responseBody);
    assertPackageRevision(packageRevision, "abc.rpm", "some-user", "2011-07-14T19:43:37.100Z", "comment", "http:\\localhost:9999");
}
Also used : PackageRevision(com.thoughtworks.go.plugin.api.material.packagerepository.PackageRevision) 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