use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class AgentUpdateValidatorTest method setUp.
@BeforeEach
void setUp() {
result = new HttpOperationResult();
goConfigService = mock(GoConfigService.class);
agentInstance = mock(AgentInstance.class);
BasicCruiseConfig cruiseConfig = GoConfigMother.defaultCruiseConfig();
when(goConfigService.getEnvironments()).thenReturn(cruiseConfig.getEnvironments());
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceTest method findPipelineInstanceShouldChangeResultTo404WhenPipelineNotFound.
@Test
void findPipelineInstanceShouldChangeResultTo404WhenPipelineNotFound() {
ensureConfigHasPipeline("pipeline");
ensureHasPermission(Username.ANONYMOUS, "pipeline");
when(pipelineDao.findPipelineHistoryByNameAndCounter("pipeline", 1)).thenReturn(null);
HttpOperationResult operationResult = new HttpOperationResult();
PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance("pipeline", 1, Username.ANONYMOUS, operationResult);
assertThat(pipelineInstance).isNull();
assertThat(operationResult.httpCode()).isEqualTo(404);
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceTest method shouldPopulateResultAsNotFound_getPipelineStatus.
@Test
void shouldPopulateResultAsNotFound_getPipelineStatus() {
CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
when(cruiseConfig.getPipelineConfigByName(new CaseInsensitiveString("pipeline-name"))).thenReturn(null);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
HttpOperationResult result = new HttpOperationResult();
PipelineStatusModel pipelineStatus = pipelineHistoryService.getPipelineStatus("pipeline-name", "user-name", result);
assertThat(pipelineStatus).isNull();
assertThat(result.httpCode()).isEqualTo(404);
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceTest method shouldPopulateResultAsNotFoundWhenPipelineNotFound_loadMinimalData.
@Test
void shouldPopulateResultAsNotFoundWhenPipelineNotFound_loadMinimalData() {
String pipelineName = "unknown-pipeline";
CruiseConfig cruiseConfig = mock(BasicCruiseConfig.class);
when(cruiseConfig.hasPipelineNamed(new CaseInsensitiveString(pipelineName))).thenReturn(false);
when(goConfigService.currentCruiseConfig()).thenReturn(cruiseConfig);
HttpOperationResult result = new HttpOperationResult();
PipelineInstanceModels pipelineInstanceModels = pipelineHistoryService.loadMinimalData(pipelineName, Pagination.pageFor(0, 0, 10), new Username(new CaseInsensitiveString("looser")), result);
assertThat(pipelineInstanceModels).isNull();
assertThat(result.httpCode()).isEqualTo(404);
assertThat(result.detailedMessage()).isEqualTo("Not Found { Pipeline " + pipelineName + " not found }\n");
}
use of com.thoughtworks.go.server.service.result.HttpOperationResult in project gocd by gocd.
the class PipelineHistoryServiceTest method findPipelineInstanceUsingIdShouldPopulateAppendEmptyStagesFromConfig.
@Test
void findPipelineInstanceUsingIdShouldPopulateAppendEmptyStagesFromConfig() {
ensureConfigHasPipeline("pipeline");
ensureHasPermission(Username.ANONYMOUS, "pipeline");
PipelineInstanceModel instanceModel = PipelineInstanceModel.createEmptyPipelineInstanceModel("pipeline", BuildCause.createNeverRun(), new StageInstanceModels());
when(pipelineDao.loadHistoryByIdWithBuildCause(1L)).thenReturn(instanceModel);
stubConfigServiceToReturnPipeline("pipeline", config);
PipelineInstanceModel pipelineInstance = pipelineHistoryService.findPipelineInstance("pipeline", 1, 1L, Username.ANONYMOUS, new HttpOperationResult());
StageInstanceModels models = pipelineInstance.getStageHistory();
assertThat(models.size()).isEqualTo(2);
}
Aggregations