Search in sources :

Example 1 with FetchPluggableArtifactBuilder

use of com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder in project gocd by gocd.

the class FetchTaskBuilderTest method FetchPluggableArtifactTask_shouldFindStageCounterFromDependenciesWhenPipelineNameIsDifferent.

@Test
public void FetchPluggableArtifactTask_shouldFindStageCounterFromDependenciesWhenPipelineNameIsDifferent() {
    FetchPluggableArtifactTask fetchTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("uppest_stream"), new CaseInsensitiveString("uppest-stage1"), new CaseInsensitiveString("uppest-job1"), "installer");
    Pipeline pipeline = pipelineWithDepencencyMaterial("cruise", "uppest_stream", 1, "label-1", "uppest-stage1", 2);
    FetchPluggableArtifactBuilder builder = (FetchPluggableArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(builder.getJobIdentifier().getStageCounter(), is("2"));
}
Also used : FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) Test(org.junit.Test)

Example 2 with FetchPluggableArtifactBuilder

use of com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder in project gocd by gocd.

the class FetchTaskBuilderTest method FetchPluggableArtifactTask_shouldFetchFromCorrectAncestorStageInstance_InCaseOfLinerDependency.

@Test
public void FetchPluggableArtifactTask_shouldFetchFromCorrectAncestorStageInstance_InCaseOfLinerDependency() {
    FetchPluggableArtifactTask fetchTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("uppest_stream/upstream/downstream"), new CaseInsensitiveString("uppest-stage1"), new CaseInsensitiveString("uppest-job1"), "installer");
    Pipeline pipeline = pipelineWithDepencencyMaterial("downest", "downstream", 1, "down-1", "stage", 2);
    DependencyMaterialRevision revisionOfDown = DependencyMaterialRevision.create("downstream/1/stage/2", "down-1");
    when(resolver.buildCauseFor(revisionOfDown.getPipelineName(), revisionOfDown.getPipelineCounter())).thenReturn(pipelineWithDepencencyMaterial("downstream", "upstream", 5, "up-5", "stage", 3).getBuildCause());
    DependencyMaterialRevision revisionOfUp = DependencyMaterialRevision.create("upstream/5/stage/3", "up-5");
    when(resolver.buildCauseFor(revisionOfUp.getPipelineName(), revisionOfUp.getPipelineCounter())).thenReturn(pipelineWithDepencencyMaterial("upstream", "uppest_stream", 3, "uppest-3", "uppest-stage1", 4).getBuildCause());
    FetchPluggableArtifactBuilder builder = (FetchPluggableArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    verify(resolver).buildCauseFor(revisionOfDown.getPipelineName(), revisionOfDown.getPipelineCounter());
    verify(resolver).buildCauseFor(revisionOfUp.getPipelineName(), revisionOfUp.getPipelineCounter());
    assertThat(builder.getJobIdentifier(), is(new JobIdentifier("uppest_stream", 3, "uppest-3", "uppest-stage1", "4", "uppest-job1", 0l)));
}
Also used : FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 3 with FetchPluggableArtifactBuilder

use of com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder in project gocd by gocd.

the class FetchTaskBuilderTest method FetchPluggableArtifactTask_shouldUseCorrectStageCounterWhenFetchingFromDependencyStage.

@Test
public void FetchPluggableArtifactTask_shouldUseCorrectStageCounterWhenFetchingFromDependencyStage() {
    FetchPluggableArtifactTask fetchTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("uppest_stream"), new CaseInsensitiveString("uppest-stage1"), new CaseInsensitiveString("uppest-job1"), "installer");
    Pipeline pipeline = pipelineWithDepencencyMaterial("cruise", "uppest_stream", 1, "label-1", "uppest-stage1", 2);
    FetchPluggableArtifactBuilder builder = (FetchPluggableArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(builder.getJobIdentifier(), is(new JobIdentifier("uppest_stream", 1, "label-1", "uppest-stage1", "2", "uppest-job1", 0L)));
}
Also used : FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) Test(org.junit.Test)

Example 4 with FetchPluggableArtifactBuilder

use of com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder in project gocd by gocd.

the class FetchTaskBuilder method createPluggableFetchTaskBuilder.

private Builder createPluggableFetchTaskBuilder(FetchPluggableArtifactTask task, Pipeline pipeline, JobIdentifier fetchFrom, Builder cancelBuilder, ChecksumFileHandler checksumHandler) {
    final ArtifactStore artifactStore = getArtifactStoreFor(task, fetchFrom);
    final String fileName = format("%s.json", artifactStore.getPluginId());
    final String metadataFileLocationOnServer = format("%s/%s", PLUGGABLE_ARTIFACT_METADATA_FOLDER, fileName);
    final File metadataFileDest = task.artifactDest(pipeline.getName(), fileName);
    return new FetchPluggableArtifactBuilder(task.getConditions(), cancelBuilder, task.describe(), fetchFrom, artifactStore, task.getConfiguration(), task.getArtifactId(), metadataFileLocationOnServer, metadataFileDest, checksumHandler);
}
Also used : FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) File(java.io.File)

Example 5 with FetchPluggableArtifactBuilder

use of com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder in project gocd by gocd.

the class FetchTaskBuilderTest method FetchPluggableArtifactTask_shouldUseLatestStageWhenFetchingFromDifferentStageInDependencyPipeline.

@Test
public void FetchPluggableArtifactTask_shouldUseLatestStageWhenFetchingFromDifferentStageInDependencyPipeline() {
    FetchPluggableArtifactTask fetchTask = new FetchPluggableArtifactTask(new CaseInsensitiveString("uppest_stream"), new CaseInsensitiveString("uppest-stage2"), new CaseInsensitiveString("uppest-job2"), "installer");
    Pipeline pipeline = pipelineWithDepencencyMaterial("cruise", "uppest_stream", 1, "label-1", "uppest-stage1", 2);
    FetchPluggableArtifactBuilder builder = (FetchPluggableArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(builder.getJobIdentifier(), is(new JobIdentifier("uppest_stream", 1, "label-1", "uppest-stage2", "latest", "uppest-job2", 0L)));
}
Also used : FetchPluggableArtifactBuilder(com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder) Test(org.junit.Test)

Aggregations

FetchPluggableArtifactBuilder (com.thoughtworks.go.domain.builder.FetchPluggableArtifactBuilder)10 Test (org.junit.Test)9 File (java.io.File)2 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)1