use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldBeAbleToPassInSpecificRevisionForMaterialsAndScheduleABuild.
@Test
public void shouldBeAbleToPassInSpecificRevisionForMaterialsAndScheduleABuild() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("stage"));
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
pipelineConfig.addMaterialConfig(dependencyMaterial.config());
pipelineConfig.addMaterialConfig(svnMaterial.config());
List<Modification> svnModifications = ModificationsMother.multipleModificationList();
MaterialConfigs knownMaterialConfigs = new MaterialConfigs(pipelineConfig.materialConfigs());
MaterialRevision specificMaterialRevision = new MaterialRevision(dependencyMaterial, new Modification(new Date(), "upstream-pipeline/2/stage/1", "MOCK_LABEL-12", null));
when(specificMaterialRevisionFactory.create(eq("pipeline"), eq(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/2/stage/1")))).thenReturn(new MaterialRevisions(specificMaterialRevision));
when(pipelineScheduleQueue.mostRecentScheduled(new CaseInsensitiveString("pipeline"))).thenReturn(BuildCause.createNeverRun());
when(materialRepository.findLatestModification(svnMaterial)).thenReturn(new MaterialRevisions(new MaterialRevision(svnMaterial, svnModifications)));
when(materialConfigConverter.toMaterials(pipelineConfig.materialConfigs())).thenReturn(new Materials(dependencyMaterial, svnMaterial));
when(materialExpansionService.expandMaterialConfigsForScheduling(pipelineConfig.materialConfigs())).thenReturn(knownMaterialConfigs);
when(materialConfigConverter.toMaterials(knownMaterialConfigs)).thenReturn(new Materials(dependencyMaterial, svnMaterial));
ManualBuild buildType = new ManualBuild(Username.ANONYMOUS);
final HashMap<String, String> stringStringHashMap = new HashMap<>();
buildCauseProducerService.newProduceBuildCause(pipelineConfig, buildType, new ScheduleOptions(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/2/stage/1"), stringStringHashMap, new HashMap<>()), new ServerHealthStateOperationResult(), 12345);
verify(pipelineScheduleQueue).schedule(eq(new CaseInsensitiveString("pipeline")), argThat(containsRevisions(new MaterialRevision(svnMaterial, svnModifications), specificMaterialRevision)));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldCheckForModificationsWhenManuallyScheduling.
@Test
public void shouldCheckForModificationsWhenManuallyScheduling() throws Exception {
HgMaterialConfig hgMaterialConfig = hg("url", null);
HgMaterial hgMaterial = new HgMaterial("url", null);
SvnMaterial svnMaterial = new SvnMaterial("url", null, null, false);
SvnMaterialConfig svnMaterialConfig = svn("url", null, null, false);
pipelineConfig.addMaterialConfig(hgMaterialConfig);
pipelineConfig.addMaterialConfig(svnMaterialConfig);
when(materialConfigConverter.toMaterial(hgMaterialConfig)).thenReturn(hgMaterial);
when(materialConfigConverter.toMaterial(svnMaterialConfig)).thenReturn(svnMaterial);
ServerHealthStateOperationResult result = new ServerHealthStateOperationResult();
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(), result);
assertThat(result.getServerHealthState().isSuccess(), is(true));
verify(mockMaterialUpdateService, times(2)).updateMaterial(any(Material.class));
verify(mockMaterialUpdateStatusNotifier).registerListenerFor(eq(pipelineConfig), any(MaterialUpdateStatusListener.class));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceTest method manualTriggerShouldNotTriggerThePipelineIfMaterialUpdateFailed.
@Test
public void manualTriggerShouldNotTriggerThePipelineIfMaterialUpdateFailed() throws Exception {
HgMaterialConfig hgMaterialConfig = hg("url", null);
HgMaterial hgMaterial = new HgMaterial("url", null);
pipelineConfig.addMaterialConfig(hgMaterialConfig);
when(materialConfigConverter.toMaterial(hgMaterialConfig)).thenReturn(hgMaterial);
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(), new ServerHealthStateOperationResult());
sendMaterialUpdateFailedMessage(extractMaterialListenerInstanceFromRegisterCall(), hgMaterial);
assertThat(triggerMonitor.isAlreadyTriggered(pipelineConfig.name()), is(false));
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldUpdateOnlyOnceIfThereAreTwoMaterialsWithSameFingerPrintButDifferentDest.
@Test
public void shouldUpdateOnlyOnceIfThereAreTwoMaterialsWithSameFingerPrintButDifferentDest() {
HgMaterial material1 = new HgMaterial("url", null);
HgMaterial material2 = new HgMaterial("url", null);
HgMaterialConfig materialConfig1 = hg("url", null);
HgMaterialConfig materialConfig2 = hg("url", null);
material1.setFolder("folder1");
material2.setFolder("folder2");
assertThat(material1.getFingerprint(), is(material2.getFingerprint()));
pipelineConfig.addMaterialConfig(materialConfig1);
pipelineConfig.addMaterialConfig(materialConfig2);
Material[] materials = new Material[] { material1, material2 };
when(materialConfigConverter.toMaterial(materialConfig1)).thenReturn(material1);
when(materialConfigConverter.toMaterial(materialConfig2)).thenReturn(material2);
buildCauseProducerService.manualSchedulePipeline(Username.ANONYMOUS, pipelineConfig.name(), new ScheduleOptions(new HashMap<>(), new HashMap<>(), new HashMap<>()), new ServerHealthStateOperationResult());
verify(mockMaterialUpdateService, times(1)).updateMaterial(any(Material.class));
MaterialUpdateStatusListener statusListener = extractMaterialListenerInstanceFromRegisterCall();
statusListener.onMaterialUpdate(new MaterialUpdateFailedMessage(materials[0], 0, new Exception("Cannot connect to repo")));
verify(mockMaterialUpdateStatusNotifier).removeListenerFor(pipelineConfig);
}
use of com.thoughtworks.go.server.service.result.ServerHealthStateOperationResult in project gocd by gocd.
the class ArtifactsDiskSpaceFullCheckerTest method shouldSendEmailAgainIfProblemOccuresAgain.
@Test
public void shouldSendEmailAgainIfProblemOccuresAgain() throws Exception {
when(goConfigService.adminEmail()).thenReturn("admin@tw.com");
full.onSetUp();
// should send email this time
checker.check(new ServerHealthStateOperationResult());
full.onTearDown();
// should not send email
checker.check(new ServerHealthStateOperationResult());
full.onSetUp();
// should send email again
checker.check(new ServerHealthStateOperationResult());
verify(emailSender, times(2)).sendEmail(any(SendEmailMessage.class));
}
Aggregations