diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/CollectionTypeCodeRepository.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/CollectionTypeCodeRepository.java index 14fda090d..f9cc2d2c6 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/CollectionTypeCodeRepository.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/repository/v1/CollectionTypeCodeRepository.java @@ -12,4 +12,5 @@ public interface CollectionTypeCodeRepository extends JpaRepository findAllByOpenDateBeforeAndEffectiveDateLessThanAndExpiryDateGreaterThan(LocalDateTime dateTime, LocalDateTime dateTimeGreat, LocalDateTime dateTimeLess); + List findAllByExpiryDateAfter(LocalDateTime now); } diff --git a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/CodeTableService.java b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/CodeTableService.java index 03308340f..baedbd70c 100644 --- a/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/CodeTableService.java +++ b/api/src/main/java/ca/bc/gov/educ/studentdatacollection/api/service/v1/CodeTableService.java @@ -6,6 +6,7 @@ import org.springframework.cache.annotation.Cacheable; import org.springframework.stereotype.Service; +import java.time.LocalDateTime; import java.util.List; import java.util.Optional; @@ -95,7 +96,8 @@ public List getAllGenderCodes() { @Cacheable("collectionCodes") public List getCollectionCodeList() { - return collectionCodeRepository.findAll(); + + return collectionCodeRepository.findAllByExpiryDateAfter(LocalDateTime.now()); } @Cacheable("schoolGradeCodes") diff --git a/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/BaseStudentDataCollectionAPITest.java b/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/BaseStudentDataCollectionAPITest.java index 70014a794..acdd087bd 100644 --- a/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/BaseStudentDataCollectionAPITest.java +++ b/api/src/test/java/ca/bc/gov/educ/studentdatacollection/api/BaseStudentDataCollectionAPITest.java @@ -130,7 +130,7 @@ public SchoolFundingGroupCodeEntity createSchoolFundingGroupCodeData() { public CollectionTypeCodeEntity createCollectionTypeCodeData() { return CollectionTypeCodeEntity.builder().collectionTypeCode("SEPTEMBER").label("September").description("September collection") - .displayOrder(10).effectiveDate(LocalDateTime.now()).expiryDate(LocalDateTime.MAX).openDate(LocalDateTime.now().minusMonths(1)) + .displayOrder(10).effectiveDate(LocalDateTime.now()).expiryDate(LocalDateTime.now().plusYears(10)).openDate(LocalDateTime.now().minusMonths(1)) .closeDate(LocalDateTime.now().plusMonths(1)).createUser("TEST").snapshotDate(LocalDate.now()).updateUser("TEST").build(); }