use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelinePauseServiceTest method shouldPopulateHttpResult401WhenPipelineIsNotAuthorizedForUnPausing.
@Test
public void shouldPopulateHttpResult401WhenPipelineIsNotAuthorizedForUnPausing() throws Exception {
setUpValidPipelineWithInvalidAuth();
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
pipelinePauseService.unpause(VALID_PIPELINE, INVALID_USER, result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(SC_UNAUTHORIZED));
verify(pipelineDao, never()).unpause(VALID_PIPELINE);
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelinePauseServiceTest method shouldPausePipelineWithCaptialName.
@Test
public void shouldPausePipelineWithCaptialName() throws Exception {
setUpValidPipelineWithAuth();
when(pipelineDao.pauseState(PIPELINE_WITH_CAPITAL_NAME)).thenReturn(new PipelinePauseInfo(false, "", VALID_USER.getUsername().toString()));
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
pipelinePauseService.pause(PIPELINE_WITH_CAPITAL_NAME, "cause", VALID_USER, result);
verify(pipelineDao).pause(PIPELINE_WITH_CAPITAL_NAME, "cause", VALID_USER.getUsername().toString());
assertThat(result.isSuccessful(), is(true));
assertThat(result.httpCode(), is(SC_OK));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelinePauseServiceTest method shouldPopulateHttpResult500WhenPipelinePauseResultsInAnError.
@Test
public void shouldPopulateHttpResult500WhenPipelinePauseResultsInAnError() throws Exception {
setUpValidPipelineWithAuth();
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
doThrow(new RuntimeException("Failed to pause")).when(pipelineDao).pause(VALID_PIPELINE, "cause", VALID_USER.getUsername().toString());
pipelinePauseService.pause(VALID_PIPELINE, "cause", VALID_USER, result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(SC_INTERNAL_SERVER_ERROR));
verify(pipelineDao).pause(VALID_PIPELINE, "cause", VALID_USER.getUsername().toString());
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelinePauseServiceTest method shouldNotPausePipelineWhenPipelineIsAlreadyPaused.
@Test
public void shouldNotPausePipelineWhenPipelineIsAlreadyPaused() throws Exception {
setUpValidPipelineWithAuth();
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(pipelineDao.pauseState(VALID_PIPELINE)).thenReturn(new PipelinePauseInfo(true, "", VALID_USER.getUsername().toString()));
pipelinePauseService.pause(VALID_PIPELINE, null, VALID_USER, result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(409));
}
use of com.thoughtworks.go.server.service.result.HttpLocalizedOperationResult in project gocd by gocd.
the class PipelinePauseServiceTest method shouldPopulateHttpResult404WhenPipelineIsNotFoundForUnpause.
@Test
public void shouldPopulateHttpResult404WhenPipelineIsNotFoundForUnpause() throws Exception {
HttpLocalizedOperationResult result = new HttpLocalizedOperationResult();
when(goConfigDao.load()).thenReturn(new BasicCruiseConfig());
pipelinePauseService.unpause(INVALID_PIPELINE, VALID_USER, result);
assertThat(result.isSuccessful(), is(false));
assertThat(result.httpCode(), is(SC_NOT_FOUND));
verify(pipelineDao, never()).unpause(INVALID_PIPELINE);
}
Aggregations