diff --git a/.github/dependabot.yml b/.github/dependabot.yml
index 0d28b300..56e573e7 100644
--- a/.github/dependabot.yml
+++ b/.github/dependabot.yml
@@ -10,3 +10,7 @@ updates:
schedule:
interval: "daily"
target-branch: "grad-release"
+ - package-ecosystem: "github-actions"
+ directory: "/"
+ schedule:
+ interval: "weekly"
\ No newline at end of file
diff --git a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
index 22c39ee3..bb941421 100644
--- a/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.developer.branch.deploy.to.dev.yml
@@ -155,6 +155,6 @@ jobs:
# now hit it with a zap scan
- name: ZAP Scan
- uses: zaproxy/action-api-scan@v0.7.0
+ uses: zaproxy/action-api-scan@v0.9.0
with:
target: 'https://${{ env.REPO_NAME }}-${{ env.OPENSHIFT_NAMESPACE }}.apps.silver.devops.gov.bc.ca/api/v1/api-docs'
diff --git a/.github/workflows/build.from.main.branch.deploy.to.dev.yml b/.github/workflows/build.from.main.branch.deploy.to.dev.yml
index 6401fef0..af04a1ad 100644
--- a/.github/workflows/build.from.main.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.main.branch.deploy.to.dev.yml
@@ -137,6 +137,6 @@ jobs:
# now hit it with a zap scan
- name: ZAP Scan
- uses: zaproxy/action-api-scan@v0.7.0
+ uses: zaproxy/action-api-scan@v0.9.0
with:
target: 'https://${{ env.REPO_NAME }}-${{ env.OPENSHIFT_NAMESPACE }}.apps.silver.devops.gov.bc.ca/api/v1/api-docs'
\ No newline at end of file
diff --git a/.github/workflows/build.from.release.branch.deploy.to.dev.yml b/.github/workflows/build.from.release.branch.deploy.to.dev.yml
index 2b49b449..2398ea31 100644
--- a/.github/workflows/build.from.release.branch.deploy.to.dev.yml
+++ b/.github/workflows/build.from.release.branch.deploy.to.dev.yml
@@ -144,6 +144,6 @@ jobs:
# now hit it with a zap scan
- name: ZAP Scan
- uses: zaproxy/action-api-scan@v0.7.0
+ uses: zaproxy/action-api-scan@v0.9.0
with:
target: 'https://${{ env.REPO_NAME }}-${{ env.OPENSHIFT_NAMESPACE }}.apps.silver.devops.gov.bc.ca/api/v1/api-docs'
\ No newline at end of file
diff --git a/api/pom.xml b/api/pom.xml
index d2900d12..0e9215c7 100644
--- a/api/pom.xml
+++ b/api/pom.xml
@@ -6,7 +6,7 @@
ca.bc.gov.educ
educ-grad-student-api
- 1.8.67
+ 1.8.69
educ-grad-student-api
Student Demographics API for GRAD team
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/config/RequestInterceptor.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/config/RequestInterceptor.java
index e2e2d238..9177a1c6 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/config/RequestInterceptor.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/config/RequestInterceptor.java
@@ -42,13 +42,10 @@ public boolean preHandle(HttpServletRequest request, HttpServletResponse respons
// username
Authentication auth = SecurityContextHolder.getContext().getAuthentication();
- if (auth instanceof JwtAuthenticationToken) {
- JwtAuthenticationToken authenticationToken = (JwtAuthenticationToken) auth;
+ if (auth instanceof JwtAuthenticationToken authenticationToken) {
Jwt jwt = (Jwt) authenticationToken.getCredentials();
- String username = JwtUtil.getName(jwt);
- if (username != null) {
- ThreadLocalStateUtil.setCurrentUser(username);
- }
+ String username = JwtUtil.getName(jwt, request);
+ ThreadLocalStateUtil.setCurrentUser(username);
}
return true;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/constant/TraxEventType.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/constant/TraxEventType.java
index 81724cc4..19334f90 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/constant/TraxEventType.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/constant/TraxEventType.java
@@ -10,7 +10,6 @@ public enum TraxEventType {
NEWSTUDENT,
UPD_DEMOG,
UPD_GRAD,
- UPD_STD_STATUS,
XPROGRAM,
ASSESSMENT,
COURSE,
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecord.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecord.java
index 8715ec35..6d81b064 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecord.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/dto/GraduationStudentRecord.java
@@ -27,7 +27,7 @@ public class GraduationStudentRecord extends BaseModel {
private String schoolOfRecord;
private UUID schoolOfRecordId;
private String schoolName;
- private String studentGrade;
+ private String studentGrade;
private String studentStatus;
private String studentStatusName;
private UUID studentID;
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java
index ae1bfc7b..6c6d2b59 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/entity/BaseEntity.java
@@ -70,5 +70,8 @@ protected void onPersist() {
if (this.createDate == null) {
this.createDate = LocalDateTime.now();
}
+ if(this.updateDate == null) {
+ this.updateDate = LocalDateTime.now();
+ }
}
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java
index 90816cbf..7a83c5c2 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/repository/GraduationStudentRecordHistoryRepository.java
@@ -140,4 +140,60 @@ INSERT INTO GRADUATION_STUDENT_RECORD_HISTORY (
@Query(value= INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_BATCH_ID_AND_STUDENT_ID_IN_SQL, nativeQuery=true)
Integer insertGraduationStudentRecordHistoryByBatchIdAndStudentIDs(@Param(value = "batchId") Long batchId, @Param(value = "studentIDs") List studentIDs, @Param(value = "activityCode") String activityCode, @Param(value = "updateUser") String updateUser);
+ String INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_STUDENT_ID_IN_SQL = """
+ INSERT INTO GRADUATION_STUDENT_RECORD_HISTORY (
+ GRADUATION_STUDENT_RECORD_HISTORY_ID,
+ HISTORY_ACTIVITY_CODE,
+ GRADUATION_STUDENT_RECORD_ID,
+ GRADUATION_PROGRAM_CODE,
+ GPA,
+ STUDENT_STATUS_CODE,
+ HONOURS_STANDING,
+ PROGRAM_COMPLETION_DATE,
+ RECALCULATE_GRAD_STATUS,
+ SCHOOL_OF_RECORD,
+ STUDENT_GRADE,
+ SCHOOL_AT_GRADUATION,
+ CREATE_USER,
+ CREATE_DATE,
+ UPDATE_USER,
+ UPDATE_DATE,
+ RECALCULATE_PROJECTED_GRAD,
+ BATCH_ID,
+ CONSUMER_EDUC_REQT_MET,
+ STUDENT_CITIZENSHIP_CODE,
+ ADULT_START_DATE,
+ SCHOOL_OF_RECORD_ID,
+ SCHOOL_AT_GRADUATION_ID
+ ) SELECT
+ SYS_GUID(),
+ :activityCode,
+ GRADUATION_STUDENT_RECORD_ID,
+ GRADUATION_PROGRAM_CODE,
+ GPA,
+ STUDENT_STATUS_CODE,
+ HONOURS_STANDING,
+ PROGRAM_COMPLETION_DATE,
+ RECALCULATE_GRAD_STATUS,
+ SCHOOL_OF_RECORD,
+ STUDENT_GRADE,
+ SCHOOL_AT_GRADUATION,
+ CREATE_USER,
+ CREATE_DATE,
+ UPDATE_USER,
+ SYSDATE,
+ RECALCULATE_PROJECTED_GRAD,
+ BATCH_ID,
+ CONSUMER_EDUC_REQT_MET,
+ STUDENT_CITIZENSHIP_CODE,
+ ADULT_START_DATE,
+ SCHOOL_OF_RECORD_ID,
+ SCHOOL_AT_GRADUATION_ID
+ FROM GRADUATION_STUDENT_RECORD
+ WHERE GRADUATION_STUDENT_RECORD_ID = :studentID
+ """;
+ @Modifying
+ @Query(value= INSERT_INTO_GRADUATION_STUDENT_RECORD_HISTORY_BY_STUDENT_ID_IN_SQL, nativeQuery=true)
+ Integer insertGraduationStudentRecordHistoryByStudentId(@Param(value = "studentID") UUID studentID, @Param(value = "activityCode") String activityCode);
+
}
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java
index f5ceee17..f99a0749 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionService.java
@@ -120,8 +120,13 @@ public GraduationStudentRecord updateGraduationStatusByFields(OngoingUpdateReque
gradEntity.setUpdateDate(null);
gradEntity.setUpdateUser(null);
validateStudentStatusAndResetBatchFlags(gradEntity);
- gradEntity = graduationStatusRepository.saveAndFlush(gradEntity);
- historyService.createStudentHistory(gradEntity, UPDATE_ONGOING_HISTORY_ACTIVITY_CODE);
+ if (isBatchFlagUpdatesOnly(eventType)) {
+ gradEntity = saveBatchFlagsWithAuditHistory(gradEntity.getStudentID(), gradEntity.getRecalculateGradStatus(),
+ gradEntity.getRecalculateProjectedGrad(), UPDATE_ONGOING_HISTORY_ACTIVITY_CODE);
+ } else {
+ gradEntity = graduationStatusRepository.saveAndFlush(gradEntity);
+ historyService.createStudentHistory(gradEntity, UPDATE_ONGOING_HISTORY_ACTIVITY_CODE);
+ }
if (constants.isStudentGuidPenXrefEnabled() && StringUtils.isNotBlank(requestDTO.getPen())) {
saveStudentGuidPenXref(gradEntity.getStudentID(), requestDTO.getPen());
}
@@ -130,6 +135,10 @@ public GraduationStudentRecord updateGraduationStatusByFields(OngoingUpdateReque
return null;
}
+ private boolean isBatchFlagUpdatesOnly(TraxEventType eventType) {
+ return TraxEventType.NEWSTUDENT != eventType && TraxEventType.UPD_GRAD != eventType;
+ }
+
@Transactional
@Retry(name = "generalpostcall")
public StudentOptionalProgram saveStudentOptionalProgram(StudentOptionalProgramRequestDTO studentOptionalProgramReq, String accessToken) {
@@ -214,6 +223,15 @@ private void saveStudentGuidPenXref(UUID studentId, String pen) {
}
}
+ /**
+ * Update Batch Flags in Graduation Status for Ongoing Updates
+ */
+ private GraduationStudentRecordEntity saveBatchFlagsWithAuditHistory(UUID studentID, String recalculateGradStatus, String recalculateProjectedGrad, String historyActivityCode) {
+ graduationStatusRepository.updateGradStudentRecalculationAllFlags(studentID, recalculateGradStatus, recalculateProjectedGrad);
+ gradStudentRecordHistoryRepository.insertGraduationStudentRecordHistoryByStudentId(studentID, historyActivityCode);
+ return graduationStatusRepository.findByStudentID(studentID);
+ }
+
@Transactional
public void deleteGraduationStatus(UUID studentID) {
// graduation_student_record
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java
index a2e6a765..c0173e35 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/service/GraduationStatusService.java
@@ -41,7 +41,6 @@
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.concurrent.*;
-import java.util.stream.Collectors;
import static ca.bc.gov.educ.api.gradstudent.constant.EventStatus.DB_COMMITTED;
@@ -82,16 +81,15 @@ public class GraduationStatusService extends GradBaseService {
final HistoryService historyService;
final GradValidation validation;
final EducGradStudentApiConstants constants;
+ final GraduationStudentRecordSearchRepository graduationStudentRecordSearchRepository;
@Autowired
- GraduationStudentRecordSearchRepository graduationStudentRecordSearchRepository;
-
- @Autowired
- public GraduationStatusService(WebClient webClient, GraduationStudentRecordRepository graduationStatusRepository, StudentStatusRepository studentStatusRepository, GradStatusEventRepository gradStatusEventRepository, StudentNonGradReasonRepository studentNonGradReasonRepository, GraduationStatusTransformer graduationStatusTransformer, StudentOptionalProgramRepository gradStudentOptionalProgramRepository, GradStudentOptionalProgramTransformer gradStudentOptionalProgramTransformer, StudentCareerProgramRepository gradStudentCareerProgramRepository, GradStudentCareerProgramTransformer gradStudentCareerProgramTransformer, StudentNonGradReasonTransformer studentNonGradReasonTransformer, GradStudentService gradStudentService, HistoryService historyService, GradValidation validation, EducGradStudentApiConstants constants) {
+ public GraduationStatusService(WebClient webClient, GraduationStudentRecordRepository graduationStatusRepository, StudentStatusRepository studentStatusRepository, GradStatusEventRepository gradStatusEventRepository, StudentNonGradReasonRepository studentNonGradReasonRepository, GraduationStatusTransformer graduationStatusTransformer, StudentOptionalProgramRepository gradStudentOptionalProgramRepository, GraduationStudentRecordSearchRepository graduationStudentRecordSearchRepository, GradStudentOptionalProgramTransformer gradStudentOptionalProgramTransformer, StudentCareerProgramRepository gradStudentCareerProgramRepository, GradStudentCareerProgramTransformer gradStudentCareerProgramTransformer, StudentNonGradReasonTransformer studentNonGradReasonTransformer, GradStudentService gradStudentService, HistoryService historyService, GradValidation validation, EducGradStudentApiConstants constants) {
this.webClient = webClient;
this.graduationStatusRepository = graduationStatusRepository;
this.studentStatusRepository = studentStatusRepository;
this.gradStatusEventRepository = gradStatusEventRepository;
+ this.graduationStudentRecordSearchRepository = graduationStudentRecordSearchRepository;
this.graduationStatusTransformer = graduationStatusTransformer;
this.gradStudentOptionalProgramRepository = gradStudentOptionalProgramRepository;
this.gradStudentOptionalProgramTransformer = gradStudentOptionalProgramTransformer;
@@ -202,7 +200,7 @@ public Pair saveGraduationStatus(UUID
if(batchId != null) {
resetBatchFlags(gradEntity, false);
}
-
+ gradEntity.setUpdateUser(null);
gradEntity = graduationStatusRepository.saveAndFlush(gradEntity);
historyService.createStudentHistory(gradEntity, GRAD_ALG);
final GradStatusEvent gradStatusEvent = createGradStatusEvent(gradEntity.getUpdateUser(), gradEntity,
@@ -399,8 +397,8 @@ public GraduationStudentRecordSearchResult searchGraduationStudentRecords(final
Specification spec = new GraduationStudentRecordSearchSpecification(searchCriteria);
List results = graduationStudentRecordSearchRepository.findAll(Specification.where(spec));
List students = new ArrayList<>();
- if (results != null && !results.isEmpty()) {
- students = results.stream().map(GraduationStudentRecordSearchEntity::getStudentID).collect(Collectors.toList());
+ if (!results.isEmpty()) {
+ students = results.stream().map(GraduationStudentRecordSearchEntity::getStudentID).toList();
}
searchResult.setStudentIDs(students);
return searchResult;
@@ -1102,6 +1100,7 @@ public Pair undoCompletionStudent(UUID
gradEntity.setGpa(null);
gradEntity.setSchoolAtGrad(null);
gradEntity.setUpdateUser(null);
+ gradEntity.setUpdateDate(null);
gradEntity = graduationStatusRepository.save(gradEntity);
historyService.createStudentHistory(gradEntity, USER_UNDO_CMPL);
final GradStatusEvent gradStatusEvent = createGradStatusEvent(gradEntity.getUpdateUser(), gradEntity,
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
index d0bb9a53..31d1a532 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/EducGradStudentApiConstants.java
@@ -15,6 +15,7 @@ public class EducGradStudentApiConstants {
public static final String API_NAME = "GRAD-STUDENT-API";
public static final String STREAM_NAME="GRAD_STATUS_EVENT_STREAM";
public static final String CORRELATION_ID = "correlationID";
+ public static final String USERNAME = "username";
//API end-point Mapping constants
public static final String API_ROOT_MAPPING = "";
diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/JwtUtil.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/JwtUtil.java
index 49984fb2..dff3287d 100644
--- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/JwtUtil.java
+++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/util/JwtUtil.java
@@ -1,5 +1,7 @@
package ca.bc.gov.educ.api.gradstudent.util;
+import jakarta.servlet.http.HttpServletRequest;
+import lombok.val;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.oauth2.jwt.Jwt;
@@ -54,6 +56,38 @@ public static String getName(Jwt jwt) {
return sb.toString();
}
+ /**
+ * Gets name string
+ * => If it is service account, get it from request header. Otherwise, get it from jwt
+ *
+ * @param jwt the JWT
+ * @param request the Request Header
+ * @return the username string
+ */
+ public static String getName(Jwt jwt, HttpServletRequest request) {
+ StringBuilder sb = new StringBuilder();
+ if (isServiceAccount(jwt.getClaims())) {
+ sb.append(getUserNameString(request));
+ } else {
+ String givenName = (String) jwt.getClaims().get("given_name");
+ if (StringUtils.isNotBlank(givenName)) {
+ sb.append(givenName.charAt(0));
+ }
+ String familyName = (String) jwt.getClaims().get("family_name");
+ sb.append(familyName);
+ }
+ return sb.toString();
+ }
+
+ private static String getUserNameString(HttpServletRequest request) {
+ val username = request.getHeader(EducGradStudentApiConstants.USERNAME);
+ if (StringUtils.isNotBlank(username)) {
+ return username;
+ } else {
+ return "Batch Process";
+ }
+ }
+
private static boolean isServiceAccount(Map claims) {
return !claims.containsKey("family_name");
}
diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionServiceTest.java
index 9b51cf96..d99bdd39 100644
--- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionServiceTest.java
+++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/DataConversionServiceTest.java
@@ -289,7 +289,7 @@ public void testGraduationStudentRecordAsOngoingUpdateForStudentStatus() {
OngoingUpdateRequestDTO requestDTO = new OngoingUpdateRequestDTO();
requestDTO.setPen(pen);
requestDTO.setStudentID(studentID.toString());
- requestDTO.setEventType(TraxEventType.UPD_STD_STATUS);
+ requestDTO.setEventType(TraxEventType.UPD_GRAD);
OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder()
.type(FieldType.STRING).name(FieldName.STUDENT_STATUS).value(newStatus)
@@ -322,6 +322,68 @@ public void testGraduationStudentRecordAsOngoingUpdateForStudentStatus() {
assertThat(result.getRecalculateGradStatus()).isNull();
}
+ @Test
+ public void testGraduationStudentRecordAsOngoingUpdateForBatchFlags() {
+ // ID
+ UUID studentID = UUID.randomUUID();
+ String pen = "123456789";
+ String mincode = "12345678";
+
+ GraduationStudentRecordEntity graduationStatusEntity = new GraduationStudentRecordEntity();
+ graduationStatusEntity.setStudentID(studentID);
+ graduationStatusEntity.setPen(pen);
+ graduationStatusEntity.setStudentStatus("CUR");
+ graduationStatusEntity.setRecalculateGradStatus(null);
+ graduationStatusEntity.setRecalculateProjectedGrad("Y");
+ graduationStatusEntity.setProgram("2018-EN");
+ graduationStatusEntity.setSchoolOfRecord(mincode);
+ graduationStatusEntity.setSchoolAtGrad(mincode);
+ graduationStatusEntity.setGpa("4");
+ graduationStatusEntity.setProgramCompletionDate(new Date(System.currentTimeMillis()));
+
+ OngoingUpdateRequestDTO requestDTO = new OngoingUpdateRequestDTO();
+ requestDTO.setPen(pen);
+ requestDTO.setStudentID(studentID.toString());
+ requestDTO.setEventType(TraxEventType.COURSE);
+
+ OngoingUpdateFieldDTO field1 = OngoingUpdateFieldDTO.builder()
+ .type(FieldType.STRING).name(FieldName.RECALC_GRAD_ALG).value("Y")
+ .build();
+ requestDTO.getUpdateFields().add(field1);
+
+ OngoingUpdateFieldDTO field2 = OngoingUpdateFieldDTO.builder()
+ .type(FieldType.STRING).name(FieldName.RECALC_TVR).value("NULL")
+ .build();
+ requestDTO.getUpdateFields().add(field2);
+
+ GraduationStudentRecordEntity savedGraduationStatus = new GraduationStudentRecordEntity();
+ BeanUtils.copyProperties(graduationStatusEntity, savedGraduationStatus);
+ savedGraduationStatus.setRecalculateGradStatus("Y");
+ savedGraduationStatus.setRecalculateProjectedGrad(null);
+
+ when(graduationStatusRepository.findById(studentID)).thenReturn(Optional.of(graduationStatusEntity));
+ when(graduationStatusRepository.findByStudentID(studentID)).thenReturn(savedGraduationStatus);
+ when(graduationStatusRepository.saveAndFlush(graduationStatusEntity)).thenReturn(savedGraduationStatus);
+
+ when(this.webClient.delete()).thenReturn(this.requestHeadersUriMock);
+ when(this.requestHeadersUriMock.uri(String.format(constants.getDeleteStudentAchievements(),studentID))).thenReturn(this.requestHeadersMock);
+ when(this.requestHeadersMock.headers(any(Consumer.class))).thenReturn(this.requestBodyMock);
+ when(this.requestBodyMock.retrieve()).thenReturn(this.responseMock);
+ when(this.responseMock.bodyToMono(Integer.class)).thenReturn(Mono.just(0));
+
+ var result = dataConversionService.updateGraduationStatusByFields(requestDTO, "accessToken");
+
+ assertThat(result).isNotNull();
+ assertThat(result.getStudentID()).isEqualTo(graduationStatusEntity.getStudentID());
+ assertThat(result.getPen()).isEqualTo(graduationStatusEntity.getPen());
+
+ assertThat(result.getSchoolOfRecord()).isEqualTo(graduationStatusEntity.getSchoolOfRecord());
+ assertThat(result.getGpa()).isEqualTo(graduationStatusEntity.getGpa());
+
+ assertThat(result.getRecalculateGradStatus()).isEqualTo("Y");
+ assertThat(result.getRecalculateProjectedGrad()).isNull();
+ }
+
@Test
public void testGraduationStudentRecordAsOngoingUpdateForStudentMergedStatus() {
// ID
@@ -345,7 +407,7 @@ public void testGraduationStudentRecordAsOngoingUpdateForStudentMergedStatus() {
OngoingUpdateRequestDTO requestDTO = new OngoingUpdateRequestDTO();
requestDTO.setPen(pen);
requestDTO.setStudentID(studentID.toString());
- requestDTO.setEventType(TraxEventType.UPD_STD_STATUS);
+ requestDTO.setEventType(TraxEventType.UPD_GRAD);
OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder()
.type(FieldType.STRING).name(FieldName.STUDENT_STATUS).value(newStatus)
@@ -407,7 +469,7 @@ public void testGraduationStudentRecordAsOngoingUpdateForStudentArchivedStatus()
OngoingUpdateRequestDTO requestDTO = new OngoingUpdateRequestDTO();
requestDTO.setPen(pen);
requestDTO.setStudentID(studentID.toString());
- requestDTO.setEventType(TraxEventType.UPD_STD_STATUS);
+ requestDTO.setEventType(TraxEventType.UPD_GRAD);
OngoingUpdateFieldDTO field = OngoingUpdateFieldDTO.builder()
.type(FieldType.STRING).name(FieldName.STUDENT_STATUS).value(newStatus)