use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class ArtifactsControllerTest method shouldReturnHttpErrorCodeWhenChecksumFileSaveFails.
@Test
public void shouldReturnHttpErrorCodeWhenChecksumFileSaveFails() throws Exception {
File artifactFile = new File("junk");
when(artifactService.findArtifact(any(JobIdentifier.class), eq("some-path"))).thenReturn(artifactFile);
when(artifactService.saveFile(any(File.class), any(InputStream.class), eq(false), eq(1))).thenReturn(true);
when(artifactService.saveOrAppendFile(any(File.class), any(InputStream.class))).thenReturn(false);
MockMultipartHttpServletRequest mockMultipartHttpServletRequest = new MockMultipartHttpServletRequest();
mockMultipartHttpServletRequest.addFile(new MockMultipartFile(REGULAR_MULTIPART_FILENAME, "content".getBytes()));
mockMultipartHttpServletRequest.addFile(new MockMultipartFile(CHECKSUM_MULTIPART_FILENAME, "checksum-content".getBytes()));
ModelAndView modelAndView = artifactsController.postArtifact("pipeline-1", "1", "stage-1", "2", "job-1", 122L, "some-path", 1, mockMultipartHttpServletRequest);
ResponseCodeView view = (ResponseCodeView) modelAndView.getView();
assertThat(view.getStatusCode(), is(SC_INTERNAL_SERVER_ERROR));
assertThat(view.getContent(), is("Error saving checksum file for the artifact at path 'some-path'"));
}
use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class StageControllerIntegrationTest method shouldGiveFriendlyErrorMessageForRerun.
@Test
public void shouldGiveFriendlyErrorMessageForRerun() {
ModelAndView modelAndView = controller.rerunStage("pipeline", "invalid-label", "stage", response, request);
ResponseCodeView codeView = (ResponseCodeView) modelAndView.getView();
assertThat(codeView.getStatusCode(), is(HttpServletResponse.SC_BAD_REQUEST));
assertThat(codeView.getContent(), is("Stage [pipeline/invalid-label/stage] not found"));
}
use of com.thoughtworks.go.server.web.ResponseCodeView in project gocd by gocd.
the class ArtifactsControllerIntegrationTest method testConsoleOutShouldReturn404WhenJobIsNotFound.
@Test
public void testConsoleOutShouldReturn404WhenJobIsNotFound() throws Exception {
prepareConsoleOut("");
Stage firstStage = pipeline.getFirstStage();
long startLineNumber = 0L;
ModelAndView view = artifactsController.consoleout("snafu", "snafu", "snafu", "build", String.valueOf(firstStage.getCounter()), startLineNumber);
assertThat(view.getView().getContentType(), is(RESPONSE_CHARSET));
assertThat(view.getView(), is(instanceOf((ResponseCodeView.class))));
assertThat(((ResponseCodeView) view.getView()).getContent(), containsString("Job snafu/snafu/snafu/1/build not found."));
}
Aggregations