Search in sources :

Example 1 with FetchArtifactBuilder

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

the class FetchTaskBuilderTest method shouldUseCorrectStageCounterWhenFetchingFromSamePipelineAndStageThatHasBeenRun.

@Test
public void shouldUseCorrectStageCounterWhenFetchingFromSamePipelineAndStageThatHasBeenRun() {
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("dev"), new CaseInsensitiveString("linux-firefox"), "", "");
    Pipeline pipeline = pipelineWithStage("mingle", 1, "label-1", "dev", 2);
    FetchArtifactBuilder builder = (FetchArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(builder.getJobIdentifier(), Matchers.is(new JobIdentifier("mingle", 1, "label-1", "dev", "2", "linux-firefox", 0L)));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Test(org.junit.Test)

Example 2 with FetchArtifactBuilder

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

the class FetchTaskBuilderTest method shouldUseNameAndLabelFromPipelineWhenPipelineNameOfFetchTaskIsEmpty.

@Test
public void shouldUseNameAndLabelFromPipelineWhenPipelineNameOfFetchTaskIsEmpty() {
    FetchTask fetchTask = new FetchTask();
    fetchTask.setSrcfile("a.txt");
    Pipeline pipeline = pipeline(LABEL);
    FetchArtifactBuilder builder = (FetchArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(builder.getJobIdentifier().getPipelineName(), is("cruise"));
    assertThat(builder.getJobIdentifier().getPipelineLabel(), is(LABEL));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Test(org.junit.Test)

Example 3 with FetchArtifactBuilder

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

the class FetchTaskBuilderTest method shouldUseLatestStageWhenFetchingFromDifferentStageInDependencyPipeline.

@Test
public void shouldUseLatestStageWhenFetchingFromDifferentStageInDependencyPipeline() {
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("ft"), new CaseInsensitiveString("linux-firefox"), "", "");
    Pipeline pipeline = pipelineWithDepencencyMaterial("cruise", "mingle", 1, "label-1", "dev", 2);
    FetchArtifactBuilder builder = (FetchArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(builder.getJobIdentifier(), is(new JobIdentifier("mingle", 1, "label-1", "ft", "latest", "linux-firefox", 0L)));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) Test(org.junit.Test)

Example 4 with FetchArtifactBuilder

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

the class FetchTaskBuilderTest method shouldGetTheRightDestAndJobLocatorOnAgent.

@Test
public void shouldGetTheRightDestAndJobLocatorOnAgent() {
    Pipeline pipeline = pipelineWithDepencencyMaterial("cruise", "mingle", 1, "label-1", "dev", 2);
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("mingle"), new CaseInsensitiveString("dev"), new CaseInsensitiveString("one"), "", "dest");
    FetchHandler fetchHandler = fetchTaskBuilder.getHandler(fetchTask, pipeline.getName());
    FetchArtifactBuilder builder = (FetchArtifactBuilder) fetchTaskBuilder.createBuilder(builderFactory, fetchTask, pipeline, resolver);
    assertThat(fetchHandler, is(new FileHandler(new File("pipelines/cruise/dest"), getSrc())));
    assertThat(builder.jobLocatorForDisplay(), is("mingle/label-1/dev/2/one"));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) File(java.io.File) Test(org.junit.Test)

Example 5 with FetchArtifactBuilder

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

the class FetchTaskBuilderTest method shouldFetchFromCorrectAncestorStageInstance_InCaseOfLinerDependency.

@Test
public void shouldFetchFromCorrectAncestorStageInstance_InCaseOfLinerDependency() {
    FetchTask fetchTask = new FetchTask(new CaseInsensitiveString("uppest/up/down"), new CaseInsensitiveString("uppest-stage"), new CaseInsensitiveString("uppest-job"), "src", "dest");
    Pipeline pipeline = pipelineWithDepencencyMaterial("downest", "down", 1, "down-1", "down-stage", 2);
    DependencyMaterialRevision revisionOfDown = DependencyMaterialRevision.create("down/1/down-stage/2", "down-1");
    when(resolver.buildCauseFor(revisionOfDown.getPipelineName(), revisionOfDown.getPipelineCounter())).thenReturn(pipelineWithDepencencyMaterial("down", "up", 5, "up-5", "up-stage", 3).getBuildCause());
    DependencyMaterialRevision revisionOfUp = DependencyMaterialRevision.create("up/5/up-stage/3", "up-5");
    when(resolver.buildCauseFor(revisionOfUp.getPipelineName(), revisionOfUp.getPipelineCounter())).thenReturn(pipelineWithDepencencyMaterial("up", "uppest", 3, "uppest-3", "uppest-stage", 4).getBuildCause());
    FetchArtifactBuilder builder = (FetchArtifactBuilder) 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", 3, "uppest-3", "uppest-stage", "4", "uppest-job", 0l)));
}
Also used : FetchArtifactBuilder(com.thoughtworks.go.domain.builder.FetchArtifactBuilder) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Aggregations

FetchArtifactBuilder (com.thoughtworks.go.domain.builder.FetchArtifactBuilder)10 Test (org.junit.Test)8 Builder (com.thoughtworks.go.domain.builder.Builder)2 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)1 JobIdentifier (com.thoughtworks.go.domain.JobIdentifier)1 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)1 BuildWork (com.thoughtworks.go.remote.work.BuildWork)1 File (java.io.File)1