Search in sources :

Example 41 with HttpOperationResult

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());
}
Also used : AgentInstance(com.thoughtworks.go.domain.AgentInstance) HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) BasicCruiseConfig(com.thoughtworks.go.config.BasicCruiseConfig) GoConfigService(com.thoughtworks.go.server.service.GoConfigService) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 42 with HttpOperationResult

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);
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.jupiter.api.Test)

Example 43 with HttpOperationResult

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);
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineStatusModel(com.thoughtworks.go.presentation.PipelineStatusModel) Test(org.junit.jupiter.api.Test)

Example 44 with HttpOperationResult

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");
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) PipelineInstanceModels.createPipelineInstanceModels(com.thoughtworks.go.presentation.pipelinehistory.PipelineInstanceModels.createPipelineInstanceModels) Username(com.thoughtworks.go.server.domain.Username) Test(org.junit.jupiter.api.Test)

Example 45 with HttpOperationResult

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);
}
Also used : HttpOperationResult(com.thoughtworks.go.server.service.result.HttpOperationResult) Test(org.junit.jupiter.api.Test)

Aggregations

HttpOperationResult (com.thoughtworks.go.server.service.result.HttpOperationResult)146 Test (org.junit.jupiter.api.Test)64 Test (org.junit.Test)53 Username (com.thoughtworks.go.server.domain.Username)34 CaseInsensitiveString (com.thoughtworks.go.config.CaseInsensitiveString)23 TriStateSelection (com.thoughtworks.go.presentation.TriStateSelection)12 Pagination (com.thoughtworks.go.server.util.Pagination)7 SvnMaterial (com.thoughtworks.go.config.materials.svn.SvnMaterial)6 StageStatusCache (com.thoughtworks.go.domain.activity.StageStatusCache)6 MaterialConfig (com.thoughtworks.go.domain.materials.MaterialConfig)6 StageStatusTopic (com.thoughtworks.go.server.messaging.StageStatusTopic)6 GitMaterialConfig (com.thoughtworks.go.config.materials.git.GitMaterialConfig)5 AgentInstance (com.thoughtworks.go.domain.AgentInstance)5 BeforeEach (org.junit.jupiter.api.BeforeEach)5 PipelineConfig (com.thoughtworks.go.config.PipelineConfig)4 MaterialConfigs (com.thoughtworks.go.config.materials.MaterialConfigs)4 NullStage (com.thoughtworks.go.domain.NullStage)4 BuildCause (com.thoughtworks.go.domain.buildcause.BuildCause)4 PipelineStatusModel (com.thoughtworks.go.presentation.PipelineStatusModel)4 Stage (com.thoughtworks.go.domain.Stage)3