use of com.thoughtworks.go.domain.ArtifactPlan in project gocd by gocd.
the class ArtifactExtensionTest method shouldSubmitPublishArtifactRequest.
@Test
public void shouldSubmitPublishArtifactRequest() throws JSONException {
final String responseBody = "{\n" + " \"metadata\": {\n" + " \"artifact-version\": \"10.12.0\"\n" + " }\n" + "}";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
final PublishArtifactResponse response = artifactExtension.publishArtifact(PLUGIN_ID, new ArtifactPlan("{\"id\":\"installer\",\"storeId\":\"docker\"}"), new ArtifactStore("docker", "cd.go.docker"), "/temp");
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_PUBLISH_ARTIFACT));
final String expectedJSON = "{\n" + " \"artifact_plan\": {\n" + " \"id\": \"installer\",\n" + " \"storeId\": \"docker\"\n" + " },\n" + " \"artifact_store\": {\n" + " \"configuration\": {},\n" + " \"id\": \"docker\"\n" + " },\n" + " \"agent_working_directory\": \"/temp\"\n" + "}";
JSONAssert.assertEquals(expectedJSON, request.requestBody(), true);
assertThat(response.getMetadata().size(), is(1));
assertThat(response.getMetadata(), hasEntry("artifact-version", "10.12.0"));
}
use of com.thoughtworks.go.domain.ArtifactPlan in project gocd by gocd.
the class ArtifactExtensionTestBase method shouldSubmitPublishArtifactRequest.
@Test
public void shouldSubmitPublishArtifactRequest() {
final String responseBody = "{\n" + " \"metadata\": {\n" + " \"artifact-version\": \"10.12.0\"\n" + " }\n" + "}";
when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(responseBody));
ArtifactPlan artifactPlan = new ArtifactPlan("{\"id\":\"installer\",\"storeId\":\"docker\"}");
ArtifactStore artifactStore = new ArtifactStore("docker", "cd.go.docker");
EnvironmentVariableContext env = new EnvironmentVariableContext("foo", "bar");
final PublishArtifactResponse response = artifactExtension.publishArtifact(PLUGIN_ID, artifactPlan, artifactStore, "/temp", env);
final GoPluginApiRequest request = requestArgumentCaptor.getValue();
assertThat(request.extension(), is(ARTIFACT_EXTENSION));
assertThat(request.requestName(), is(REQUEST_PUBLISH_ARTIFACT));
final String expectedJSON = "{" + " \"artifact_plan\": {" + " \"id\": \"installer\"," + " \"storeId\": \"docker\"" + " }," + " \"artifact_store\": {" + " \"configuration\": {}," + " \"id\": \"docker\"" + " }," + " \"environment_variables\": {" + " \"foo\": \"bar\"" + " }," + " \"agent_working_directory\": \"/temp\"" + "}";
assertThatJson(expectedJSON).isEqualTo(request.requestBody());
assertThat(response.getMetadata().size(), is(1));
assertThat(response.getMetadata(), hasEntry("artifact-version", "10.12.0"));
}
use of com.thoughtworks.go.domain.ArtifactPlan in project gocd by gocd.
the class ArtifactPlanFilter method getBuiltInMergedArtifactPlans.
public List<ArtifactPlan> getBuiltInMergedArtifactPlans(List<ArtifactPlan> artifactPlans) {
MergedTestArtifactPlan testArtifactPlan = null;
final List<ArtifactPlan> mergedPlans = new ArrayList<>();
for (ArtifactPlan artifactPlan : artifactPlans) {
if (artifactPlan.getArtifactPlanType().isTest()) {
if (testArtifactPlan == null) {
testArtifactPlan = new MergedTestArtifactPlan(artifactPlan);
mergedPlans.add(testArtifactPlan);
} else {
testArtifactPlan.add(artifactPlan);
}
} else if (artifactPlan.getArtifactPlanType() == ArtifactPlanType.file) {
mergedPlans.add(artifactPlan);
}
}
return mergedPlans;
}
use of com.thoughtworks.go.domain.ArtifactPlan 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;
}
use of com.thoughtworks.go.domain.ArtifactPlan in project gocd by gocd.
the class ArtifactMessageConverterV1Test method publishArtifactMessage_shouldSerializeToJson.
@Test
public void publishArtifactMessage_shouldSerializeToJson() {
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 Map<String, String> environmentVariables = new HashMap<>();
environmentVariables.put("foo", "bar");
final String publishArtifactMessage = converter.publishArtifactMessage(artifactPlan, artifactStore, "/temp", environmentVariables);
final String expectedStr = "{" + " \"artifact_plan\": {" + " \"configuration\": {" + " \"Baz\": \"Car\"" + " }," + " \"id\": \"installers\"," + " \"storeId\": \"s3-store\"" + " }," + " \"artifact_store\": {" + " \"configuration\": {" + " \"Foo\": \"Bar\"" + " }," + " \"id\": \"s3-store\"" + " }," + " \"agent_working_directory\": \"/temp\"," + " \"environment_variables\": {" + " \"foo\": \"bar\"" + " }" + "}";
assertThatJson(expectedStr).isEqualTo(publishArtifactMessage);
}
Aggregations