From c6fd61863b3265fa4f084ba6ad9321beeb2eb3b2 Mon Sep 17 00:00:00 2001 From: arybakov Date: Thu, 26 Oct 2023 11:36:04 -0600 Subject: [PATCH 1/3] GRAD2-2361 Updated date on Student GRAD Status page defaulting to today's date regardless of when student record has been last updated --- .../gradstudent/model/entity/BaseEntity.java | 27 +++++++------------ .../GraduationStatusTransformer.java | 5 ++-- ...uationStudentRecordHistoryTransformer.java | 5 ++-- 3 files changed, 14 insertions(+), 23 deletions(-) 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 4210e389..d3b957bd 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 @@ -1,20 +1,13 @@ package ca.bc.gov.educ.api.gradstudent.model.entity; -import java.util.Date; - -import jakarta.persistence.Column; -import jakarta.persistence.MappedSuperclass; -import jakarta.persistence.PrePersist; -import jakarta.persistence.PreUpdate; -import jakarta.persistence.Temporal; -import jakarta.persistence.TemporalType; - +import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants; import ca.bc.gov.educ.api.gradstudent.util.ThreadLocalStateUtil; +import jakarta.persistence.*; +import lombok.Data; import org.apache.commons.lang3.StringUtils; import org.springframework.format.annotation.DateTimeFormat; -import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiConstants; -import lombok.Data; +import java.time.LocalDateTime; @Data @MappedSuperclass @@ -25,7 +18,7 @@ public class BaseEntity { @Column(name = "CREATE_DATE", columnDefinition="datetime",nullable = false) @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-mm-dd hh:mm:ss") - private Date createDate; + private LocalDateTime createDate; @Column(name = "UPDATE_USER", nullable = false) @@ -34,7 +27,7 @@ public class BaseEntity { @Column(name = "UPDATE_DATE", columnDefinition="datetime",nullable = true) @Temporal(TemporalType.TIMESTAMP) @DateTimeFormat(pattern = "yyyy-mm-dd hh:mm:ss") - private Date updateDate; + private LocalDateTime updateDate; @PrePersist protected void onCreate() { @@ -50,14 +43,14 @@ protected void onCreate() { this.updateUser = EducGradStudentApiConstants.DEFAULT_UPDATED_BY; } } - this.createDate = new Date(System.currentTimeMillis()); - this.updateDate = new Date(System.currentTimeMillis()); + this.createDate = LocalDateTime.now(); + this.updateDate = LocalDateTime.now(); } @PreUpdate protected void onPersist() { - this.updateDate = new Date(); + this.updateDate = LocalDateTime.now(); if (StringUtils.isBlank(updateUser)) { this.updateUser = ThreadLocalStateUtil.getCurrentUser(); if (StringUtils.isBlank(updateUser)) { @@ -71,7 +64,7 @@ protected void onPersist() { } } if (this.createDate == null) { - this.createDate = new Date(); + this.createDate = LocalDateTime.now(); } } } diff --git a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java index e91ae9d8..93af1623 100644 --- a/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java +++ b/api/src/main/java/ca/bc/gov/educ/api/gradstudent/model/transformer/GraduationStatusTransformer.java @@ -5,7 +5,6 @@ import ca.bc.gov.educ.api.gradstudent.model.dto.GraduationStudentRecordDistribution; import ca.bc.gov.educ.api.gradstudent.model.dto.ProjectedRunClob; import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordEntity; -import ca.bc.gov.educ.api.gradstudent.util.DateUtils; import ca.bc.gov.educ.api.gradstudent.util.EducGradStudentApiUtils; import ca.bc.gov.educ.api.gradstudent.util.GradValidation; import com.fasterxml.jackson.core.JsonProcessingException; @@ -129,8 +128,8 @@ public List tToDForBatch(Iterable transformToDTO (Iterable Date: Thu, 26 Oct 2023 11:47:33 -0600 Subject: [PATCH 2/3] GRAD2-2361 Updated date on Student GRAD Status page defaulting to today's date regardless of when student record has been last updated --- .../service/CommonServiceTest.java | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java index 84de4a42..16db484a 100644 --- a/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java +++ b/api/src/test/java/ca/bc/gov/educ/api/gradstudent/service/CommonServiceTest.java @@ -202,14 +202,14 @@ public void testGetAllStudentNotes() { note1.setId(UUID.randomUUID()); note1.setStudentID(studentID); note1.setNote("Test1 Comments"); - note1.setUpdateDate(new Date()); + note1.setUpdateDate(LocalDateTime.now()); allNotesList.add(note1); final StudentRecordNoteEntity note2 = new StudentRecordNoteEntity(); note2.setId(UUID.randomUUID()); note2.setStudentID(studentID); note2.setNote("Test2 Comments"); - note2.setUpdateDate(new Date( + 100000L)); + note2.setUpdateDate(LocalDateTime.now()); allNotesList.add(note2); when(studentNoteRepository.findByStudentID(studentID)).thenReturn(allNotesList); @@ -315,16 +315,16 @@ public void testGetAllStudentStatusCodeList() { obj.setDescription("Data Correction by School"); obj.setCreateUser("GRADUATION"); obj.setUpdateUser("GRADUATION"); - obj.setCreateDate(new Date()); - obj.setUpdateDate(new Date()); + obj.setCreateDate(LocalDateTime.now()); + obj.setUpdateDate(LocalDateTime.now()); gradStudentStatusList.add(obj); obj = new StudentStatusEntity(); obj.setCode("CC"); obj.setDescription("Courses not complete"); obj.setCreateUser("GRADUATION"); obj.setUpdateUser("GRADUATION"); - obj.setCreateDate(new Date()); - obj.setUpdateDate(new Date()); + obj.setCreateDate(LocalDateTime.now()); + obj.setUpdateDate(LocalDateTime.now()); gradStudentStatusList.add(obj); Mockito.when(studentStatusRepository.findAll()).thenReturn(gradStudentStatusList); List result = commonService.getAllStudentStatusCodeList(); @@ -346,8 +346,8 @@ public void testGetSpecificStudentStatusCode() { objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(studentStatusRepository.findById(reasonCode)).thenReturn(ent); StudentStatus result = commonService.getSpecificStudentStatusCode(reasonCode); @@ -376,8 +376,8 @@ public void testCreateStudentStatus() { objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(Optional.empty()); Mockito.when(studentStatusRepository.save(objEntity)).thenReturn(objEntity); StudentStatus result = commonService.createStudentStatus(obj); @@ -399,8 +399,8 @@ public void testCreateStudentStatus_codeAlreadyExists() { objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(ent); StudentStatus result = commonService.createStudentStatus(obj); @@ -422,8 +422,8 @@ public void testUpdateStudentStatus() { objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(ent); Mockito.when(studentStatusRepository.save(objEntity)).thenReturn(objEntity); @@ -444,7 +444,7 @@ public void testUpdateStudentStatus_noCreatedUpdatedByData() { objEntity.setCode("DC"); objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(ent); Mockito.when(studentStatusRepository.save(objEntity)).thenReturn(objEntity); @@ -466,8 +466,8 @@ public void testUpdateStudentStatus_codeAlreadyExists() { objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(Optional.empty()); StudentStatus result = commonService.updateStudentStatus(obj); assertThat(result).isNotNull(); @@ -492,8 +492,8 @@ private StudentStatusEntity createStudentStatuses() { objEntity.setDescription("Active"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); return objEntity; } @@ -505,16 +505,16 @@ public void testGetAllHistoryActivityCodeList() { obj.setDescription("Data Correction by School"); obj.setCreateUser("GRADUATION"); obj.setUpdateUser("GRADUATION"); - obj.setCreateDate(new Date()); - obj.setUpdateDate(new Date()); + obj.setCreateDate(LocalDateTime.now()); + obj.setUpdateDate(LocalDateTime.now()); gradHistoryActivityList.add(obj); obj = new HistoryActivityCodeEntity(); obj.setCode("CC"); obj.setDescription("Courses not complete"); obj.setCreateUser("GRADUATION"); obj.setUpdateUser("GRADUATION"); - obj.setCreateDate(new Date()); - obj.setUpdateDate(new Date()); + obj.setCreateDate(LocalDateTime.now()); + obj.setUpdateDate(LocalDateTime.now()); gradHistoryActivityList.add(obj); Mockito.when(historyActivityRepository.findAll()).thenReturn(gradHistoryActivityList); commonService.getAllHistoryActivityCodeList(); @@ -535,8 +535,8 @@ public void testGetSpecificHistoryActivityCode() { objEntity.setDescription("Data Correction by School"); objEntity.setCreateUser("GRADUATION"); objEntity.setUpdateUser("GRADUATION"); - objEntity.setCreateDate(new Date()); - objEntity.setUpdateDate(new Date()); + objEntity.setCreateDate(LocalDateTime.now()); + objEntity.setUpdateDate(LocalDateTime.now()); Optional ent = Optional.of(objEntity); Mockito.when(historyActivityRepository.findById(reasonCode)).thenReturn(ent); commonService.getSpecificHistoryActivityCode(reasonCode); From 62ae977663f9a2b842d3976e75b665ed5d2afa0f Mon Sep 17 00:00:00 2001 From: Kamal Mohammed Date: Fri, 17 Nov 2023 00:28:21 +0530 Subject: [PATCH 3/3] Update pom.xml --- api/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/pom.xml b/api/pom.xml index 6aa798c5..0a9923ca 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -6,7 +6,7 @@ ca.bc.gov.educ educ-grad-student-api - 1.8.48 + 1.8.51 educ-grad-student-api Student Demographics API for GRAD team