Skip to content

Commit

Permalink
fix server tests
Browse files Browse the repository at this point in the history
  • Loading branch information
krusche committed Oct 12, 2024
1 parent ae3d541 commit caddaec
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3303,8 +3303,7 @@ private Course createCourseWithCourseImageAndReturn() throws Exception {
course = objectMapper.readValue(result.getResponse().getContentAsString(), Course.class);

assertThat(course.getCourseIcon()).as("Course icon got stored").isNotNull();
var imgResult = request.performMvcRequest(get(course.getCourseIcon())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM))
.andReturn();
var imgResult = request.performMvcRequest(get(course.getCourseIcon())).andExpect(status().isOk()).andExpect(content().contentType(MediaType.IMAGE_PNG)).andReturn();
assertThat(imgResult.getResponse().getContentAsByteArray()).isNotEmpty();

var createdCourse = courseRepo.findByIdElseThrow(course.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ private void checkCreatedFiles(QuizExercise quizExercise) throws Exception {
}

private void checkCreatedFile(String path) throws Exception {
MvcResult result = request.performMvcRequest(get(path)).andExpect(status().isOk()).andExpect(content().contentType(MediaType.APPLICATION_OCTET_STREAM)).andReturn();
MediaType mediaType = path.endsWith(".png") ? MediaType.IMAGE_PNG : MediaType.IMAGE_JPEG;
MvcResult result = request.performMvcRequest(get(path)).andExpect(status().isOk()).andExpect(content().contentType(mediaType)).andReturn();
byte[] image = result.getResponse().getContentAsByteArray();
assertThat(image).isNotEmpty();
}
Expand Down

0 comments on commit caddaec

Please sign in to comment.