Search in sources :

Example 31 with DependencyMaterial

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

the class MaterialDatabaseDependencyUpdaterTest method shouldReturnLatestPipelineIfThereHasBeenANewOne.

@Test
public void shouldReturnLatestPipelineIfThereHasBeenANewOne() 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(null, 9, stages(10));
    updater.updateMaterial(dependencyMaterial);
    List<Modification> newModifications = materialRepository.findModificationsSince(dependencyMaterial, new MaterialRevision(dependencyMaterial, modification));
    assertThat(newModifications.size(), is(1));
    assertThat(newModifications.get(0).getRevision(), is("pipeline-name/10/stage-name/0"));
    assertThat(newModifications.get(0).getPipelineLabel(), is("LABEL-10"));
}
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 32 with DependencyMaterial

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

the class MaterialDatabaseDependencyUpdaterTest method shouldClearServerHealthIfCheckSucceeds.

@Test
public void shouldClearServerHealthIfCheckSucceeds() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    Mockito.when(dependencyMaterialSourceDao.getPassedStagesByName(new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name")), Pagination.pageStartingAt(0, null, MaterialDatabaseUpdater.STAGES_PER_PAGE))).thenReturn(new ArrayList<>());
    updater.updateMaterial(dependencyMaterial);
    Mockito.verify(healthService).removeByScope(HealthStateScope.forMaterial(dependencyMaterial));
}
Also used : DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 33 with DependencyMaterial

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

the class MaterialDatabaseDependencyUpdaterTest method shouldUpdateMaterialCorrectlyIfCaseOfPipelineNameIsDifferentInConfigurationOfDependencyMaterial.

@Test
public void shouldUpdateMaterialCorrectlyIfCaseOfPipelineNameIsDifferentInConfigurationOfDependencyMaterial() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("PIPEline-name"), new CaseInsensitiveString("STAge-name"));
    stubStageServiceGetHistory(dependencyMaterial, stages(1));
    // create the material instance
    updater.updateMaterial(dependencyMaterial);
    stubStageServiceGetHistoryAfter(dependencyMaterial, 1, stages(2));
    // update first time & should mark cache as updated
    updater.updateMaterial(dependencyMaterial);
    Stage stage = stage(3);
    ReflectionUtil.setField(stage, "result", StageResult.Passed);
    // update subsequently should hit database
    updater.updateMaterial(dependencyMaterial);
    Mockito.verify(dependencyMaterialSourceDao, times(2)).getPassedStagesAfter(any(String.class), any(DependencyMaterial.class), any(Pagination.class));
    Mockito.verify(dependencyMaterialSourceDao, times(2)).getPassedStagesByName(any(DependencyMaterial.class), any(Pagination.class));
}
Also used : Pagination(com.thoughtworks.go.server.util.Pagination) Stage(com.thoughtworks.go.domain.Stage) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 34 with DependencyMaterial

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

the class MaterialDatabaseDependencyUpdaterTest method shouldInsertAllHistoricRunsOfUpstreamStageTheFirstTime.

@Test
public void shouldInsertAllHistoricRunsOfUpstreamStageTheFirstTime() throws Exception {
    DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("pipeline-name"), new CaseInsensitiveString("stage-name"));
    stubStageServiceGetHistory(null, stages(9, 10, 11), stages(12, 13));
    updater.updateMaterial(dependencyMaterial);
    for (Integer revision : new int[] { 9, 10, 11, 12, 13 }) {
        String stageLocator = String.format("pipeline-name/%s/stage-name/0", revision);
        Modification modification = materialRepository.findModificationWithRevision(dependencyMaterial, stageLocator);
        assertThat(modification.getRevision(), is(stageLocator));
        assertThat(modification.getPipelineLabel(), is(String.format("LABEL-%s", revision)));
    }
}
Also used : Modification(com.thoughtworks.go.domain.materials.Modification) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) Test(org.junit.Test)

Example 35 with DependencyMaterial

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

the class MaterialRepositoryIntegrationTest method shouldPersistActualFromRevisionForSameRevisionOfDependencyMaterialModifications.

@Test
public void shouldPersistActualFromRevisionForSameRevisionOfDependencyMaterialModifications() throws Exception {
    Material material = new DependencyMaterial(new CaseInsensitiveString("pipeline_name"), new CaseInsensitiveString("stage_name"));
    Modification actualFrom = modification("pipeline_name/8/stage_name/2");
    MaterialRevision firstRevision = new MaterialRevision(material, new Modifications(actualFrom));
    saveMaterialRev(firstRevision);
    Pipeline firstPipeline = createPipeline();
    savePMR(firstRevision, firstPipeline);
    firstPipeline = createPipeline();
    savePMR(firstRevision, firstPipeline);
    List<PipelineMaterialRevision> pmrs = repo.findPipelineMaterialRevisions(firstPipeline.getId());
    assertThat(pmrs.get(0).getActualFromRevisionId(), is(actualFrom.getId()));
    assertEquals(actualFrom, pmrs.get(0).getFromModification());
}
Also used : PackageMaterial(com.thoughtworks.go.config.materials.PackageMaterial) GitMaterial(com.thoughtworks.go.config.materials.git.GitMaterial) SvnMaterial(com.thoughtworks.go.config.materials.svn.SvnMaterial) PluggableSCMMaterial(com.thoughtworks.go.config.materials.PluggableSCMMaterial) HgMaterial(com.thoughtworks.go.config.materials.mercurial.HgMaterial) ScmMaterial(com.thoughtworks.go.config.materials.ScmMaterial) P4Material(com.thoughtworks.go.config.materials.perforce.P4Material) DependencyMaterial(com.thoughtworks.go.config.materials.dependency.DependencyMaterial) 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