From 395ffc35f5bf6e9d27957ba59648c3c4ceabf6c2 Mon Sep 17 00:00:00 2001 From: arybakov Date: Wed, 1 May 2024 09:42:08 -0600 Subject: [PATCH] GRAD2-2579 Fix testing errors --- .../report/service/CommonServiceTest.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java index 80e6f806..11e1eeb6 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/grad/report/service/CommonServiceTest.java @@ -903,9 +903,13 @@ public void testGetStudentCredentialsForUserRequestDisRun_OC() { when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); Mockito.when(gradStudentCertificatesRepository.findRecordsWithNullDistributionDateForUserRequest(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentCertificatesRepository.findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); Mockito.when(gradStudentCertificatesRepository.findRecordsForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentCertificatesRepository.findRecordsForUserRequest(studentList)).thenReturn(scdSubList); Mockito.when(gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequest(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentTranscriptsRepository.findRecordsForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); Mockito.when(gradStudentTranscriptsRepository.findRecordsForUserRequest(studentList)).thenReturn(scdSubList); List result = commonService.getStudentCredentialsForUserRequestDisRun(credentialType,new StudentSearchRequest(),false,null); @@ -913,6 +917,54 @@ public void testGetStudentCredentialsForUserRequestDisRun_OC() { } + @Test + public void testGetStudentCredentialsForUserRequestDisRun_OC_SearchRequest() { + + GraduationStudentRecordSearchResult res = new GraduationStudentRecordSearchResult(); + + List studList= new ArrayList<>(); + GraduationStudentRecord rec = new GraduationStudentRecord(); + rec.setLegalFirstName("asda"); + rec.setStudentID(new UUID(1,1)); + studList.add(rec.getStudentID()); + res.setStudentIDs(studList); + + List scdSubList = new ArrayList<>(); + StudentCredentialDistribution scdSub = new StudentCredentialDistribution(new UUID(4,4),"E",new UUID(5,5),"YED4","COMPL", new Date()); + scdSubList.add(scdSub); + + List studentList = new ArrayList<>(); + studentList.add(new UUID(1,1)); + + when(this.webClient.post()).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.uri(constants.getGradStudentApiStudentForSpcGradListUrl())).thenReturn(this.requestBodyUriMock); + when(this.requestBodyUriMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock); + when(this.requestBodyMock.body(any(BodyInserter.class))).thenReturn(this.requestHeadersMock); + when(this.requestHeadersMock.retrieve()).thenReturn(this.responseMock); + when(this.responseMock.bodyToMono(GraduationStudentRecordSearchResult.class)).thenReturn(Mono.just(res)); + + StudentSearchRequest searchRequest = new StudentSearchRequest(); + searchRequest.setPens(new ArrayList<>()); + searchRequest.getPens().add("12345678"); + + Mockito.when(gradStudentCertificatesRepository.findRecordsWithNullDistributionDateForUserRequest(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentCertificatesRepository.findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentCertificatesRepository.findRecordsForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentCertificatesRepository.findRecordsForUserRequest(studentList)).thenReturn(scdSubList); + + Mockito.when(gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequest(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentTranscriptsRepository.findRecordsWithNullDistributionDateForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentTranscriptsRepository.findRecordsForUserRequestByStudentIdOnly(studentList)).thenReturn(scdSubList); + Mockito.when(gradStudentTranscriptsRepository.findRecordsForUserRequest(studentList)).thenReturn(scdSubList); + + List result = commonService.getStudentCredentialsForUserRequestDisRun("OC",searchRequest,true,"accessToken"); + assertThat(result).isNotEmpty(); + + result = commonService.getStudentCredentialsForUserRequestDisRun("OT",searchRequest,false,"accessToken"); + assertThat(result).isNotEmpty(); + + } + @Test public void testGetStudentCredentialsForUserRequestDisRun_OC_with_Null_DistributionDate() {