Search in sources :

Example 16 with DependencyMaterialRevision

use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.

the class DependencyMaterialTest method shouldDifferIfStageCounterHasChanged.

@Test
public void shouldDifferIfStageCounterHasChanged() {
    DependencyMaterialRevision rev1 = create("pipeline", 10, "1.0.123", "stage", 1);
    DependencyMaterialRevision rev2 = create("pipeline", 10, "1.0.123", "stage", 2);
    DependencyMaterialRevision rev3 = create("pipeline", 11, "1.0.123", "stage", 1);
    assertThat(rev1, is(not(rev2)));
    assertThat(rev2, is(not(rev3)));
    assertThat(rev3, is(not(rev1)));
}
Also used : DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Test(org.junit.Test)

Example 17 with DependencyMaterialRevision

use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.

the class ModificationsMother method changedDependencyMaterialRevision.

public static MaterialRevision changedDependencyMaterialRevision(String pipelineName, int pipelineCounter, String pipelineLabel, String stageName, int stageCounter, Date modifiedTime) {
    MaterialRevision materialRevision = dependencyMaterialRevision(pipelineName, pipelineCounter, pipelineLabel, stageName, stageCounter, modifiedTime);
    materialRevision.markAsChanged();
    return materialRevision;
}
Also used : DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 18 with DependencyMaterialRevision

use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.

the class MaterialRevisionBuilder method depInstance.

public Tuple depInstance(String pipelineName, int counter, Date modifiedTime, Tuple... buildCause) {
    String key = key(pipelineName, counter, modifiedTime);
    if (!instanceToRevision.containsKey(key)) {
        if (buildCause.length == 0) {
            throw new RuntimeException("Cannot create instance without a buildcause. You can retrive it without buildcause once it has been created");
        }
        DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString(pipelineName), new CaseInsensitiveString(STAGE_NAME));
        DependencyMaterialRevision revision = DependencyMaterialRevision.create(pipelineName, counter, "label", STAGE_NAME, 1);
        instanceToRevision.put(key, revision.convert(material, modifiedTime));
        final long id = getNextId();
        org.mockito.Mockito.when(pipelineDao.findPipelineByNameAndCounter(pipelineName, counter)).thenReturn(pipeline(id));
        org.mockito.Mockito.when(materialRepository.findMaterialRevisionsForPipeline(id)).thenReturn(buildCauseOfThisPipeline(buildCause));
    }
    MaterialRevision materialRevision = instanceToRevision.get(key);
    Materials materials = new Materials();
    for (MaterialRevision revision : buildCauseOfThisPipeline(buildCause)) {
        materials.add(revision.getMaterial());
    }
    PipelineConfig config = new PipelineConfig(new CaseInsensitiveString(pipelineName), materials.convertToConfigs(), new StageConfig(new CaseInsensitiveString(STAGE_NAME), new JobConfigs()));
    return new Tuple(new PipelineConfigDependencyGraph(config, dependencyGraphsFor(buildCause)), materialRevision);
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) Materials(com.thoughtworks.go.config.materials.Materials) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) StageConfig(com.thoughtworks.go.config.StageConfig) PipelineConfigDependencyGraph(com.thoughtworks.go.server.domain.PipelineConfigDependencyGraph) JobConfigs(com.thoughtworks.go.config.JobConfigs) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision)

Example 19 with DependencyMaterialRevision

use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.

the class PipelineSqlMapDaoIntegrationTest method shouldStoreAndRetrieveDependencyMaterialsWithMaxAllowedRevision.

@Test
public void shouldStoreAndRetrieveDependencyMaterialsWithMaxAllowedRevision() throws SQLException {
    char[] name = new char[255];
    for (int i = 0; i < 255; i++) {
        name[i] = 'a';
    }
    final String s = new String(name);
    final String s1 = new String(name);
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString(s), new CaseInsensitiveString(s1));
    PipelineConfig pipelineConfig = PipelineMother.twoBuildPlansWithResourcesAndMaterials("mingle", "dev");
    pipelineConfig.setMaterialConfigs(new MaterialConfigs(dependencyMaterial.config()));
    MaterialRevisions materialRevisions = new MaterialRevisions();
    DependencyMaterialRevision revision = DependencyMaterialRevision.create(new String(name), -10, new String(name), new String(name), Integer.MAX_VALUE);
    materialRevisions.addRevision(revision.convert(dependencyMaterial, new Date()));
    Pipeline pipeline = instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(materialRevisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider());
    assertNotInserted(pipeline.getId());
    savePipeline(pipeline);
    Pipeline pipelineFromDB = pipelineDao.loadPipeline(pipeline.getId());
    final Materials materials = pipelineFromDB.getMaterials();
    assertThat(materials.get(0), is(dependencyMaterial));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) TimeProvider(com.thoughtworks.go.util.TimeProvider) Materials(com.thoughtworks.go.config.materials.Materials) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) DependencyMaterialRevision(com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision) Date(java.util.Date) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) Test(org.junit.Test)

Example 20 with DependencyMaterialRevision

use of com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision in project gocd by gocd.

the class FetchTaskBuilderTest method FetchTask_shouldFetchFromCorrectAncestorStageInstance_InCaseOfLinerDependency.

@Test
public void FetchTask_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

DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)20 DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)7 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)6 Test (org.junit.Test)6 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)5 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)5 Date (java.util.Date)4 StageIdentifier (com.thoughtworks.go.domain.StageIdentifier)3 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)2 Materials (com.thoughtworks.go.config.materials.Materials)2 DependencyMaterialConfig (com.thoughtworks.go.config.materials.dependency.DependencyMaterialConfig)2 PipelineTimelineEntry (com.thoughtworks.go.domain.PipelineTimelineEntry)2 FetchArtifactBuilder (com.thoughtworks.go.domain.builder.FetchArtifactBuilder)2 Material (com.thoughtworks.go.domain.materials.Material)2 PipelineTimeline (com.thoughtworks.go.server.domain.PipelineTimeline)2 Pair (com.thoughtworks.go.util.Pair)2 ArrayList (java.util.ArrayList)2 ConcurrentLinkedQueue (java.util.concurrent.ConcurrentLinkedQueue)2 JobConfigs (com.thoughtworks.go.config.JobConfigs)1 PathFromAncestor (com.thoughtworks.go.config.PathFromAncestor)1