From caddaec416e83a7ebb5e61e4c24fb6da71557dec Mon Sep 17 00:00:00 2001 From: Stephan Krusche Date: Sat, 12 Oct 2024 22:17:44 +0200 Subject: [PATCH] fix server tests --- .../de/tum/cit/aet/artemis/core/util/CourseTestService.java | 3 +-- .../tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java index 3b8ce269954b..c80195c2b8aa 100644 --- a/src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java +++ b/src/test/java/de/tum/cit/aet/artemis/core/util/CourseTestService.java @@ -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()); diff --git a/src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java index b11c688358fa..e787ee1533a0 100644 --- a/src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java +++ b/src/test/java/de/tum/cit/aet/artemis/quiz/QuizExerciseIntegrationTest.java @@ -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(); }