Search in sources :

Example 1 with FetchPluggableArtifactTask

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

the class TaskViewServiceTest method shouldNotGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOff.

@Test
public void shouldNotGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOff() {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    taskClasses.add(FetchPluggableArtifactTask.class);
    when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(false);
    when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
    when(registry.getViewModelFor(new FetchPluggableArtifactTask(), "new")).thenReturn(viewModel(new FetchPluggableArtifactTask()));
    when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(new TaskViewModel(new ExecTask(), ""));
    List<PluggableViewModel> taskViewModels = taskViewService.getTaskViewModels();
    assertThat(taskViewModels.size(), is(3));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
    assertThat(taskViewModels.indexOf(viewModel(new FetchPluggableArtifactTask())), is(-1));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) FetchTask(com.thoughtworks.go.config.FetchTask) AntTask(com.thoughtworks.go.config.AntTask) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskViewModel(com.thoughtworks.go.presentation.TaskViewModel) ExecTask(com.thoughtworks.go.config.ExecTask) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) Test(org.junit.Test)

Example 2 with FetchPluggableArtifactTask

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

the class ArtifactExtensionTest method shouldSubmitFetchArtifactRequest.

@Test
public void shouldSubmitFetchArtifactRequest() throws JSONException {
    when(pluginManager.submitTo(eq(PLUGIN_ID), eq(ARTIFACT_EXTENSION), requestArgumentCaptor.capture())).thenReturn(DefaultGoPluginApiResponse.success(""));
    final FetchPluggableArtifactTask pluggableArtifactTask = new FetchPluggableArtifactTask(null, null, "artifactId", create("Filename", false, "build/libs/foo.jar"));
    artifactExtension.fetchArtifact(PLUGIN_ID, new ArtifactStore("s3", "cd.go.s3"), pluggableArtifactTask.getConfiguration(), Collections.singletonMap("Version", "10.12.0"), "/temp");
    final GoPluginApiRequest request = requestArgumentCaptor.getValue();
    final String requestBody = "{\n" + "  \"artifact_metadata\": {\n" + "    \"Version\": \"10.12.0\"\n" + "  },\n" + "  \"store_configuration\": {},\n" + "  \"fetch_artifact_configuration\": {\n" + "      \"Filename\": \"build/libs/foo.jar\"\n" + "  },\n" + "  \"agent_working_directory\": \"/temp\"\n" + "}";
    assertThat(request.extension(), is(ARTIFACT_EXTENSION));
    assertThat(request.requestName(), is(REQUEST_FETCH_ARTIFACT));
    JSONAssert.assertEquals(requestBody, request.requestBody(), true);
}
Also used : GoPluginApiRequest(com.thoughtworks.go.plugin.api.request.GoPluginApiRequest) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) Test(org.junit.Test)

Example 3 with FetchPluggableArtifactTask

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

the class FetchPluggableArtifactBuilderTest method setUp.

@Before
public void setUp() throws Exception {
    publisher = mock(DefaultGoPublisher.class);
    artifactExtension = mock(ArtifactExtension.class);
    checksumFileHandler = mock(ChecksumFileHandler.class);
    registry = mock(PluginRequestProcessorRegistry.class);
    metadataDest = new File(temporaryFolder.newFolder("dest"), "cd.go.s3.json");
    FileUtils.writeStringToFile(metadataDest, "{\"artifactId\":{}}", StandardCharsets.UTF_8);
    jobIdentifier = new JobIdentifier("cruise", -10, "1", "dev", "1", "windows", 1L);
    artifactStore = new ArtifactStore("s3", "cd.go.s3", ConfigurationPropertyMother.create("ACCESS_KEY", true, "hksjdfhsksdfh"));
    fetchPluggableArtifactTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("dev"), new CaseInsensitiveString("windows"), "artifactId", ConfigurationPropertyMother.create("Destination", false, "build/"));
    sourceOnServer = format("%s/%s", PLUGGABLE_ARTIFACT_METADATA_FOLDER, "cd.go.s3.json");
    when(checksumFileHandler.handleResult(SC_OK, publisher)).thenReturn(true);
}
Also used : DefaultGoPublisher(com.thoughtworks.go.work.DefaultGoPublisher) ArtifactStore(com.thoughtworks.go.config.ArtifactStore) ArtifactExtension(com.thoughtworks.go.plugin.access.artifact.ArtifactExtension) PluginRequestProcessorRegistry(com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry) JobIdentifier(com.thoughtworks.go.domain.JobIdentifier) ChecksumFileHandler(com.thoughtworks.go.domain.ChecksumFileHandler) File(java.io.File) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Before(org.junit.Before)

Example 4 with FetchPluggableArtifactTask

use of com.thoughtworks.go.config.FetchPluggableArtifactTask 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 5 with FetchPluggableArtifactTask

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

the class TaskViewServiceTest method shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn.

@Test
public void shouldGetViewModelForPluggableFetchArtifactTaskWhenToggleIsOn() {
    List<Class<? extends Task>> taskClasses = taskImplementations();
    taskClasses.add(FetchPluggableArtifactTask.class);
    when(featureToggleService.isToggleOn(Toggles.ARTIFACT_EXTENSION_KEY)).thenReturn(true);
    when(registry.implementersOf(Task.class)).thenReturn(taskClasses);
    when(registry.getViewModelFor(new FetchPluggableArtifactTask(), "new")).thenReturn(viewModel(new FetchPluggableArtifactTask()));
    when(registry.getViewModelFor(new ExecTask(), "new")).thenReturn(new TaskViewModel(new ExecTask(), ""));
    List<PluggableViewModel> taskViewModels = taskViewService.getTaskViewModels();
    assertThat(taskViewModels.size(), is(4));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new ExecTask(), "")));
    assertThat(taskViewModels, hasItem((PluggableViewModel) new TaskViewModel(new FetchPluggableArtifactTask(), "")));
}
Also used : ExecTask(com.thoughtworks.go.config.ExecTask) Task(com.thoughtworks.go.domain.Task) FetchTask(com.thoughtworks.go.config.FetchTask) AntTask(com.thoughtworks.go.config.AntTask) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) PluggableTask(com.thoughtworks.go.config.pluggabletask.PluggableTask) TaskViewModel(com.thoughtworks.go.presentation.TaskViewModel) ExecTask(com.thoughtworks.go.config.ExecTask) PluggableViewModel(com.thoughtworks.go.plugins.presentation.PluggableViewModel) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) Test(org.junit.Test)

Aggregations

FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)5 Test (org.junit.Test)4 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)3 AntTask (com.thoughtworks.go.config.AntTask)2 ExecTask (com.thoughtworks.go.config.ExecTask)2 FetchTask (com.thoughtworks.go.config.FetchTask)2 PluggableTask (com.thoughtworks.go.config.pluggabletask.PluggableTask)2 Task (com.thoughtworks.go.domain.Task)2 PluggableViewModel (com.thoughtworks.go.plugins.presentation.PluggableViewModel)2 TaskViewModel (com.thoughtworks.go.presentation.TaskViewModel)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 GoPluginApiRequest (com.thoughtworks.go.plugin.api.request.GoPluginApiRequest)1 PluginRequestProcessorRegistry (com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry)1 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)1 File (java.io.File)1 Before (org.junit.Before)1