Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
guma2k2 committed Aug 31, 2024
1 parent dc52d36 commit b68723f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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<CartListGetVM> cartList = List.of(
new CartListGetVM(1L, course1, false),
Expand Down
11 changes: 7 additions & 4 deletions src/test/java/com/backend/elearning/service/CartServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
);

Expand Down Expand Up @@ -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
);

Expand Down Expand Up @@ -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<Cart> carts = List.of(cart1, cart2);
Expand Down

0 comments on commit b68723f

Please sign in to comment.