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 6fc9b766fefb23e0f31aa2d79af7f30dc9ae7ab2..0279180b41ea671a944ab270735ac5f5c00acb75 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 @@ -3,7 +3,6 @@ package org.fuseri.model.dto.lecture; import jakarta.validation.constraints.*; import lombok.Getter; import lombok.Setter; -import org.fuseri.model.dto.course.CourseDto; import java.time.LocalDateTime; @@ -27,10 +26,10 @@ public class LectureCreateDto { @Min(value = 1, message = "Lecture capacity must be at least 1") private Integer capacity; - @NotBlank(message = "Lecture course cannot be blank") - private String courseId; + @NotNull(message = "Lecture course cannot be null") + private Long courseId; - public LectureCreateDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, String courseId) { + public LectureCreateDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, Long courseId) { this.from = from; this.to = to; this.topic = topic; 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 f54ac383238e7e6cfbecbde6a71af275f4a4efb0..df35d83cfa5668cb6c9d28b514d50221f6425584 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 @@ -29,16 +29,16 @@ public class LectureDto extends DomainObjectDto { @Min(value = 1, message = "Lecture capacity must be at least 1") private Integer capacity; - @NotNull(message = "Lecture capacity cannot be null") - private String lecturerId; + @NotNull(message = "Lecture lecturer cannot be null") + private Long lecturerId; - @NotBlank(message = "Lecture courseId cannot be blank") - private String courseId; + @NotNull(message = "Lecture courseId cannot be null") + private Long courseId; @NotNull(message = "Student IDs list cannot be null") private List<Long> studentIds; - public LectureDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, String lecturerId, String courseId) { + public LectureDto(LocalDateTime from, LocalDateTime to, String topic, Integer capacity, Long lecturerId, Long courseId) { this.from = from; this.to = to; this.topic = topic; 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 86b9670a578674a85557aad6768c022561a1b53a..a719f242bad99bdd3349d44cdddbbc51fc2319fa 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 @@ -3,6 +3,7 @@ package org.fuseri.modulelanguageschool.lecture; import jakarta.persistence.Entity; import jakarta.persistence.ManyToMany; import jakarta.persistence.ManyToOne; +import jakarta.persistence.Table; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.NoArgsConstructor; @@ -12,13 +13,15 @@ import org.fuseri.modulelanguageschool.course.Course; import org.fuseri.modulelanguageschool.user.User; import java.time.LocalDateTime; -import java.util.List; +import java.util.Set; /** * This class represents a lecture entity in the domain model. */ @Getter @Setter +@Entity +@Table(name = "lecture") @NoArgsConstructor @AllArgsConstructor public class Lecture extends DomainObject { @@ -27,9 +30,20 @@ public class Lecture extends DomainObject { private LocalDateTime to; private String topic; + @ManyToOne private Course course; + @ManyToOne private User lecturer; - private List<User> user; + @ManyToMany + private Set<User> students; + + public void enrolStudent(User student) { + students.add(student); + } + + public void expelStudent(User student) { + students.remove(student); + } } diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureController.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureController.java index 34d91578d4a8f53d4dbc75972d3216cbb199adf6..99da62d65cb004ec46b9aea96e51c867938dc577 100644 --- a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureController.java +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureController.java @@ -1,15 +1,12 @@ package org.fuseri.modulelanguageschool.lecture; import jakarta.validation.Valid; -import org.fuseri.model.dto.course.CourseDto; import org.fuseri.model.dto.lecture.LectureCreateDto; import org.fuseri.model.dto.lecture.LectureDto; import org.fuseri.model.dto.user.UserDto; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; -import java.time.LocalDateTime; -import java.time.Month; -import java.util.ArrayList; import java.util.List; /** @@ -20,9 +17,13 @@ import java.util.List; @RequestMapping("/lectures") public class LectureController { - private static final LocalDateTime START_DATETIME = LocalDateTime.of(2045, Month.JUNE, 30, 12, 0, 0); - private static final LocalDateTime END_DATETIME = LocalDateTime.of(2045, Month.JUNE, 30, 14, 0, 0); - public static final String TOPIC = "Learning how to spell deprecated"; + private final LectureFacade lectureFacade; + + @Autowired + public LectureController(LectureFacade lectureFacade) { + this.lectureFacade = lectureFacade; + } + /** * Creates a new lecture resource by delegating to the LectureService's create method. @@ -32,18 +33,18 @@ public class LectureController { */ @PostMapping("/create") public LectureDto create(@Valid @RequestBody LectureCreateDto lecture) { - return new LectureDto(START_DATETIME, END_DATETIME, TOPIC, 10, "0", "0"); + return lectureFacade.create(lecture); } /** * Retrieves a lecture resource by its ID. * - * @param id the ID of the lecture to find + * @param courseId the ID of the lecture to find * @return the LectureDto representing the found lecture */ - @GetMapping("find/{id}") - public LectureDto find(@PathVariable String id) { - return new LectureDto(START_DATETIME, END_DATETIME, TOPIC, 10, "0", "0"); + @GetMapping("find/{courseId}") + public LectureDto find(@PathVariable Long courseId) { + return lectureFacade.findById(courseId); } /** @@ -53,8 +54,8 @@ public class LectureController { * @return the list of LectureDtos */ @GetMapping("/findByCourse") - public List<LectureDto> findByCourse(@Valid @RequestParam String courseId) { - return new ArrayList<>(); + public List<LectureDto> findByCourse(@Valid @RequestParam Long courseId) { + return lectureFacade.findAll(courseId); } /** @@ -64,8 +65,8 @@ public class LectureController { * @return the LectureDto representing the updated lecture */ @PutMapping("/update/{id}") - public LectureDto update(@PathVariable String id, @Valid @RequestBody LectureCreateDto lecture) { - return new LectureDto(START_DATETIME, END_DATETIME, TOPIC, 10, "0", "0"); + public LectureDto update(@PathVariable Long id, @Valid @RequestBody LectureCreateDto lecture) { + return lectureFacade.update(id, lecture); } /** @@ -74,20 +75,21 @@ public class LectureController { * @param id the ID of the lecture to delete */ @DeleteMapping("/delete/{id}") - public void delete(@PathVariable String id) { + public void delete(@PathVariable Long id) { + lectureFacade.delete(id); } /** * Adds lecturer to the existing lecture resource * - * @param id id of lecture to update - * @param lecturer UserDto for the course lecturer + * @param id id of lecture to update + * @param lecturerDto UserDto for the course lecturer * @return the LectureDto representing the updated lecture */ @PatchMapping("/setLecturer/{id}") - public LectureDto setLecturer(@PathVariable String id, @RequestBody UserDto lecturer) { - return new LectureDto(START_DATETIME, END_DATETIME, TOPIC, 10, "0", "0"); + public LectureDto setLecturer(@PathVariable Long id, @RequestBody UserDto lecturerDto) { + return lectureFacade.setLecturer(id, lecturerDto); } /** @@ -98,10 +100,8 @@ public class LectureController { * @return the LectureDto representing the updated lecture */ @PatchMapping("/enrol/{id}") - public LectureDto enrol(@PathVariable String id, @RequestBody UserDto student) { - var lecture = new LectureDto(START_DATETIME, END_DATETIME, TOPIC, 10, "0", "0"); - lecture.setStudentIds(new ArrayList<>(List.of(student.getId()))); - return lecture; + public LectureDto enrol(@PathVariable Long id, @RequestBody UserDto student) { + return lectureFacade.enrol(id, student); } /** @@ -112,7 +112,7 @@ public class LectureController { * @return the LectureDto representing the updated lecture */ @PatchMapping("/expel/{id}") - public LectureDto expel(@PathVariable String id, @RequestBody UserDto student) { - return new LectureDto(START_DATETIME, END_DATETIME, TOPIC, 10, "0", "0"); + public LectureDto expel(@PathVariable Long id, @RequestBody UserDto student) { + return lectureFacade.expel(id, student); } } \ No newline at end of file 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 new file mode 100644 index 0000000000000000000000000000000000000000..08fe710ce9f4fc519a3dd1996d2ea1d99ed33066 --- /dev/null +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureFacade.java @@ -0,0 +1,78 @@ +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.model.dto.user.UserDto; +import org.fuseri.modulelanguageschool.course.Language; +import org.fuseri.modulelanguageschool.course.ProficiencyLevel; +import org.fuseri.modulelanguageschool.user.UserMapper; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +@Service +@Transactional +public class LectureFacade { + + private final LectureService lectureService; + private final LectureMapper lectureMapper; + private final UserMapper userMapper; + + @Autowired + public LectureFacade(LectureService lectureService, LectureMapper lectureMapper, UserMapper userMapper) { + this.lectureService = lectureService; + this.lectureMapper = lectureMapper; + this.userMapper = userMapper; + } + + @Transactional + public LectureDto create(LectureCreateDto dto) { + return lectureMapper.mapToDto(lectureService.save(lectureMapper.mapToLecture(dto))); + } + + @Cacheable(cacheNames = "courses", key = "#id") + @Transactional(readOnly = true) + public LectureDto findById(Long id) { + return lectureMapper.mapToDto(lectureService.findById(id)); + } + + @Transactional(readOnly = true) + public List<LectureDto> findAll(Long id) { + return lectureMapper.mapToList(lectureService.findAllByCourse(id)); + } + + @Transactional + public LectureDto update(Long id, LectureCreateDto dto) { + return lectureMapper.mapToDto(lectureService.update(id, lectureMapper.mapToLecture(dto))); + } + + @Transactional + public void delete(Long id) { + lectureService.delete(id); + } + + public List<LectureDto> findAll(LanguageTypeDto lang) { + return lectureMapper.mapToList(lectureService.findAll(Language.valueOf(lang.name()))); + } + + public List<LectureDto> findAll(LanguageTypeDto lang, ProficiencyLevelDto prof) { + return lectureMapper.mapToList(lectureService.findAll(Language.valueOf(lang.name()), ProficiencyLevel.valueOf(prof.name()))); + } + + public LectureDto enrol(Long id, UserDto student) { + return lectureMapper.mapToDto(lectureService.enrol(id, userMapper.fromDto(student))); + } + + public LectureDto expel(Long id, UserDto student) { + return lectureMapper.mapToDto(lectureService.expel(id, userMapper.fromDto(student))); + } + + public LectureDto setLecturer(Long id, UserDto lecturerDto) { + return lectureMapper.mapToDto(lectureService.setLecturer(id, userMapper.fromDto(lecturerDto))); + } +} 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 new file mode 100644 index 0000000000000000000000000000000000000000..8136a3e21de60635099c9284cfc71d2dec40ee2b --- /dev/null +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureMapper.java @@ -0,0 +1,25 @@ +package org.fuseri.modulelanguageschool.lecture; + +import org.fuseri.model.dto.lecture.LectureCreateDto; +import org.fuseri.model.dto.lecture.LectureDto; +import org.mapstruct.Mapper; +import org.springframework.data.domain.Page; +import org.springframework.data.domain.PageImpl; + +import java.util.List; + +@Mapper(componentModel = "spring") +public interface LectureMapper { + LectureDto mapToDto(Lecture lecture); + + Lecture mapToLecture(LectureDto lectureDto); + + List<LectureDto> mapToList(List<Lecture> lectures); + + + default Page<LectureDto> mapToPageDto(Page<Lecture> lectures) { + return new PageImpl<>(mapToList(lectures.getContent()), lectures.getPageable(), lectures.getTotalPages()); + } + + Lecture mapToLecture(LectureCreateDto dto); +} diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureRepository.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureRepository.java new file mode 100644 index 0000000000000000000000000000000000000000..1fd35bce8e435fd2bb321504daabf03772997fc3 --- /dev/null +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureRepository.java @@ -0,0 +1,21 @@ +package org.fuseri.modulelanguageschool.lecture; +import org.fuseri.modulelanguageschool.course.Language; +import org.fuseri.modulelanguageschool.course.ProficiencyLevel; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.stereotype.Repository; + +import java.util.List; + +@Repository +public interface LectureRepository extends JpaRepository<Lecture, Long> { + + @Query("SELECT l FROM Lecture l WHERE l.course.id = ?1") + List<Lecture> findAllByCourse(Long id); + + @Query("SELECT l FROM Lecture l WHERE l.course.language = ?1") + List<Lecture> findAllByLang(Language language); + + @Query("SELECT l FROM Lecture l WHERE l.course.language = ?1 AND l.course.proficiency = ?2") + List<Lecture> findAllByLangProf(Language language, ProficiencyLevel proficiencyLevel); +} diff --git a/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureService.java b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureService.java new file mode 100644 index 0000000000000000000000000000000000000000..a9e90bcbae837c0785c4119e76f6d548163c19e7 --- /dev/null +++ b/application/module-language-school/src/main/java/org/fuseri/modulelanguageschool/lecture/LectureService.java @@ -0,0 +1,102 @@ +package org.fuseri.modulelanguageschool.lecture; + +import org.fuseri.modulelanguageschool.common.ResourceNotFoundException; +import org.fuseri.modulelanguageschool.course.Language; +import org.fuseri.modulelanguageschool.course.ProficiencyLevel; +import org.fuseri.modulelanguageschool.user.User; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Optional; + +@Service +public class LectureService { + + private final LectureRepository lectureRepository; + + @Autowired + public LectureService(LectureRepository lectureRepository) { + this.lectureRepository = lectureRepository; + } + + @Transactional + public Lecture save(Lecture lecture) { + return lectureRepository.save(lecture); + } + + @Transactional(readOnly = true) + public Lecture findById(Long id) { + return lectureRepository.findById(id) + .orElseThrow(() -> new ResourceNotFoundException("Lecture with id: " + id + " was not found.")); + } + + @Transactional(readOnly = true) + public List<Lecture> findAllByCourse(Long id) { + return lectureRepository.findAllByCourse(id); + } + + @Transactional + public Lecture update(Long id, Lecture newLecture) { + Optional<Lecture> optionalLecture = lectureRepository.findById(id); + if (optionalLecture.isPresent()) { + Lecture lecture = optionalLecture.get(); + lecture.setFrom(newLecture.getFrom()); + lecture.setTo(newLecture.getTo()); + lecture.setTopic(newLecture.getTopic()); + lecture.setCourse(newLecture.getCourse()); + lecture.setLecturer(newLecture.getLecturer()); + lecture.setStudents(newLecture.getStudents()); + return lectureRepository.save(lecture); + } else { + throw new ResourceNotFoundException("Lecture with id: " + id + " was not found."); + } + } + + @Transactional + public void delete(Long id) { + lectureRepository.deleteById(id); + } + + public List<Lecture> findAll(Language language) { + return lectureRepository.findAllByLang(language); + } + + public List<Lecture> findAll(Language language, ProficiencyLevel proficiencyLevel) { + return lectureRepository.findAllByLangProf(language, proficiencyLevel); + } + + public Lecture enrol(Long id, User student) { + Optional<Lecture> optionalLecture = lectureRepository.findById(id); + if (optionalLecture.isPresent()) { + Lecture lecture = optionalLecture.get(); + lecture.enrolStudent(student); + return lectureRepository.save(lecture); + } else { + throw new ResourceNotFoundException("Lecture with id: " + id + " was not found."); + } + } + + public Lecture expel(Long id, User student) { + Optional<Lecture> optionalLecture = lectureRepository.findById(id); + if (optionalLecture.isPresent()) { + Lecture lecture = optionalLecture.get(); + lecture.expelStudent(student); + return lectureRepository.save(lecture); + } else { + throw new ResourceNotFoundException("Lecture with id: " + id + " was not found."); + } + } + + public Lecture setLecturer(Long id, User lecturer) { + Optional<Lecture> optionalLecture = lectureRepository.findById(id); + if (optionalLecture.isPresent()) { + Lecture lecture = optionalLecture.get(); + lecture.setLecturer(lecturer); + return lectureRepository.save(lecture); + } else { + throw new ResourceNotFoundException("Lecture with id: " + id + " was not found."); + } + } +} diff --git a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureTest.java b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureTest.java index e254fd91b028d5636361c47afd12a0c5483ac2ab..7c28786107d499d226165831e7968cf440a6e4da 100644 --- a/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureTest.java +++ b/application/module-language-school/src/test/java/org/fuseri/modulelanguageschool/lecture/LectureTest.java @@ -38,12 +38,12 @@ public class LectureTest { LocalDateTime.now().plusDays(2), LocalDateTime.now().plusDays(2).plusHours(2), "Learning how to spell deprecated", - 10, "0"); + 10, 0L); private final LectureDto lectureDto = new LectureDto( LocalDateTime.now().plusDays(2), LocalDateTime.now().plusDays(2).plusHours(2), "Learning how to spell deprecated", - 10, "0", "0"); + 10, 0L, 0L); @Test void createLecture() throws Exception { @@ -81,7 +81,7 @@ public class LectureTest { @Test void findLecture() throws Exception { - String id = "0"; + Long id = 0L; Mockito.when(lectureController.find(id)).thenReturn(lectureDto); mockMvc.perform(get("/lectures/find/" + id)) .andExpect(status().isOk()) @@ -96,17 +96,17 @@ public class LectureTest { @Test void findLectureWithoutId() throws Exception { - Mockito.when(lectureController.find(ArgumentMatchers.anyString())).thenReturn(lectureDto); + Mockito.when(lectureController.find(ArgumentMatchers.anyLong())).thenReturn(lectureDto); mockMvc.perform(get("/lectures/find/")) .andExpect(status().is4xxClientError()); } @Test void findLecturesByCourse() throws Exception { - String id = "0"; + Long id = 0L; Mockito.when(lectureController.findByCourse(id)).thenReturn(new ArrayList<>()); String response = mockMvc.perform(get("/lectures/findByCourse") - .param("courseId", id)) + .param("courseId", String.valueOf(id))) .andExpect(status().isOk()) .andReturn().getResponse().getContentAsString(); @@ -115,14 +115,14 @@ public class LectureTest { @Test void findLecturesByCourseWithoutParameter() throws Exception { - Mockito.when(lectureController.findByCourse(ArgumentMatchers.anyString())).thenReturn(new ArrayList<>()); + Mockito.when(lectureController.findByCourse(ArgumentMatchers.anyLong())).thenReturn(new ArrayList<>()); mockMvc.perform(get("/lectures/findByCourse")) .andExpect(status().is4xxClientError()); } @Test void updateLecture() throws Exception { - String id = "0"; + Long id = 0L; Mockito.when(lectureController.update(ArgumentMatchers.eq(id), ArgumentMatchers.isA(LectureCreateDto.class))) .thenReturn(lectureDto); @@ -142,7 +142,7 @@ public class LectureTest { @Test void updateLectureWithoutParameter() throws Exception { Mockito.when(lectureController. - update(ArgumentMatchers.anyString(), ArgumentMatchers.isA(LectureCreateDto.class))) + update(ArgumentMatchers.anyLong(), ArgumentMatchers.isA(LectureCreateDto.class))) .thenReturn(lectureDto); mockMvc.perform(put("/lectures/update")) .andExpect(status().is4xxClientError()); @@ -150,7 +150,7 @@ public class LectureTest { @Test void deleteLecture() throws Exception { - String id = "0"; + Long id = 0L; Mockito.doNothing().when(lectureController).delete(id); mockMvc.perform(delete("/lectures/delete/" + id)) .andExpect(status().isOk()); @@ -158,14 +158,14 @@ public class LectureTest { @Test void deleteCourseWithoutParameter() throws Exception { - Mockito.doNothing().when(lectureController).delete(ArgumentMatchers.anyString()); + Mockito.doNothing().when(lectureController).delete(ArgumentMatchers.anyLong()); mockMvc.perform(delete("/lectures/delete/")) .andExpect(status().is4xxClientError()); } @Test void setLecturerForLecture() throws Exception { - String id = "0"; + Long id = 0L; Mockito.when(lectureController.setLecturer(ArgumentMatchers.eq(id), ArgumentMatchers.isA(UserDto.class))) .thenReturn(lectureDto); @@ -186,7 +186,7 @@ public class LectureTest { @Test void setLecturerForLectureWithoutParameters() throws Exception { - Mockito.when(lectureController.setLecturer(ArgumentMatchers.anyString(), + Mockito.when(lectureController.setLecturer(ArgumentMatchers.anyLong(), ArgumentMatchers.isA(UserDto.class))) .thenReturn(lectureDto); mockMvc.perform(patch("/lectures/setLecturer")) @@ -195,7 +195,7 @@ public class LectureTest { @Test void enrolLecture() throws Exception { - String id = "0"; + Long id = 0L; Mockito.when(lectureController.enrol(ArgumentMatchers.eq(id), ArgumentMatchers.isA(UserDto.class))) .thenReturn(lectureDto); @@ -216,7 +216,7 @@ public class LectureTest { @Test void enrolCourseWithoutUserParameters() throws Exception { - Mockito.when(lectureController.enrol(ArgumentMatchers.anyString(), + Mockito.when(lectureController.enrol(ArgumentMatchers.anyLong(), ArgumentMatchers.isA(UserDto.class))) .thenReturn(lectureDto); mockMvc.perform(patch("/lectures/enrol")) @@ -225,7 +225,7 @@ public class LectureTest { @Test void expelLecture() throws Exception { - String id = "0"; + Long id = 0L; Mockito.when(lectureController.expel(ArgumentMatchers.eq(id), ArgumentMatchers.isA(UserDto.class))) .thenReturn(lectureDto); @@ -246,7 +246,7 @@ public class LectureTest { @Test void expelCourseWithoutUserParameters() throws Exception { - Mockito.when(lectureController.expel(ArgumentMatchers.anyString(), + Mockito.when(lectureController.expel(ArgumentMatchers.anyLong(), ArgumentMatchers.isA(UserDto.class))) .thenReturn(lectureDto); mockMvc.perform(patch("/lectures/expel"))