Search in sources :

Example 6 with ServerHealthStates

use of com.thoughtworks.go.serverhealth.ServerHealthStates in project gocd by gocd.

the class SCMMaterialSourceTest method shouldReloadSchedulableMaterialsOnPipelineConfigChange.

@Test
public void shouldReloadSchedulableMaterialsOnPipelineConfigChange() {
    Set<MaterialConfig> schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config()));
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
    when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial)));
    Set<Material> materials = source.materialsForUpdate();
    assertThat(materials.size(), is(1));
    assertTrue(materials.contains(svnMaterial));
    schedulableMaterialConfigs = new HashSet<>(Arrays.asList(svnMaterial.config(), gitMaterial.config()));
    when(goConfigService.getSchedulableSCMMaterials()).thenReturn(schedulableMaterialConfigs);
    when(goConfigService.getCurrentConfig()).thenReturn(mock(CruiseConfig.class));
    when(materialConfigConverter.toMaterials(schedulableMaterialConfigs)).thenReturn(new HashSet<>(Arrays.asList(svnMaterial, gitMaterial)));
    when(serverHealthService.getAllLogs()).thenReturn(new ServerHealthStates());
    source.pipelineConfigChangedListener().onEntityConfigChange(mock(PipelineConfig.class));
    materials = source.materialsForUpdate();
    assertThat(materials.size(), is(2));
    assertTrue(materials.contains(svnMaterial));
    assertTrue(materials.contains(gitMaterial));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) MaterialConfig(com.thoughtworks.go.domain.materials.MaterialConfig) ServerHealthStates(com.thoughtworks.go.serverhealth.ServerHealthStates) Material(com.thoughtworks.go.domain.materials.Material) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

ServerHealthStates (com.thoughtworks.go.serverhealth.ServerHealthStates)6 ServerHealthService (com.thoughtworks.go.serverhealth.ServerHealthService)3 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)2 Pipeline (com.thoughtworks.go.domain.Pipeline)2 Stage (com.thoughtworks.go.domain.Stage)2 JobStatusCache (com.thoughtworks.go.domain.activity.JobStatusCache)2 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)2 Material (com.thoughtworks.go.domain.materials.Material)2 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)2 JobInstanceDao (com.thoughtworks.go.server.dao.JobInstanceDao)2 PipelineDao (com.thoughtworks.go.server.dao.PipelineDao)2 StageDao (com.thoughtworks.go.server.dao.StageDao)2 JobResultTopic (com.thoughtworks.go.server.messaging.JobResultTopic)2 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)2 HashSet (java.util.HashSet)2 Test (org.junit.Test)2 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)1 ServerHealthState (com.thoughtworks.go.serverhealth.ServerHealthState)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1