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)));
}
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;
}
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);
}
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));
}
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)));
}
Aggregations