Search in sources :

Example 1 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class EmailNotificationListenerTest method shouldNotCreateMailSenderIfMailHostIsNotConfigured.

@Test
public void shouldNotCreateMailSenderIfMailHostIsNotConfigured() {
    context.checking(new Expectations() {

        {
            allowing(goConfigService).currentCruiseConfig();
            will(returnValue(new BasicCruiseConfig()));
        }
    });
    emailNotificationListener.onMessage(null);
}
Also used : Expectations(org.jmock.Expectations) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 2 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class UnrunStagesPopulatorTest method shouldAddRemainingStagesToAllDownstreamPipelines.

@Test
public void shouldAddRemainingStagesToAllDownstreamPipelines() throws Exception {
    /*
            p --> p1 --> p2
             \
              +-> p3
         */
    ValueStreamMap valueStreamMap = new ValueStreamMap("p", revision("p", 1));
    Node p1_node = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p1", "p1"), "p");
    Node p2_node = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p2", "p2"), "p1");
    Node p3_node = valueStreamMap.addDownstreamNode(new PipelineDependencyNode("p3", "p3"), "p");
    addRevisions(p1_node);
    addRevisions(p2_node);
    addRevisions(p3_node);
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    String grp = "first";
    cruiseConfig.addPipeline(grp, pipelineConfig("p"));
    cruiseConfig.addPipeline(grp, pipelineConfig("p1"));
    cruiseConfig.addPipeline(grp, pipelineConfig("p2"));
    cruiseConfig.addPipeline(grp, pipelineConfig("p3"));
    when(goConfigService.getCurrentConfig()).thenReturn(cruiseConfig);
    unrunStagesPopulator.apply(valueStreamMap);
    assertRevision(valueStreamMap.getCurrentPipeline().revisions().get(0));
    assertStages(p1_node);
    assertStages(p2_node);
    assertStages(p3_node);
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CaseInsensitiveString(com.thoughtworks.go.config.CaseInsensitiveString) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 3 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class TimerSchedulerQuartzIntegrationTest method shouldUpdateJobsInTheQuartzSchedulerOnConfigChange.

@Test
public void shouldUpdateJobsInTheQuartzSchedulerOnConfigChange() throws InterruptedException {
    PipelineConfig uat = pipelineConfigWithTimer("uat", "* * * * * ?");
    PipelineConfig dist = pipelineConfigWithTimer("dist", "* * * * * ?");
    List<PipelineConfig> pipelineConfigs = asList(uat, dist);
    GoConfigService goConfigService = mock(GoConfigService.class);
    when(goConfigService.getAllPipelineConfigs()).thenReturn(pipelineConfigs);
    BuildCauseProducerService buildCauseProducerService = mock(BuildCauseProducerService.class);
    TimerScheduler timerScheduler = new TimerScheduler(quartzSchedulerFactory, goConfigService, buildCauseProducerService, null);
    timerScheduler.initialize();
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.getGroups().add(new BasicPipelineConfigs(uat));
    timerScheduler.onConfigChange(cruiseConfig);
    pauseForScheduling();
    verify(buildCauseProducerService, atLeastOnce()).timerSchedulePipeline(eq(uat), any(ServerHealthStateOperationResult.class));
}
Also used : PipelineConfig(com.thoughtworks.go.config.PipelineConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) ServerHealthStateOperationResult(com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult) BuildCauseProducerService(com.thoughtworks.go.server.scheduling.BuildCauseProducerService) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Example 4 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class UpdatePipelineConfigCommandTest method shouldDisallowStaleRequest.

@Test
public void shouldDisallowStaleRequest() {
    UpdatePipelineConfigCommand command = new UpdatePipelineConfigCommand(goConfigService, entityHashingService, pipelineConfig, username, "stale_md5", localizedOperationResult);
    when(goConfigService.findGroupNameByPipeline(pipelineConfig.name())).thenReturn("group1");
    when(goConfigService.canEditPipeline(pipelineConfig.name().toString(), username, localizedOperationResult, "group1")).thenReturn(true);
    when(entityHashingService.md5ForEntity(pipelineConfig)).thenReturn("latest_md5");
    BasicCruiseConfig basicCruiseConfig = new BasicCruiseConfig(new BasicPipelineConfigs(pipelineConfig));
    assertFalse(command.canContinue(basicCruiseConfig));
}
Also used : BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) BasicPipelineConfigs(com.thoughtworks.go.config.BasicPipelineConfigs) Test(org.junit.Test)

Example 5 with BasicCruiseConfig

use of com.thoughtworks.go.config.BasicCruiseConfig in project gocd by gocd.

the class ArtifactDirValidatorTest method shouldThrowExceptionWhenUserProvidesEmtpty.

@Test
public void shouldThrowExceptionWhenUserProvidesEmtpty() {
    CruiseConfig cruiseConfig = new BasicCruiseConfig();
    cruiseConfig.setServerConfig(new ServerConfig("", null));
    ArtifactDirValidator dirValidator = new ArtifactDirValidator();
    try {
        dirValidator.validate(cruiseConfig);
        fail("should throw exception");
    } catch (Exception e) {
    }
}
Also used : ServerConfig(com.thoughtworks.go.config.ServerConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) CruiseConfig(com.thoughtworks.go.config.CruiseConfig) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) Test(org.junit.Test)

Aggregations

BasicCruiseConfig (com.thoughtworks.go.config.BasicCruiseConfig)31 Test (org.junit.Test)28 CruiseConfig (com.thoughtworks.go.config.CruiseConfig)18 ServerConfig (com.thoughtworks.go.config.ServerConfig)10 BasicPipelineConfigs (com.thoughtworks.go.config.BasicPipelineConfigs)4 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)4 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 ServerSiteUrlConfig (com.thoughtworks.go.domain.ServerSiteUrlConfig)4 SystemEnvironment (com.thoughtworks.go.util.SystemEnvironment)4 ConfigSaveValidationContext (com.thoughtworks.go.config.ConfigSaveValidationContext)3 SecurityConfig (com.thoughtworks.go.config.SecurityConfig)3 ValidationError (com.thoughtworks.go.plugin.api.response.validation.ValidationError)3 ValidationResult (com.thoughtworks.go.plugin.api.response.validation.ValidationResult)3 GoConfigService (com.thoughtworks.go.server.service.GoConfigService)3 HttpLocalizedOperationResult (com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult)3 PluginRoleConfig (com.thoughtworks.go.config.PluginRoleConfig)2 SecurityAuthConfig (com.thoughtworks.go.config.SecurityAuthConfig)2 ElasticProfile (com.thoughtworks.go.config.elastic.ElasticProfile)2 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)2 ConfigurationKey (com.thoughtworks.go.domain.config.ConfigurationKey)2