From 770ee2f99d5c83b12166eb6a27aa8207df7ed5ed Mon Sep 17 00:00:00 2001 From: PaulBredl Date: Fri, 28 Jun 2024 13:49:56 +0200 Subject: [PATCH] fix further tests --- .../course_service/api/AuthorizationTest.java | 16 ++++++++-------- .../api/MutationCreateCourseTest.java | 11 +++++++---- .../api/MutationJoinCourseTest.java | 3 ++- .../api/MutationLeaveCourseTest.java | 3 ++- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/AuthorizationTest.java b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/AuthorizationTest.java index 4b495d2..57866eb 100644 --- a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/AuthorizationTest.java +++ b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/AuthorizationTest.java @@ -39,7 +39,7 @@ public class AuthorizationTest { @Test - void testCreateCourseCourseCreatorOnly(final HttpGraphQlTester tester) { + void testCreateCourseCourseCreatorOnly(WebGraphQlTester tester) { final String query = """ mutation { @@ -80,7 +80,7 @@ public static void assertIsMissingGlobalPermission(final List gra @Test @Transactional - void testUpdateCourseAdminOnly(final HttpGraphQlTester tester) { + void testUpdateCourseAdminOnly(WebGraphQlTester tester) { final String query = """ mutation { @@ -120,7 +120,7 @@ void testUpdateCourseAdminOnly(final HttpGraphQlTester tester) { } @Test - void testDeleteCourseAdminOnly(final HttpGraphQlTester tester) { + void testDeleteCourseAdminOnly(WebGraphQlTester tester) { final String query = """ mutation { @@ -135,7 +135,7 @@ void testDeleteCourseAdminOnly(final HttpGraphQlTester tester) { } @Test - void testCreateChapterAdminOnly(final HttpGraphQlTester tester) { + void testCreateChapterAdminOnly(WebGraphQlTester tester) { final String query = """ mutation { @@ -165,7 +165,7 @@ void testCreateChapterAdminOnly(final HttpGraphQlTester tester) { } @Test - void testUpdateChapterAdminOnly(final HttpGraphQlTester tester) { + void testUpdateChapterAdminOnly(WebGraphQlTester tester) { final ChapterEntity chapterEntity = chapterRepository.save(TestUtils.dummyChapterBuilder().courseId(courseId).build()); @@ -226,7 +226,7 @@ void testDeleteChapterAdminOnly(WebGraphQlTester tester) { @Test - void testCreateMembershipAdminOnly(final HttpGraphQlTester tester) { + void testCreateMembershipAdminOnly(WebGraphQlTester tester) { final CourseMembership expectedDto = CourseMembership.builder() .setUserId(UUID.randomUUID()) @@ -257,7 +257,7 @@ void testCreateMembershipAdminOnly(final HttpGraphQlTester tester) { } @Test - void testUpdateMembershipAdminOnly(final HttpGraphQlTester tester) { + void testUpdateMembershipAdminOnly(WebGraphQlTester tester) { final CourseMembership expectedDto = CourseMembership.builder() .setUserId(currentUser.getId()) @@ -288,7 +288,7 @@ void testUpdateMembershipAdminOnly(final HttpGraphQlTester tester) { } @Test - void testDeleteMembershipAdminOnly(final HttpGraphQlTester tester) { + void testDeleteMembershipAdminOnly(WebGraphQlTester tester) { final CourseMembership expectedDto = CourseMembership.builder() .setUserId(currentUser.getId()) diff --git a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationCreateCourseTest.java b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationCreateCourseTest.java index cd4bfc4..f5bd23d 100644 --- a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationCreateCourseTest.java +++ b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationCreateCourseTest.java @@ -1,6 +1,8 @@ package de.unistuttgart.iste.meitrex.course_service.api; -import de.unistuttgart.iste.meitrex.common.testutil.*; +import de.unistuttgart.iste.meitrex.common.testutil.GraphQlApiTest; +import de.unistuttgart.iste.meitrex.common.testutil.InjectCurrentUserHeader; +import de.unistuttgart.iste.meitrex.common.testutil.MockTestPublisherConfiguration; import de.unistuttgart.iste.meitrex.common.user_handling.LoggedInUser; import de.unistuttgart.iste.meitrex.course_service.persistence.repository.ChapterRepository; import de.unistuttgart.iste.meitrex.course_service.persistence.repository.CourseRepository; @@ -9,6 +11,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.graphql.test.tester.GraphQlTester; +import org.springframework.graphql.test.tester.WebGraphQlTester; import org.springframework.test.context.ContextConfiguration; import java.time.OffsetDateTime; @@ -42,7 +45,7 @@ class MutationCreateCourseTest { * Then the course is created and returned */ @Test - void testCreateCourse(final HttpGraphQlTester tester) { + void testCreateCourse(WebGraphQlTester tester) { final String query = """ mutation { createCourse( @@ -99,7 +102,7 @@ void testCreateCourse(final HttpGraphQlTester tester) { * Then the course is created and returned */ @Test - void testCreateCourseWithTerm(final HttpGraphQlTester tester) { + void testCreateCourseWithTerm(GraphQlTester tester) { final String query = """ mutation { createCourse( @@ -253,7 +256,7 @@ void testTooLongDescription(final GraphQlTester tester) { * Then a validation error is returned */ @Test - void testStartDateAfterEndDate(final HttpGraphQlTester tester) { + void testStartDateAfterEndDate(WebGraphQlTester tester) { final String query = """ mutation { createCourse( diff --git a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationJoinCourseTest.java b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationJoinCourseTest.java index cfa233f..a2734f1 100644 --- a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationJoinCourseTest.java +++ b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationJoinCourseTest.java @@ -10,6 +10,7 @@ import de.unistuttgart.iste.meitrex.generated.dto.UserRoleInCourse; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.graphql.test.tester.WebGraphQlTester; import java.time.OffsetDateTime; import java.util.UUID; @@ -29,7 +30,7 @@ class MutationJoinCourseTest { private final UUID currentUserId = UUID.randomUUID(); @Test - void testJoinCourse(final HttpGraphQlTester tester) { + void testJoinCourse(WebGraphQlTester tester) { final CourseEntity course = courseRepository.save(CourseEntity.builder().title("Course 1") .description("This is course 1") .startDate(OffsetDateTime.parse("2020-01-01T00:00:00.000Z")) diff --git a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationLeaveCourseTest.java b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationLeaveCourseTest.java index d9e8926..29d7394 100644 --- a/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationLeaveCourseTest.java +++ b/src/test/java/de/unistuttgart/iste/meitrex/course_service/api/MutationLeaveCourseTest.java @@ -12,6 +12,7 @@ import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.graphql.test.tester.WebGraphQlTester; import java.time.OffsetDateTime; import java.util.UUID; @@ -28,7 +29,7 @@ class MutationLeaveCourseTest { private final UUID currentUserId = UUID.randomUUID(); @Test - void testLeaveCourse(final HttpGraphQlTester tester) { + void testLeaveCourse(WebGraphQlTester tester) { final CourseEntity course = courseRepository.save(CourseEntity.builder().title("Course 1") .description("This is course 1") .startDate(OffsetDateTime.parse("2020-01-01T00:00:00.000Z"))