diff --git a/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureCreateDto.java b/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureCreateDto.java index 0279180b41ea671a944ab270735ac5f5c00acb75..b7ec0926fd958f722109fcf52421f4c47934f8b4 100644 --- a/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureCreateDto.java +++ b/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureCreateDto.java @@ -12,11 +12,11 @@ public class LectureCreateDto { @Future(message = "Lecture start date and time must be in the future") @NotNull(message = "Lecture start date and time cannot be null") - private LocalDateTime from; + private LocalDateTime lectureFrom; @Future(message = "Lecture end date and time must be in the future") @NotNull(message = "Lecture end date and time cannot be null") - private LocalDateTime to; + private LocalDateTime lectureTo; @NotBlank(message = "Lecture topic cannot be blank") @Size(max = 255, message = "Lecture topic must be no more than {max} characters") @@ -30,8 +30,8 @@ public class LectureCreateDto { private Long courseId; public LectureCreateDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, Long courseId) { - this.from = from; - this.to = to; + this.lectureFrom = from; + this.lectureTo = to; this.topic = topic; this.capacity = capacity; this.courseId = courseId; @@ -39,7 +39,7 @@ public class LectureCreateDto { @AssertTrue(message = "Lecture start datetime must be before Lecture end datetime") private boolean isFromDateBeforeToDate() { - if (from == null || to == null) return true; - return from.isBefore(to); + if (lectureFrom == null || lectureTo == null) return true; + return lectureFrom.isBefore(lectureTo); } } diff --git a/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureDto.java b/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureDto.java index b10a5cb1c067c1da84ffa40e8cf6c19da845594c..73820adce9c8b5281064b96c6c0811253488b63c 100644 --- a/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureDto.java +++ b/application/model/src/main/java/org/fuseri/model/dto/lecture/LectureDto.java @@ -7,7 +7,6 @@ import lombok.Setter; import org.fuseri.model.dto.common.DomainObjectDto; import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.List; @Getter @@ -38,16 +37,16 @@ public class LectureDto extends DomainObjectDto { private Long courseId; @NotNull(message = "Student IDs list cannot be null") - private List<Long> studentIds; + private List<Long> students; - public LectureDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, Long lecturerId, Long courseId) { + public LectureDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, Long lecturerId, Long courseId, List<Long> students) { this.lectureFrom = from; this.lectureTo = to; this.topic = topic; this.capacity = capacity; this.lecturerId = lecturerId; this.courseId = courseId; - this.studentIds = new ArrayList<>(); + this.students = students; } @AssertTrue(message = "Lecture start datetime must be before Lecture end datetime") diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/course/Course.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/course/Course.java index 821ee1e40b1c15669c7d492943d64c48c44380a6..2117ea3fb60c9782ac13f257c0ac64e8bd4f7441 100644 --- a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/course/Course.java +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/course/Course.java @@ -1,12 +1,14 @@ package org.fuseri.modulelanguageschool.course; import jakarta.persistence.*; -import lombok.*; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; import org.fuseri.modulelanguageschool.common.DomainObject; import org.fuseri.modulelanguageschool.user.User; import java.util.List; -import java.util.Set; @Getter @Setter @@ -27,7 +29,7 @@ public class Course extends DomainObject { private ProficiencyLevel proficiency; @ManyToMany - private Set<User> students; + private List<User> students; public void enrolStudent(User student) { students.add(student); diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/Lecture.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/Lecture.java index 4391c9b29bee8a031c0c74ccf0a5d1079e394994..14afc0a256929f0c98f8ad3aa461896488d95189 100644 --- a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/Lecture.java +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/Lecture.java @@ -10,7 +10,7 @@ import org.fuseri.modulelanguageschool.course.Course; import org.fuseri.modulelanguageschool.user.User; import java.time.LocalDateTime; -import java.util.Set; +import java.util.List; /** * This class represents a lecture entity in the domain model. @@ -36,7 +36,7 @@ public class Lecture extends DomainObject { private User lecturer; @ManyToMany - private Set<User> students; + private List<User> students; public void enrolStudent(User student) { students.add(student); diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureFacade.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureFacade.java index 08fe710ce9f4fc519a3dd1996d2ea1d99ed33066..ce9214dd71a6f10b6a9aa47187692e3ff6470fd7 100644 --- a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureFacade.java +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureFacade.java @@ -5,6 +5,7 @@ import org.fuseri.model.dto.course.ProficiencyLevelDto; import org.fuseri.model.dto.lecture.LectureCreateDto; import org.fuseri.model.dto.lecture.LectureDto; import org.fuseri.model.dto.user.UserDto; +import org.fuseri.modulelanguageschool.course.CourseService; import org.fuseri.modulelanguageschool.course.Language; import org.fuseri.modulelanguageschool.course.ProficiencyLevel; import org.fuseri.modulelanguageschool.user.UserMapper; @@ -22,17 +23,19 @@ public class LectureFacade { private final LectureService lectureService; private final LectureMapper lectureMapper; private final UserMapper userMapper; + private final CourseService courseService; @Autowired - public LectureFacade(LectureService lectureService, LectureMapper lectureMapper, UserMapper userMapper) { + public LectureFacade(LectureService lectureService, LectureMapper lectureMapper, UserMapper userMapper, CourseService courseService) { this.lectureService = lectureService; this.lectureMapper = lectureMapper; this.userMapper = userMapper; + this.courseService = courseService; } @Transactional public LectureDto create(LectureCreateDto dto) { - return lectureMapper.mapToDto(lectureService.save(lectureMapper.mapToLecture(dto))); + return lectureMapper.mapToDto(lectureService.save(lectureMapper.mapToLecture(dto, courseService))); } @Cacheable(cacheNames = "courses", key = "#id") @@ -48,7 +51,7 @@ public class LectureFacade { @Transactional public LectureDto update(Long id, LectureCreateDto dto) { - return lectureMapper.mapToDto(lectureService.update(id, lectureMapper.mapToLecture(dto))); + return lectureMapper.mapToDto(lectureService.update(id, lectureMapper.mapToLecture(dto, courseService))); } @Transactional diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureMapper.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureMapper.java index c3edf8ad5f94e0f6a23d895ed406fec67a0afccc..1eba68d367b58e75f46bf841871aae883cc25a0d 100644 --- a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureMapper.java +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureMapper.java @@ -2,17 +2,70 @@ package org.fuseri.modulelanguageschool.lecture; import org.fuseri.model.dto.lecture.LectureCreateDto; import org.fuseri.model.dto.lecture.LectureDto; +import org.fuseri.modulelanguageschool.course.CourseService; +import org.fuseri.modulelanguageschool.user.User; +import org.fuseri.modulelanguageschool.user.UserService; import org.mapstruct.Mapper; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; -@Mapper(componentModel = "spring") +@Mapper(componentModel = "spring", uses = {UserService.class}) public interface LectureMapper { - LectureDto mapToDto(Lecture lecture); - Lecture mapToLecture(LectureDto lectureDto); + default LectureDto mapToDto(Lecture lecture) { + if (lecture == null) { + return null; + } - List<LectureDto> mapToList(List<Lecture> lectures); + var dto = new LectureDto(lecture.getLectureFrom(), + lecture.getLectureTo(), + lecture.getTopic(), + lecture.getCapacity(), + lecture.getLecturer() == null ? null : lecture.getLecturer().getId(), + lecture.getCourse().getId(), + new ArrayList<>(lecture.getStudents().stream().map(User::getId).collect(Collectors.toList()))); + dto.setId(lecture.getId()); + return dto; + } - Lecture mapToLecture(LectureCreateDto dto); + default Lecture mapToLecture(LectureDto lectureDto, CourseService courseService, UserService userService) { + if (lectureDto == null) { + return null; + } + var lecture = new Lecture(lectureDto.getLectureFrom(), + lectureDto.getLectureTo(), + lectureDto.getTopic(), + lectureDto.getCapacity(), + courseService.findById(lectureDto.getCourseId()), + userService.find(lectureDto.getLecturerId()), + new ArrayList<>()); + lecture.setId(lectureDto.getId()); + for (Long userId : lectureDto.getStudents()) { + lecture.enrolStudent(userService.find(userId)); + } + return lecture; + } + + default List<LectureDto> mapToList(List<Lecture> lectures) { + if (lectures == null) { + return null; + } + return new ArrayList<>(lectures.stream().map(this::mapToDto).toList()); + } + + + default Lecture mapToLecture(LectureCreateDto lectureDto, CourseService courseService) { + if (lectureDto == null) { + return null; + } + return new Lecture(lectureDto.getLectureFrom(), + lectureDto.getLectureTo(), + lectureDto.getTopic(), + lectureDto.getCapacity(), + courseService.findById(lectureDto.getCourseId()), + null, + new ArrayList<>()); + } } diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseRepositoryTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseRepositoryTest.java index 44314aac67a62ac44d71c872b546f11d12fdc35d..95ddc06b344397bd4c8bee8e9c55505f11ff85da 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseRepositoryTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseRepositoryTest.java @@ -8,8 +8,8 @@ import org.springframework.boot.test.autoconfigure.orm.jpa.TestEntityManager; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; +import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; @DataJpaTest @@ -22,7 +22,7 @@ class CourseRepositoryTest { private CourseRepository courseRepository; private final Course course = new Course("AJ1", 10, - Language.ENGLISH, ProficiencyLevel.A1, new HashSet<>()); + Language.ENGLISH, ProficiencyLevel.A1, new ArrayList<>()); @Test void saveCourse() { diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseServiceTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseServiceTest.java index 833da024f1e19920abc91bbeba825c475c1f521f..de62ebb600738b604d572b84ab23d804b2010ee1 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseServiceTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/course/CourseServiceTest.java @@ -27,13 +27,13 @@ final class CourseServiceTest { private CourseService courseService; private final Course course = new Course("AJ1", 10, - Language.ENGLISH, ProficiencyLevel.A1, new HashSet<>()); //todo + Language.ENGLISH, ProficiencyLevel.A1, new ArrayList<>()); //todo private final User user = new User("novakovat", UserType.STUDENT, "novakova@gamil.com", "password", "Tereza", "Nováková", new Address(), List.of(), List.of()); private final Course courseWithEnrolledStudent = new Course("AJ1", 10, - Language.ENGLISH, ProficiencyLevel.A1, new HashSet<>(List.of(user))); + Language.ENGLISH, ProficiencyLevel.A1, new ArrayList<>(List.of(user))); private final List<Course> courses = List.of(course, course); @Test @@ -51,7 +51,6 @@ final class CourseServiceTest { when(courseRepository.findById(anyLong())).thenReturn(Optional.empty()); Assertions.assertThrows(ResourceNotFoundException.class, () -> courseService.findById(anyLong())); - } @Test diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureControllerTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureControllerTest.java index f6164836b671143323b9c72b0937b262b5f32cd2..d4f02844c1019cd16f364193f83792d4da55e046 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureControllerTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureControllerTest.java @@ -17,6 +17,8 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import java.time.LocalDateTime; import java.util.ArrayList; +import java.util.Collections; + import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.is; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.*; @@ -34,16 +36,18 @@ public class LectureControllerTest { @MockBean private LectureController lectureController; + private final LocalDateTime now = LocalDateTime.now(); + private final LectureCreateDto lectureCreateDto = new LectureCreateDto( - LocalDateTime.now().plusDays(2), - LocalDateTime.now().plusDays(2).plusHours(2), + now.plusDays(2), + now.plusDays(2).plusHours(2), "Learning how to spell deprecated", 10, 0L); private final LectureDto lectureDto = new LectureDto( - LocalDateTime.now().plusDays(2), - LocalDateTime.now().plusDays(2).plusHours(2), + now.plusDays(2), + now.plusDays(2).plusHours(2), "Learning how to spell deprecated", - 10, 0L, 0L); + 10, 0L, 0L, Collections.emptyList()); @Test void createLecture() throws Exception { diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureFacadeTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureFacadeTest.java index 5634fcfb8120f3f5942edec5c7c7645aca7d8065..78f5924299f2ace9182566fb19f32cd9de49c2c2 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureFacadeTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureFacadeTest.java @@ -7,6 +7,7 @@ import org.fuseri.model.dto.lecture.LectureCreateDto; import org.fuseri.model.dto.lecture.LectureDto; import org.fuseri.model.dto.user.AddressDto; import org.fuseri.model.dto.user.UserDto; +import org.fuseri.modulelanguageschool.course.CourseService; import org.fuseri.modulelanguageschool.course.Language; import org.fuseri.modulelanguageschool.course.ProficiencyLevel; import org.fuseri.modulelanguageschool.user.User; @@ -18,6 +19,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import java.time.LocalDateTime; +import java.util.Collections; import java.util.List; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -43,7 +45,7 @@ final class LectureFacadeTest { LocalDateTime.now().plusDays(2), LocalDateTime.now().plusDays(2).plusHours(2), "Learning how to spell deprecated", - 10, 0L, 0L); + 10, 0L, 0L, Collections.emptyList()); private final Lecture lecture = new Lecture(); private final User user = new User(); private final List<Lecture> lectureList = List.of(lecture); @@ -64,9 +66,12 @@ final class LectureFacadeTest { @MockBean private UserMapper userMapper; + @Autowired + private CourseService courseService; + @Test void create() { - when(lectureMapper.mapToLecture(lectureCreateDto)).thenReturn(lecture); + when(lectureMapper.mapToLecture(lectureCreateDto, courseService)).thenReturn(lecture); when(lectureService.save(lecture)).thenReturn(lecture); when(lectureMapper.mapToDto(lecture)).thenReturn(lectureDto); @@ -101,7 +106,7 @@ final class LectureFacadeTest { @Test void update() { Long id = 1L; - when(lectureMapper.mapToLecture(lectureCreateDto)).thenReturn(lecture); + when(lectureMapper.mapToLecture(lectureCreateDto, courseService)).thenReturn(lecture); when(lectureService.update(id, lecture)).thenReturn(lecture); when(lectureMapper.mapToDto(lecture)).thenReturn(lectureDto); diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureMapperTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureMapperTest.java index 2fa4345e857347662b354fab4c41635f95ebba09..28e5a1e57fcce0bb1eebf2a534760376cc130b86 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureMapperTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureMapperTest.java @@ -1,68 +1,77 @@ package org.fuseri.modulelanguageschool.lecture; -import org.fuseri.model.dto.course.LanguageTypeDto; -import org.fuseri.model.dto.course.ProficiencyLevelDto; import org.fuseri.model.dto.lecture.LectureCreateDto; import org.fuseri.model.dto.lecture.LectureDto; import org.fuseri.modulelanguageschool.course.Course; +import org.fuseri.modulelanguageschool.course.CourseService; import org.fuseri.modulelanguageschool.course.Language; import org.fuseri.modulelanguageschool.course.ProficiencyLevel; -import org.fuseri.modulelanguageschool.lecture.Lecture; -import org.fuseri.modulelanguageschool.lecture.LectureMapper; import org.fuseri.modulelanguageschool.user.Address; import org.fuseri.modulelanguageschool.user.User; +import org.fuseri.modulelanguageschool.user.UserService; import org.fuseri.modulelanguageschool.user.UserType; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageImpl; -import org.springframework.data.domain.PageRequest; +import org.springframework.boot.test.mock.mockito.MockBean; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.anyLong; +import static org.mockito.Mockito.when; + @SpringBootTest final class LectureMapperTest { + private final LocalDateTime now = LocalDateTime.now(); + + private final User lecturer = new User("dolezelt", UserType.LECTURER, + "dolezel@gmail.com", "password", "Tomáš", + "Doležel", new Address(), List.of(), List.of()); + private final User student = new User("novakovat", UserType.STUDENT, + "novakova@gmail.com", "password", "Tereza", + "Nováková", new Address(), List.of(), List.of()); + + private final Course course = new Course("AJ1", 10, + Language.ENGLISH, ProficiencyLevel.A1, null); + private final LectureCreateDto lectureCreateDto = new LectureCreateDto( - LocalDateTime.now().plusDays(2), - LocalDateTime.now().plusDays(2).plusHours(2), + now.plusDays(2), + now.plusDays(2).plusHours(2), "Learning how to spell deprecated", - 10, 0L); + 10, course.getId()); private final LectureDto lectureDto = new LectureDto( - LocalDateTime.now().plusDays(2), - LocalDateTime.now().plusDays(2).plusHours(2), + now.plusDays(2), + now.plusDays(2).plusHours(2), "Learning how to spell deprecated", - 10, 0L, 0L); - private final Course course = new Course("AJ1", 10, - Language.ENGLISH, ProficiencyLevel.A1, null); - private final User student = new User("novakovat", UserType.STUDENT, - "novakova@gmail.com", "password", "Tereza", - "Nováková", new Address(), List.of(), List.of()); - private final User lecturer = new User("dolezelt", UserType.LECTURER, - "dolezel@gmail.com", "password", "Tomáš", - "Doležel", new Address(), List.of(), List.of()); + 10, lecturer.getId(), course.getId(), Collections.emptyList()); + private final Lecture newLecture = new Lecture( + now.plusDays(2), + now.plusDays(2).plusHours(2), + "Learning how to spell deprecated", + 10, + course, null, new ArrayList<>(List.of())); + private final Lecture lecture = new Lecture( - LocalDateTime.now().plusDays(2), - LocalDateTime.now().plusDays(2).plusHours(2), + now.plusDays(2), + now.plusDays(2).plusHours(2), "Learning how to spell deprecated", 10, - course, lecturer, new HashSet<>(List.of(student))); + course, lecturer, new ArrayList<>(List.of())); @Autowired private org.fuseri.modulelanguageschool.lecture.LectureMapper LectureMapper; - @BeforeEach - void setUp() - { - lecture.setId(1L); - lectureDto.setId(1L); - } + @MockBean + private CourseService courseService; + + @MockBean + private UserService userService; @Test void mapNullToDto() { @@ -80,15 +89,17 @@ final class LectureMapperTest { @Test void mapNullToLectureDto() { - var createdLecture = LectureMapper.mapToLecture((LectureDto) null); + var createdLecture = LectureMapper.mapToLecture((LectureDto) null, courseService, userService); Assertions.assertNull(createdLecture); } @Test void mapToLectureDto() { - var createdLecture = LectureMapper.mapToLecture(lectureDto); + when(courseService.findById(any())).thenReturn(course); + when(userService.find(any())).thenReturn(student); + var createdLecture = LectureMapper.mapToLecture(lectureDto, courseService, userService); Assertions.assertEquals(lecture, createdLecture); } @@ -108,6 +119,9 @@ final class LectureMapperTest { @Test void mapToList() { + when(courseService.findById(anyLong())).thenReturn(course); + when(userService.find(anyLong())).thenReturn(lecturer); + var lectureDtos = LectureMapper.mapToList(Collections.singletonList(lecture)); Assertions.assertEquals(1, lectureDtos.size()); @@ -116,16 +130,18 @@ final class LectureMapperTest { @Test void mapNullToLectureLectureCreateDto() { - var createdLecture = LectureMapper.mapToLecture((LectureCreateDto) null); + var createdLecture = LectureMapper.mapToLecture((LectureCreateDto) null, courseService); Assertions.assertNull(createdLecture); } @Test void mapToLectureLectureCreateDto() { - var createdLecture = LectureMapper.mapToLecture(lectureCreateDto); + when(courseService.findById(any())).thenReturn(course); - Assertions.assertEquals(lecture, createdLecture); + var createdLecture = LectureMapper.mapToLecture(lectureCreateDto, courseService); + + Assertions.assertEquals(newLecture, createdLecture); } } diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureRepositoryTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureRepositoryTest.java index e2320d8a9351d2bad45c49e629cfc8534037def5..242f478f6474cff9d8f33e98509910e449fb4779 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureRepositoryTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureRepositoryTest.java @@ -15,8 +15,8 @@ import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import java.time.LocalDateTime; +import java.util.ArrayList; import java.util.Arrays; -import java.util.HashSet; import java.util.List; @DataJpaTest @@ -42,7 +42,7 @@ class LectureRepositoryTest { LocalDateTime.now().plusDays(2).plusHours(2), "Learning how to spell deprecated", 10, - course, lecturer, new HashSet<>(List.of(student))); + course, lecturer, new ArrayList<>(List.of(student))); @Test void saveLecture() { diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureServiceTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureServiceTest.java index 4f1c31d41061b508349e4bed16998f66d3859eb6..a1114eeac448e889e097835a1427f10557c13f23 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureServiceTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureServiceTest.java @@ -40,7 +40,7 @@ final class LectureServiceTest { LocalDateTime.now().plusDays(2).plusHours(2), "Learning how to spell deprecated", 10, - course, lecturer, new HashSet<>(List.of())); + course, lecturer, new ArrayList<>(List.of())); private final User user = new User("novakovat", UserType.STUDENT, "novakova@gamil.com", "password", "Tereza", @@ -51,8 +51,8 @@ final class LectureServiceTest { LocalDateTime.now().plusDays(2).plusHours(2), "Learning how to spell deprecated", 10, - course, lecturer, new HashSet<>(List.of(student))); - private final List<Lecture> lectures = List.of(lecture, lecture); + course, lecturer, new ArrayList<>(List.of(student))); + private final List<Lecture> lectures = new ArrayList<>(List.of(lecture, lecture)); @Test void save() {