Skip to content

Commit

Permalink
VKT(Backend): Save examiner to contact request
Browse files Browse the repository at this point in the history
  • Loading branch information
jrkkp committed Nov 7, 2024
1 parent d6c0f5b commit f5fc165
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,11 @@ public List<PublicExaminerDTO> listExaminers() {

@PostMapping(path = "/enrollment/examiner/{examinerId:\\d+}")
@ResponseStatus(HttpStatus.CREATED)
public void createEnrollmentContact(@RequestBody @Valid final PublicEnrollmentContactCreateDTO dto) {
publicEnrollmentService.createEnrollmentContact(dto);
public void createEnrollmentContact(
@RequestBody @Valid final PublicEnrollmentContactCreateDTO dto,
@PathVariable final long examinerId
) {
publicEnrollmentService.createEnrollmentContact(dto, examinerId);
}

@GetMapping(path = "/enrollment/examiner/{examinerId:\\d+}")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import fi.oph.vkt.model.Enrollment;
import fi.oph.vkt.model.EnrollmentAppointment;
import fi.oph.vkt.model.ExamEvent;
import fi.oph.vkt.model.Examiner;
import fi.oph.vkt.model.FeatureFlag;
import fi.oph.vkt.model.FreeEnrollment;
import fi.oph.vkt.model.Person;
Expand All @@ -31,6 +32,7 @@
import fi.oph.vkt.repository.EnrollmentAppointmentRepository;
import fi.oph.vkt.repository.EnrollmentRepository;
import fi.oph.vkt.repository.ExamEventRepository;
import fi.oph.vkt.repository.ExaminerRepository;
import fi.oph.vkt.repository.FreeEnrollmentRepository;
import fi.oph.vkt.repository.ReservationRepository;
import fi.oph.vkt.repository.UploadedFileAttachmentRepository;
Expand Down Expand Up @@ -68,6 +70,7 @@ public class PublicEnrollmentService extends AbstractEnrollmentService {
private final FeatureFlagService featureFlagService;
private final UploadedFileAttachmentRepository uploadedFileAttachmentRepository;
private final KoskiService koskiService;
private final ExaminerRepository examinerRepository;

@Transactional
public PublicEnrollmentInitialisationDTO initialiseEnrollment(final long examEventId, final Person person) {
Expand Down Expand Up @@ -678,10 +681,12 @@ public PublicEnrollmentAppointmentDTO saveEnrollmentAppointment(
return createEnrollmentAppointmentDTO(enrollmentAppointment);
}

public void createEnrollmentContact(final PublicEnrollmentContactCreateDTO dto) {
public void createEnrollmentContact(final PublicEnrollmentContactCreateDTO dto, final long examinerId) {
final EnrollmentAppointment enrollmentAppointment = new EnrollmentAppointment();
final Examiner examiner = examinerRepository.getReferenceById(examinerId);

enrollmentAppointment.setStatus(EnrollmentAppointmentStatus.CONTACT_CREATED);
enrollmentAppointment.setExaminer(examiner);
copyDtoFieldsToEnrollment(enrollmentAppointment, dto);

enrollmentAppointmentRepository.saveAndFlush(enrollmentAppointment);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import fi.oph.vkt.repository.EnrollmentAppointmentRepository;
import fi.oph.vkt.repository.EnrollmentRepository;
import fi.oph.vkt.repository.ExamEventRepository;
import fi.oph.vkt.repository.ExaminerRepository;
import fi.oph.vkt.repository.FreeEnrollmentRepository;
import fi.oph.vkt.repository.ReservationRepository;
import fi.oph.vkt.repository.UploadedFileAttachmentRepository;
Expand Down Expand Up @@ -90,6 +91,9 @@ public class PublicEnrollmentServiceTest {
@Resource
private UploadedFileAttachmentRepository uploadedFileAttachmentRepository;

@Resource
private ExaminerRepository examinerRepository;

@BeforeEach
public void setup() throws IOException, InterruptedException {
doNothing().when(publicEnrollmentEmailServiceMock).sendEnrollmentToQueueConfirmationEmail(any(), any());
Expand All @@ -116,7 +120,8 @@ public void setup() throws IOException, InterruptedException {
s3Service,
featureFlagService,
uploadedFileAttachmentRepository,
koskiService
koskiService,
examinerRepository
);
}

Expand Down

0 comments on commit f5fc165

Please sign in to comment.