use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class DiskSpaceWarningCheckerTest method shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl.
@Test
public void shouldFormatLowDiskSpaceWarningMailWithHelpLinksHttpAndSiteUrl() throws URISyntaxException {
String expectedHelpUrl = docsUrl("/installation/configuring_server_details.html");
GoConfigService goConfigService = mockGoConfigServiceToHaveSiteUrl();
SystemDiskSpaceChecker checker = mock(SystemDiskSpaceChecker.class);
when(checker.getUsableSpace(any(File.class))).thenReturn(1000000L);
ArtifactsDiskSpaceWarningChecker diskSpaceWarningChecker = new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), null, goConfigService, checker, serverHealthService) {
@Override
protected String targetFolderCanonicalPath() {
return ".";
}
};
SendEmailMessage actual = diskSpaceWarningChecker.createEmail();
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
diskSpaceWarningChecker.check(result);
assertThat(actual.getBody(), Matchers.containsString(expectedHelpUrl));
assertThat(result.getServerHealthState().isSuccess(), is(true));
assertThat(result.getServerHealthState().getMessage(), is("GoCD Server's artifact repository is running low on disk space"));
assertThat(result.getServerHealthState().getType(), is(HealthStateType.artifactsDiskFull()));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceTest method manualTrigger_shouldUpdateJustPipelineConfigNotMaterialsWhenPipelineIsDefinedInConfigRepoAndMDUFlagIsTurnedOff.
@Test
public void manualTrigger_shouldUpdateJustPipelineConfigNotMaterialsWhenPipelineIsDefinedInConfigRepoAndMDUFlagIsTurnedOff() {
HgMaterial material1 = new HgMaterial("url", null);
HgMaterialConfig materialConfig1 = hg("url", null);
HgMaterialConfig materialConfig2 = hg("url2", null);
pipelineConfig.addMaterialConfig(materialConfig1);
pipelineConfig.setOrigin(new RepoConfigOrigin(ConfigRepoConfig.createConfigRepoConfig(materialConfig2, "plug", "id"), "revision1"));
when(materialConfigConverter.toMaterial(materialConfig2)).thenReturn(new MaterialConfigConverter().toMaterial(materialConfig2));
ScheduleOptions scheduleOptions = new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>());
scheduleOptions.shouldPerformMDUBeforeScheduling(false);
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), scheduleOptions, new ServerHealthStateOperationResult());
verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
statusListener.onMaterialUpdate(new MaterialUpdateSuccessfulMessage(material1, 0));
verify(mockMaterialUpdateStatusNotifier).registerListenerFor(eq(pipelineConfig), any(MaterialUpdateStatusListener.class));
verify(goConfigService, times(1)).pipelineConfigNamed(pipelineConfig.name());
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class CompositeCheckerTest method shouldReturnSuccessWhenAllTheCheckersReturnSuccess.
@Test
public void shouldReturnSuccessWhenAllTheCheckersReturnSuccess() {
CompositeChecker checker = new CompositeChecker(successful(), successful());
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
checker.check(result);
assertThat(result.getServerHealthState(), is(SUCCESS_SERVER_HEALTH_STATE));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class CompositeCheckerTest method shouldReturnTheFirstError.
@Test
public void shouldReturnTheFirstError() {
CompositeChecker checker = new CompositeChecker(StubCheckerFactory.error(), StubCheckerFactory.anotherError());
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
checker.check(result);
assertThat(result.getServerHealthState(), is(ERROR_SERVER_HEALTH_STATE));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class DiskSpaceWarningCheckerTest method shouldReturnSuccessWhenTheArtifactsFolderIsNotPresent.
@Test
public void shouldReturnSuccessWhenTheArtifactsFolderIsNotPresent() {
final GoConfigService service = mock(GoConfigService.class);
when(service.artifactsDir()).thenReturn(new File("/pavan"));
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
new ArtifactsDiskSpaceWarningChecker(new SystemEnvironment(), sender, service, new SystemDiskSpaceChecker(), serverHealthService).check(result);
assertThat(result.getServerHealthState().isSuccess(), is(true));
}
Aggregations