-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change classCode to classId for send invite, remove classCode for cla…
…ss table
- Loading branch information
Showing
8 changed files
with
16 additions
and
13 deletions.
There are no files selected for viewing
3 changes: 2 additions & 1 deletion
3
src/main/java/com/quemistry/user_ms/model/StudentInvitationDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,11 @@ | ||
package com.quemistry.user_ms.model; | ||
|
||
import jakarta.validation.constraints.NotBlank; | ||
import jakarta.validation.constraints.NotNull; | ||
|
||
public record StudentInvitationDto( | ||
@NotBlank String studentEmail, | ||
@NotBlank String studentFullName, | ||
@NotBlank String classCode) { | ||
@NotNull Long classId) { | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
src/main/resources/db/migration/V20240926212444__update_class.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE qms_user.class | ||
RENAME COLUMN class_end_ts TO end_date; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -295,7 +295,7 @@ void givenStudents_whenSendInvitationToStudent_thenStatus200() throws Exception | |
{ | ||
"studentEmail": "[email protected]", | ||
"studentFullName": "test", | ||
"classCode": "test" | ||
"classId": "1" | ||
}""")) | ||
.andExpect(status().isOk()) | ||
.andExpect(content().contentTypeCompatibleWith(MediaType.APPLICATION_JSON)) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -153,7 +153,7 @@ void givenStudent_whenSendInvitation_thenReturnSuccess() throws Exception { | |
var inputStudentProfile = new StudentInvitationDto( | ||
"[email protected]", | ||
"full name", | ||
"c001"); | ||
1L); | ||
|
||
|
||
var userEntity = new User( | ||
|
@@ -167,7 +167,7 @@ void givenStudent_whenSendInvitation_thenReturnSuccess() throws Exception { | |
var tutorEntity = new Tutor(2L, "P1", "centre", userEntity, Collections.emptyList()); | ||
|
||
when(tutorRepository.findTutorByUserEntityAccountId(anyString())).thenReturn(Optional.of(tutorEntity)); | ||
when(classRepository.findByCode(any())).thenReturn(Optional.of(clazz)); | ||
when(classRepository.findById(any())).thenReturn(Optional.of(clazz)); | ||
when(notificationService.sendEmailNotification(anyString(), anyString(), any())).thenReturn(true); | ||
when(cryptoService.encrypt(anyString())).thenReturn("test"); | ||
|
||
|
@@ -193,19 +193,19 @@ void testSendInvitation_TutorNotFound() { | |
void testSendInvitation_ClassNotFound() { | ||
// Given | ||
String tutorAccountId = "tutor123"; | ||
String classCode = "class456"; | ||
StudentInvitationDto input = new StudentInvitationDto("John Doe", "[email protected]", classCode); | ||
Long classId = 1L; | ||
StudentInvitationDto input = new StudentInvitationDto("John Doe", "[email protected]", classId); | ||
|
||
Tutor tutor = new Tutor(); | ||
when(tutorRepository.findTutorByUserEntityAccountId(tutorAccountId)).thenReturn(Optional.of(tutor)); | ||
when(classRepository.findByCode(classCode)).thenReturn(Optional.empty()); | ||
when(classRepository.findById(classId)).thenReturn(Optional.empty()); | ||
|
||
// Act & Assert | ||
ResponseStatusException exception = assertThrows(ResponseStatusException.class, () -> { | ||
studentService.sendInvitation(input, tutorAccountId); | ||
}); | ||
|
||
assertEquals("404 NOT_FOUND \"class code=class456 not found\"", exception.getMessage()); | ||
assertEquals("404 NOT_FOUND \"class id=1 not found\"", exception.getMessage()); | ||
verify(classInvitationRepository, never()).save(any(ClassInvitation.class)); | ||
} | ||
|
||
|