Skip to content

Commit

Permalink
Grad release 1.10.0
Browse files Browse the repository at this point in the history
Grad release 1.10.0
  • Loading branch information
kamal-mohammed authored Nov 16, 2023
2 parents 89b6b32 + 62ae977 commit bde3541
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 49 deletions.
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ca.bc.gov.educ</groupId>
<artifactId>educ-grad-student-api</artifactId>
<version>1.8.48</version>
<version>1.8.51</version>
<name>educ-grad-student-api</name>
<description>Student Demographics API for GRAD team</description>

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
Expand All @@ -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() {
Expand All @@ -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)) {
Expand All @@ -71,7 +64,7 @@ protected void onPersist() {
}
}
if (this.createDate == null) {
this.createDate = new Date();
this.createDate = LocalDateTime.now();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -129,8 +128,8 @@ public List<GraduationStudentRecord> tToDForBatch(Iterable<GraduationStudentReco
populatePenAndLegalNamesAndNonGradReasons(gradStatus);
gradStatus.setStudentCitizenship(gradStatusEntity.getStudentCitizenship());
gradStatus.setStudentGradData(null);
gradStatus.setCreateDate(DateUtils.toLocalDateTime(gradStatusEntity.getCreateDate()));
gradStatus.setUpdateDate(DateUtils.toLocalDateTime(gradStatusEntity.getUpdateDate()));
gradStatus.setCreateDate((gradStatusEntity.getCreateDate()));
gradStatus.setUpdateDate((gradStatusEntity.getUpdateDate()));
gradStatusList.add(gradStatus);
}
return gradStatusList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import ca.bc.gov.educ.api.gradstudent.model.dto.GraduationStudentRecordHistory;
import ca.bc.gov.educ.api.gradstudent.model.entity.GraduationStudentRecordHistoryEntity;
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 org.modelmapper.ModelMapper;
Expand Down Expand Up @@ -45,8 +44,8 @@ public List<GraduationStudentRecordHistory> transformToDTO (Iterable<GraduationS
for (GraduationStudentRecordHistoryEntity graduationStudentRecordHistoryEntity : graduationStudentRecordHistoryEntities) {
GraduationStudentRecordHistory graduationStudentRecordHistory = modelMapper.map(graduationStudentRecordHistoryEntity, GraduationStudentRecordHistory.class);
graduationStudentRecordHistory.setProgramCompletionDate(EducGradStudentApiUtils.formatDate(graduationStudentRecordHistoryEntity.getProgramCompletionDate(), "yyyy/MM"));
graduationStudentRecordHistory.setCreateDate(DateUtils.toLocalDateTime(graduationStudentRecordHistoryEntity.getCreateDate()));
graduationStudentRecordHistory.setUpdateDate(DateUtils.toLocalDateTime(graduationStudentRecordHistoryEntity.getUpdateDate()));
graduationStudentRecordHistory.setCreateDate((graduationStudentRecordHistoryEntity.getCreateDate()));
graduationStudentRecordHistory.setUpdateDate((graduationStudentRecordHistoryEntity.getUpdateDate()));
graduationStudentRecordHistoryList.add(graduationStudentRecordHistory);
}
return graduationStudentRecordHistoryList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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<StudentStatus> result = commonService.getAllStudentStatusCodeList();
Expand All @@ -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<StudentStatusEntity> ent = Optional.of(objEntity);
Mockito.when(studentStatusRepository.findById(reasonCode)).thenReturn(ent);
StudentStatus result = commonService.getSpecificStudentStatusCode(reasonCode);
Expand Down Expand Up @@ -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);
Expand All @@ -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<StudentStatusEntity> ent = Optional.of(objEntity);
Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(ent);
StudentStatus result = commonService.createStudentStatus(obj);
Expand All @@ -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<StudentStatusEntity> ent = Optional.of(objEntity);
Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(ent);
Mockito.when(studentStatusRepository.save(objEntity)).thenReturn(objEntity);
Expand All @@ -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<StudentStatusEntity> ent = Optional.of(objEntity);
Mockito.when(studentStatusRepository.findById(obj.getCode())).thenReturn(ent);
Mockito.when(studentStatusRepository.save(objEntity)).thenReturn(objEntity);
Expand All @@ -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();
Expand All @@ -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;
}

Expand All @@ -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();
Expand All @@ -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<HistoryActivityCodeEntity> ent = Optional.of(objEntity);
Mockito.when(historyActivityRepository.findById(reasonCode)).thenReturn(ent);
commonService.getSpecificHistoryActivityCode(reasonCode);
Expand Down

0 comments on commit bde3541

Please sign in to comment.