use of com.thoughtworks.go.server.service.ManualBuild in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldHandleCaseWhereSpecifiedRevisionDoesNotExist.
@Test
public void shouldHandleCaseWhereSpecifiedRevisionDoesNotExist() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("stage"));
when(specificMaterialRevisionFactory.create(eq("pipeline"), eq(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/200/stage/1")))).thenThrow(new RuntimeException("Invalid specified revision"));
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/200/stage/1"), stringStringHashMap, new HashMap<>()), new ServerHealthStateOperationResult(), 12345);
verify(mockServerHealthService).update(argThat(hasErrorHealthState("Error while scheduling pipeline: pipeline", "Invalid specified revision")));
}
use of com.thoughtworks.go.server.service.ManualBuild in project gocd by gocd.
the class BuildCauseProducerServiceTest method shouldHandleCaseWhenExceptionWithoutMessageIsRaised.
@Test
public void shouldHandleCaseWhenExceptionWithoutMessageIsRaised() throws Exception {
DependencyMaterial dependencyMaterial = new DependencyMaterial(new CaseInsensitiveString("upstream-pipeline"), new CaseInsensitiveString("stage"));
when(specificMaterialRevisionFactory.create(eq("pipeline"), eq(Collections.singletonMap(dependencyMaterial.getPipelineUniqueFingerprint(), "upstream-pipeline/200/stage/1")))).thenThrow(new NullPointerException());
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/200/stage/1"), stringStringHashMap, new HashMap<>()), new ServerHealthStateOperationResult(), 12345);
verify(mockServerHealthService).update(argThat(hasErrorHealthState("Error while scheduling pipeline: pipeline", "Details not available, please check server logs.")));
}
use of com.thoughtworks.go.server.service.ManualBuild 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("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("pipeline"), argThat(containsRevisions(new MaterialRevision(svnMaterial, svnModifications), specificMaterialRevision)));
}
Aggregations