From b68723fc4b68d30666058c4504df7569c613eee4 Mon Sep 17 00:00:00 2001 From: Thuan ngo Date: Sat, 31 Aug 2024 21:35:20 +0700 Subject: [PATCH] fix unit test --- .../elearning/controller/CartControllerTest.java | 6 +++--- .../backend/elearning/service/CartServiceTest.java | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/backend/elearning/controller/CartControllerTest.java b/src/test/java/com/backend/elearning/controller/CartControllerTest.java index 52b79d3..c3f897d 100644 --- a/src/test/java/com/backend/elearning/controller/CartControllerTest.java +++ b/src/test/java/com/backend/elearning/controller/CartControllerTest.java @@ -56,7 +56,7 @@ void addToCart_ShouldReturnCartListGetVM_WhenCourseIsAddedToCart() throws Except CourseListGetVM courseListGetVM = new CourseListGetVM( 1L, "Course Title", "Course Headline", "Beginner", "course-slug", "10h 30m", 25, 4.5, 100, - "image-url", 1999L, "Author Name" + "image-url", 1999L, false, "Author Name" ); CartListGetVM cartListGetVM = new CartListGetVM(1L, courseListGetVM, false); when(cartService.addCourseToCart(courseId)).thenReturn(cartListGetVM); @@ -76,12 +76,12 @@ void listCartForCustomer_ShouldReturnListOfCartListGetVM() throws Exception { CourseListGetVM course1 = new CourseListGetVM( 1L, "Course Title 1", "Course Headline 1", "Beginner", "course-slug-1", "10h 30m", 25, 4.5, 100, - "image-url-1", 1999L, "Author Name 1" + "image-url-1", 1999L, false, "Author Name 1" ); CourseListGetVM course2 = new CourseListGetVM( 2L, "Course Title 2", "Course Headline 2", "Intermediate", "course-slug-2", "8h 15m", 20, 4.2, 80, - "image-url-2", 2999L, "Author Name 2" + "image-url-2", 2999L, false, "Author Name 2" ); List cartList = List.of( new CartListGetVM(1L, course1, false), diff --git a/src/test/java/com/backend/elearning/service/CartServiceTest.java b/src/test/java/com/backend/elearning/service/CartServiceTest.java index 0889c42..fa69ba5 100644 --- a/src/test/java/com/backend/elearning/service/CartServiceTest.java +++ b/src/test/java/com/backend/elearning/service/CartServiceTest.java @@ -74,7 +74,8 @@ void addCourseToCart_shouldAddCourseToCart_whenCourseIsNotInCart() { 4.7, // averageRating 1500, // ratingCount "https://example.com/images/java.png", // image - 4999L, // price + 4999L, + false,// price "John Doe" // createdBy ); @@ -116,7 +117,8 @@ void addCourseToCart_shouldReturnExistedCart_whenCourseIsAlreadyInCart() { 4.7, // averageRating 1500, // ratingCount "https://example.com/images/java.png", // image - 4999L, // price + 4999L, + false,// price "John Doe" // createdBy ); @@ -243,12 +245,13 @@ void listCartForUser_shouldReturnCartListForUser() { 4.7, // averageRating 1500, // ratingCount "https://example.com/images/java.png", // image - 4999L, // price + 4999L, + false,// price "John Doe" // createdBy ); CourseListGetVM courseListGetVM2 = new CourseListGetVM( 2L, "Advanced Java", "Deep dive into Java", "Advanced", "advanced-java", - "15h 45m", 35, 4.9, 3000, "https://example.com/images/java_advanced.png", 7999L, "Jane Smith" + "15h 45m", 35, 4.9, 3000, "https://example.com/images/java_advanced.png", 7999L, false,"Jane Smith" ); List carts = List.of(cart1, cart2);