Search in sources :

Example 1 with ArtifactExtension

use of com.thoughtworks.go.plugin.access.artifact.ArtifactExtension 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 2 with ArtifactExtension

use of com.thoughtworks.go.plugin.access.artifact.ArtifactExtension in project gocd by gocd.

the class ArtifactsPublisherTest method setUp.

@BeforeEach
public void setUp() throws IOException {
    artifactExtension = mock(ArtifactExtension.class);
    registry = mock(PluginRequestProcessorRegistry.class);
    publisher = new StubGoPublisher();
    artifactsPublisher = new ArtifactsPublisher(publisher, artifactExtension, new ArtifactStores(), registry, workingFolder);
    File file = new File(workingFolder, "cruise-output/log.xml");
    file.getParentFile().mkdirs();
    file.createNewFile();
}
Also used : ArtifactStores(com.thoughtworks.go.config.ArtifactStores) ArtifactExtension(com.thoughtworks.go.plugin.access.artifact.ArtifactExtension) PluginRequestProcessorRegistry(com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry) File(java.io.File) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with ArtifactExtension

use of com.thoughtworks.go.plugin.access.artifact.ArtifactExtension in project gocd by gocd.

the class BuildWorkTest method shouldCallArtifactExtensionToPublishPluggableArtifact.

@Test
void shouldCallArtifactExtensionToPublishPluggableArtifact() throws Exception {
    final ArtifactExtension artifactExtension = mock(ArtifactExtension.class);
    buildWork = (BuildWork) getWork(pluggableArtifact(), PIPELINE_NAME);
    artifactManipulator = new GoArtifactsManipulatorStub(new HttpServiceStub(SC_NOT_ACCEPTABLE));
    buildWork.doWork(environmentVariableContext, new AgentWorkContext(agentIdentifier, buildRepository, artifactManipulator, new AgentRuntimeInfo(agentIdentifier, AgentRuntimeStatus.Idle, currentWorkingDirectory(), "cookie"), packageRepositoryExtension, scmExtension, taskExtension, artifactExtension, pluginRequestProcessorRegistry));
    verify(artifactExtension).publishArtifact(anyString(), any(ArtifactPlan.class), any(ArtifactStore.class), anyString(), any(EnvironmentVariableContext.class));
}
Also used : AgentRuntimeInfo(com.thoughtworks.go.server.service.AgentRuntimeInfo) ArtifactExtension(com.thoughtworks.go.plugin.access.artifact.ArtifactExtension) EnvironmentVariableContext(com.thoughtworks.go.util.command.EnvironmentVariableContext) Test(org.junit.jupiter.api.Test)

Example 4 with ArtifactExtension

use of com.thoughtworks.go.plugin.access.artifact.ArtifactExtension in project gocd by gocd.

the class ExternalArtifactsServiceTest method setUp.

@BeforeEach
public void setUp() {
    artifactExtension = mock(ArtifactExtension.class);
    externalArtifactsService = new ExternalArtifactsService(artifactExtension);
    ArtifactPluginInfo pluginInfo = mock(ArtifactPluginInfo.class);
    PluginDescriptor pluginDescriptor = mock(PluginDescriptor.class);
    when(pluginInfo.getDescriptor()).thenReturn(pluginDescriptor);
    when(pluginDescriptor.id()).thenReturn(pluginId);
    ArtifactMetadataStore.instance().setPluginInfo(pluginInfo);
    pluggableArtifactConfig = new PluggableArtifactConfig("foo", "bar");
    pipelineConfig = PipelineConfigMother.createPipelineConfig("p1", "s1", "j1");
    pipelineConfig.getStage("s1").jobConfigByConfigName("j1").artifactTypeConfigs().add(pluggableArtifactConfig);
    fetchPluggableArtifactTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("p1"), new CaseInsensitiveString("s1"), new CaseInsensitiveString("j1"), "foo");
    cruiseConfig = GoConfigMother.defaultCruiseConfig();
    cruiseConfig.addPipelineWithoutValidation("group", pipelineConfig);
    cruiseConfig.getArtifactStores().add(new ArtifactStore("bar", pluginId));
}
Also used : PluginDescriptor(com.thoughtworks.go.plugin.api.info.PluginDescriptor) ArtifactExtension(com.thoughtworks.go.plugin.access.artifact.ArtifactExtension) ArtifactPluginInfo(com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with ArtifactExtension

use of com.thoughtworks.go.plugin.access.artifact.ArtifactExtension in project gocd by gocd.

the class FetchPluggableArtifactBuilderTest method setUp.

@BeforeEach
public void setUp(@TempDir Path tempDir) throws Exception {
    publisher = mock(DefaultGoPublisher.class);
    artifactExtension = mock(ArtifactExtension.class);
    checksumFileHandler = mock(ChecksumFileHandler.class);
    registry = mock(PluginRequestProcessorRegistry.class);
    metadataDest = TempDirUtils.createTempDirectoryIn(tempDir, "dest").resolve("cd.go.s3.json").toFile();
    FileUtils.writeStringToFile(metadataDest, "{\"artifactId\":{}}", StandardCharsets.UTF_8);
    jobIdentifier = new JobIdentifier("cruise", -10, "1", "dev", "1", "windows", 1L);
    artifactStore = new ArtifactStore("s3", PLUGIN_ID, 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) FetchPluggableArtifactTask(com.thoughtworks.go.config.FetchPluggableArtifactTask) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

ArtifactExtension (com.thoughtworks.go.plugin.access.artifact.ArtifactExtension)5 PluginRequestProcessorRegistry (com.thoughtworks.go.plugin.infra.PluginRequestProcessorRegistry)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 ArtifactStore (com.thoughtworks.go.config.ArtifactStore)2 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)2 FetchPluggableArtifactTask (com.thoughtworks.go.config.FetchPluggableArtifactTask)2 ChecksumFileHandler (com.thoughtworks.go.domain.ChecksumFileHandler)2 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)2 DefaultGoPublisher (com.thoughtworks.go.work.DefaultGoPublisher)2 File (java.io.File)2 ArtifactStores (com.thoughtworks.go.config.ArtifactStores)1 PluginDescriptor (com.thoughtworks.go.plugin.api.info.PluginDescriptor)1 ArtifactPluginInfo (com.thoughtworks.go.plugin.domain.artifact.ArtifactPluginInfo)1 AgentRuntimeInfo (com.thoughtworks.go.server.service.AgentRuntimeInfo)1 EnvironmentVariableContext (com.thoughtworks.go.util.command.EnvironmentVariableContext)1 Before (org.junit.Before)1 Test (org.junit.jupiter.api.Test)1