use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class GoDashboardTemplateConfigChangeHandlerTest method shouldRefreshAllPipelinesAssociatedWithATemplateInCacheWhenATemplateChanges.
@Test
public void shouldRefreshAllPipelinesAssociatedWithATemplateInCacheWhenATemplateChanges() throws Exception {
CruiseConfig cruiseConfig = mock(CruiseConfig.class);
PipelineTemplateConfig templateConfig = new PipelineTemplateConfig(new CaseInsensitiveString("template1"));
CaseInsensitiveString pipeline1 = new CaseInsensitiveString("p1");
CaseInsensitiveString pipeline2 = new CaseInsensitiveString("p2");
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(cruiseConfig.pipelinesAssociatedWithTemplate(templateConfig.name())).thenReturn(a(pipeline1, pipeline2));
handler.call(templateConfig);
verify(cacheUpdateService).updateCacheForPipeline(pipeline1);
verify(cacheUpdateService).updateCacheForPipeline(pipeline2);
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class ArtifactsDiskSpaceFullCheckerTest method configWithSiteUrl.
private static CruiseConfig configWithSiteUrl() {
ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://test.host"), new ServerSiteUrlConfig("https://test.host"));
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(serverConfig);
return cruiseConfig;
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class EmailNotificationListenerTest method shouldCreateMailSenderIfMailHostIsConfigured.
@Test
public void shouldCreateMailSenderIfMailHostIsConfigured() {
final MailHost mailHost = new MailHost("hostName", 1234, "user", "pass", true, true, "from", "admin@local.com");
final CruiseConfig config = GoConfigMother.cruiseConfigWithMailHost(mailHost);
context.checking(new Expectations() {
{
allowing(goConfigService).currentCruiseConfig();
will(returnValue(config));
one(goMailSenderFactory).createSender();
will(returnValue(GoSmtpMailSender.createSender(mailHost)));
}
});
emailNotificationListener.onMessage(new SendEmailMessage("subject", "body", "to"));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldSendEmailsAgainIfDiskSpaceIsFixedAndFallsBelowAgain.
@Test
public void shouldSendEmailsAgainIfDiskSpaceIsFixedAndFallsBelowAgain() {
CruiseConfig cruiseConfig = simulateFullDisk();
ArtifactsDiskSpaceFullChecker fullChecker = createChecker(cruiseConfig);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(false));
simulateEmptyDisk();
result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(true));
simulateFullDisk();
result = new ServerHealthStateOperationResult();
fullChecker.check(result);
assertThat(result.canContinue(), is(false));
verify(sender, times(2)).sendEmail(any(SendEmailMessage.class));
}
use of com.thoughtworks.go.config.CruiseConfig in project gocd by gocd.
the class DiskSpaceFullCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.
@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
String expectedHelpUrl = "https://docs.gocd.org/current/installation/configuring_server_details.html";
ServerConfig serverConfig = new ServerConfig(null, null, new ServerSiteUrlConfig("http://test.host"), new ServerSiteUrlConfig("https://test.host"));
CruiseConfig cruiseConfig = new BasicCruiseConfig();
cruiseConfig.setServerConfig(serverConfig);
GoConfigService goConfigService = mock(GoConfigService.class);
when(goConfigService.artifactsDir()).thenReturn(null);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
when(goConfigService.adminEmail()).thenReturn("admin@email.com");
ArtifactsDiskSpaceFullChecker diskSpaceFullChecker = new ArtifactsDiskSpaceFullChecker(new SystemEnvironment(), null, goConfigService, null) {
@Override
protected String targetFolderCanonicalPath() {
return "";
}
};
SendEmailMessage actual = diskSpaceFullChecker.createEmail();
assertThat(actual.getBody(), Matchers.containsString(expectedHelpUrl));
}
Aggregations