Search in sources :

Example 11 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore in project gocd by gocd.

the class ArtifactsPublisher method artifactStoresToPlugin.

private Map<ArtifactPlan, ArtifactStore> artifactStoresToPlugin(List<ArtifactPlan> artifactPlans) {
    final HashMap<ArtifactPlan, ArtifactStore> artifactPlanToArtifactStoreMap = new HashMap<>();
    for (ArtifactPlan artifactPlan : artifactPlans) {
        final String storeId = (String) artifactPlan.getPluggableArtifactConfiguration().get("storeId");
        artifactPlanToArtifactStoreMap.put(artifactPlan, artifactStores.find(storeId));
    }
    return artifactPlanToArtifactStoreMap;
}
Also used : ArtifactPlan(com.thoughtworks.go.domain.ArtifactPlan) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) HashMap(java.util.HashMap)

Example 12 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore in project gocd by gocd.

the class ArtifactMessageConverterV1Test method fetchArtifactMessage_shouldSerializeToJson.

@Test
public void fetchArtifactMessage_shouldSerializeToJson() throws JSONException {
    final ArtifactMessageConverterV1 converter = new ArtifactMessageConverterV1();
    final ArtifactStore artifactStore = new ArtifactStore("s3-store", "pluginId", create("Foo", false, "Bar"));
    final Map<String, Object> metadata = Collections.singletonMap("Version", "10.12.0");
    final FetchPluggableArtifactTask pluggableArtifactTask = new FetchPluggableArtifactTask(null, null, "artifactId", create("Filename", false, "build/libs/foo.jar"));
    final String fetchArtifactMessage = converter.fetchArtifactMessage(artifactStore, pluggableArtifactTask.getConfiguration(), metadata, "/temp");
    final String expectedStr = "{\n" + "  \"artifact_metadata\": {\n" + "    \"Version\": \"10.12.0\"\n" + "  },\n" + "  \"store_configuration\": {\n" + "    \"Foo\": \"Bar\"\n" + "  },\n" + "  \"fetch_artifact_configuration\": {\n" + "      \"Filename\": \"build/libs/foo.jar\"\n" + "    },\n" + "  \"agent_working_directory\": \"/temp\"\n" + "}";
    JSONAssert.assertEquals(expectedStr, fetchArtifactMessage, true);
}
Also used : ArtifactStore(com.thoughtworks.go.config.ArtifactStore) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) Test(org.junit.Test)

Example 13 with ArtifactStore

use of com.thoughtworks.go.config.ArtifactStore in project gocd by gocd.

the class ArtifactMessageConverterV1Test method publishArtifactMessage_shouldSerializeToJson.

@Test
public void publishArtifactMessage_shouldSerializeToJson() throws JSONException {
    final ArtifactMessageConverterV1 converter = new ArtifactMessageConverterV1();
    final ArtifactStore artifactStore = new ArtifactStore("s3-store", "pluginId", create("Foo", false, "Bar"));
    final ArtifactPlan artifactPlan = new ArtifactPlan(new PluggableArtifactConfig("installers", "s3-store", create("Baz", true, "Car")));
    final String publishArtifactMessage = converter.publishArtifactMessage(artifactPlan, artifactStore, "/temp");
    final String expectedStr = "{\n" + "  \"artifact_plan\": {\n" + "    \"configuration\": {\n" + "      \"Baz\": \"Car\"\n" + "    },\n" + "    \"id\": \"installers\",\n" + "    \"storeId\": \"s3-store\"\n" + "  },\n" + "  \"artifact_store\": {\n" + "    \"configuration\": {\n" + "      \"Foo\": \"Bar\"\n" + "    },\n" + "    \"id\": \"s3-store\"\n" + "  },\n" + "  \"agent_working_directory\": \"/temp\"\n" + "}";
    JSONAssert.assertEquals(expectedStr, publishArtifactMessage, true);
}
Also used : PluggableArtifactConfig(com.thoughtworks.go.config.PluggableArtifactConfig) ArtifactPlan(com.thoughtworks.go.domain.ArtifactPlan) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) Test(org.junit.Test)

Aggregations

ArtifactStore (com.thoughtworks.go.config.ArtifactStore)13 Test (org.junit.Test)11 PluggableArtifactConfig (com.thoughtworks.go.config.PluggableArtifactConfig)8 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)7 PublishArtifactResponse (com.thoughtworks.go.plugin.access.artifact.model.PublishArtifactResponse)7 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)3 ArtifactPlan (com.thoughtworks.go.domain.ArtifactPlan)3 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)2 GoPublisher (com.thoughtworks.go.work.GoPublisher)2 IOException (java.io.IOException)2 ExpectedException (org.junit.rules.ExpectedException)2 InOrder (org.mockito.InOrder)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)1 ChecksumFileHandler (com.thoughtworks.go.domain.ChecksumFileHandler)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 ArtifactExtension (com.thoughtworks.go.plugin.access.artifact.ArtifactExtension)1 PluginRequestProcessorRegistry (com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 File (java.io.File)1 HashMap (java.util.HashMap)1