Search in sources :

Example 86 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.

the class MaterialDatabaseDependencyUpdaterTest method shouldReturnNoNewModificationsIfNoNewPipelineHasBennCompleted.

@Test
public void shouldReturnNoNewModificationsIfNoNewPipelineHasBennCompleted() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    stubStageServiceGetHistory(null, stages(9));
    updater.updateMaterial(dependencyMaterial);
    List<Modification> modification = materialRepository.findLatestModification(dependencyMaterial).getMaterialRevision(0).getModifications();
    stubStageServiceGetHistoryAfter(dependencyMaterial, 9, stages());
    updater.updateMaterial(dependencyMaterial);
    List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
    assertThat(newModifications.size(), is(0));
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) MaterialRevision(com.thoughtworks.go.domain.MaterialRevision) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 87 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.

the class MaterialDatabaseDependencyUpdaterTest method stubStageServiceGetHistory.

private void stubStageServiceGetHistory(DependencyMaterial dependencyMaterial, Stages... stageses) {
    if (material == null) {
        dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    }
    for (int i = 0; i < stageses.length; i++) {
        ArrayList<Modification> mods = new ArrayList<>();
        for (Stage stage : stageses[i]) {
            StageIdentifier id = stage.getIdentifier();
            mods.add(new Modification(stage.completedDate(), id.stageLocator(), id.getPipelineLabel(), stage.getPipelineId()));
        }
        Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(dependencyMaterial, Pagination.pageStartingAt(i * MaterialDatabaseUpdater.STAGES_PER_PAGE, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(mods);
    }
    Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(dependencyMaterial, Pagination.pageStartingAt(MaterialDatabaseUpdater.STAGES_PER_PAGE * stageses.length, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(new ArrayList<>());
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) StageIdentifier(com.thoughtworks.go.domain.StageIdentifier) ArrayList(java.util.ArrayList) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString)

Example 88 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method shouldFindModificationsForAStageIdentifier.

@Test
public void shouldFindModificationsForAStageIdentifier() {
    DependencyMaterial material = new DependencyMaterial(new CaseInsensitiveString("P1"), new CaseInsensitiveString("S1"));
    repo.saveOrUpdate(material.createMaterialInstance());
    saveOneDependencyModification(material, "P1/1/S1/1");
    saveOneDependencyModification(material, "P1/2/S1/1");
    saveOneDependencyModification(material, "P1/1/S2/1");
    saveOneDependencyModification(material, "P2/1/S1/1");
    StageIdentifier stageIdentifier = new StageIdentifier("P1", 2, "2", "S1", "1");
    List<Modification> modifications = repo.modificationFor(stageIdentifier);
    assertThat(modifications.size(), is(1));
    assertThat(modifications.get(0).getRevision(), is("P1/2/S1/1"));
    assertThat(goCache.get(repo.cacheKeyForModificationsForStageLocator(stageIdentifier)), is(modifications));
    StageIdentifier p2_s1_stageId = new StageIdentifier("P2", 1, "S1", "1");
    List<Modification> mod_p2_s1 = repo.modificationFor(p2_s1_stageId);
    assertThat(goCache.get(repo.cacheKeyForModificationsForStageLocator(p2_s1_stageId)), is(mod_p2_s1));
    StageIdentifier p2_s1_3 = new StageIdentifier("P2", 1, "S1", "3");
    assertThat(repo.modificationFor(p2_s1_3).isEmpty(), is(true));
    assertThat(goCache.get(repo.cacheKeyForModificationsForStageLocator(p2_s1_3)), is(nullValue()));
}
Also used : DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 89 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method hasPipelineEverRunWithMultipleMaterialsAndNewChanges.

@Test
public void hasPipelineEverRunWithMultipleMaterialsAndNewChanges() {
    HgMaterial material = MaterialsMother.hgMaterial("hgUrl", "dest");
    MaterialRevision hgMaterialRevision = saveOneScmModification(material, "user", "file");
    DependencyMaterial depMaterial = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
    MaterialRevision depMaterialRevision = saveOneDependencyModification(depMaterial, "blahPipeline/1/blahStage/1");
    PipelineConfig pipelineConfig = PipelineMother.createPipelineConfig("mingle", new MaterialConfigs(material.config(), depMaterial.config()), "dev");
    MaterialRevisions revisions = new MaterialRevisions(hgMaterialRevision, depMaterialRevision);
    pipelineSqlMapDao.save(instanceFactory.createPipelineInstance(pipelineConfig, BuildCause.createManualForced(revisions, Username.ANONYMOUS), new DefaultSchedulingContext(DEFAULT_APPROVED_BY), md5, new TimeProvider()));
    MaterialRevision laterRevision = saveOneScmModification(material, "user", "file");
    MaterialRevisions newRevisions = new MaterialRevisions(depMaterialRevision, laterRevision);
    assertThat(repo.hasPipelineEverRunWith("mingle", newRevisions), is(false));
}
Also used : MaterialConfigs(com.thoughtworks.go.config.materials.MaterialConfigs) PipelineConfig(com.thoughtworks.go.config.PipelineConfig) TimeProvider(com.thoughtworks.go.util.TimeProvider) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 90 with DependencyMaterial

use of com.thoughtworks.go.config.materials.dependency.DependencyMaterial in project gocd by gocd.

the class MaterialRepositoryIntegrationTest method shouldReturnModificationForASpecificRevision.

@Test
public void shouldReturnModificationForASpecificRevision() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("blahPipeline"), new CaseInsensitiveString("blahStage"));
    MaterialRevision originalRevision = saveOneDependencyModification(dependencyMaterial, "blahPipeline/3/blahStage/1");
    Modification modification = repo.findModificationWithRevision(dependencyMaterial, "blahPipeline/3/blahStage/1");
    assertThat(modification.getRevision(), is("blahPipeline/3/blahStage/1"));
    assertEquals(originalRevision.getModification(0).getModifiedTime(), modification.getModifiedTime());
}
Also used : DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Aggregations

DependencyMaterial (com.thoughtworks.go.config.materials.dependency.DependencyMaterial)97 Test (org.junit.Test)75 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)64 Modification (com.thoughtworks.go.domain.materials.Modification)30 MaterialRevision (com.thoughtworks.go.domain.MaterialRevision)29 Date (java.util.Date)22 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)19 MaterialRevisions (com.thoughtworks.go.domain.MaterialRevisions)17 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)16 HgMaterial (com.thoughtworks.go.config.materials.mercurial.HgMaterial)15 Stage (com.thoughtworks.go.domain.Stage)14 GitMaterial (com.thoughtworks.go.config.materials.git.GitMaterial)13 Materials (com.thoughtworks.go.config.materials.Materials)12 Username (com.thoughtworks.go.server.domain.Username)12 Pipeline (com.thoughtworks.go.domain.Pipeline)11 DependencyMaterialRevision (com.thoughtworks.go.domain.materials.dependency.DependencyMaterialRevision)11 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)10 PipelineMaterialRevision (com.thoughtworks.go.domain.PipelineMaterialRevision)10 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)10 P4Material (com.thoughtworks.go.config.materials.perforce.P4Material)9