From fec3adfd8e75211405c440046eb4dc0d1d8fa388 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Wed, 28 Aug 2024 17:10:50 -0300 Subject: [PATCH] feat: add free growing and regen delay filters (#361) --- .github/workflows/merge.yml | 1 + .../oracle/dto/OpeningSearchResponseDto.java | 9 +- .../repository/OpeningSearchRepository.java | 79 +++++-- .../endpoint/OpeningSearchEndpointTest.java | 8 +- .../OpeningSearchRepositoryTest.java | 194 ++++++++++-------- .../oracle/service/OpeningServiceTest.java | 20 +- 6 files changed, 191 insertions(+), 120 deletions(-) diff --git a/.github/workflows/merge.yml b/.github/workflows/merge.yml index 783d2563..11147e85 100644 --- a/.github/workflows/merge.yml +++ b/.github/workflows/merge.yml @@ -138,6 +138,7 @@ jobs: -p RESULTS_ENV_OPENSEARCH=production -p AWS_COGNITO_ISSUER_URI=https://cognito-idp.${{ vars.AWS_REGION }}.amazonaws.com/${{ vars.VITE_USER_POOLS_ID }} -p DASHBOARD_JOB_IDIR_USERS=${{ vars.DASHBOARD_JOB_IDIR_USERS }} + -p WMS_LAYERS_WHITELIST_USERS=${{ vars.WMS_LAYERS_WHITELIST_USERS }} - name: frontend file: frontend/openshift.deploy.yml parameters: diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java index 961eb890..64289f98 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/dto/OpeningSearchResponseDto.java @@ -110,10 +110,13 @@ Identifier for a cut block of a harvesting tenure (within a cutting permit for private String clientAcronym; @Schema(description = "The final date based on the EARLY and LATE offset years.") - private String regenDelayDate; + private LocalDateTime regenDelayDate; - @Schema(description = "The final date based on the EARLY and LATE offset years.") - private String freeGrowingDate; + @Schema(description = "The final date based on the EARLY offset years.") + private LocalDateTime earlyFreeGrowingDate; + + @Schema(description = "The final date based on the LATE offset years.") + private LocalDateTime lateFreeGrowingDate; @Schema(description = "The date and time of the last update.") private LocalDateTime updateTimestamp; diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepository.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepository.java index d300084d..bb9ff576 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepository.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepository.java @@ -148,28 +148,39 @@ private List buildResultListDto(List result) { searchOpeningDto.setClientNumber(clientNumber); } - // HERE if (row.length > 13) { - searchOpeningDto.setRegenDelayDate(getValue(String.class, row[13], "regenTemporary")); + Timestamp regenDelayDate = getValue(Timestamp.class, row[13], "regenDelayDate"); + if (!Objects.isNull(regenDelayDate)) { + searchOpeningDto.setRegenDelayDate(regenDelayDate.toLocalDateTime()); + } } - // HERE if (row.length > 14) { - searchOpeningDto.setFreeGrowingDate(getValue(String.class, row[14], "freeGrowTemporary")); + Timestamp earlyDate = getValue(Timestamp.class, row[14], "earlyFreeGrowingDate"); + if (!Objects.isNull(earlyDate)) { + searchOpeningDto.setEarlyFreeGrowingDate(earlyDate.toLocalDateTime()); + } } if (row.length > 15) { - Timestamp updateTimestamp = getValue(Timestamp.class, row[15], "updateTimestamp"); - searchOpeningDto.setUpdateTimestamp(updateTimestamp.toLocalDateTime()); + Timestamp dateDate = getValue(Timestamp.class, row[15], "lateFreeGrowingDate"); + if (!Objects.isNull(dateDate)) { + searchOpeningDto.setLateFreeGrowingDate(dateDate.toLocalDateTime()); + } } if (row.length > 16) { - String entryUserId = getValue(String.class, row[16], "entryUserId"); - searchOpeningDto.setEntryUserId(entryUserId); + Timestamp updateTimestamp = getValue(Timestamp.class, row[16], "updateTimestamp"); + searchOpeningDto.setUpdateTimestamp(updateTimestamp.toLocalDateTime()); } if (row.length > 17) { - BigDecimal silvaReliefAppId = getValue(BigDecimal.class, row[17], "submittedToFrpa108"); + String entryUserId = getValue(String.class, row[17], "entryUserId"); + searchOpeningDto.setEntryUserId(entryUserId); + } + + if (row.length > 18) { + BigDecimal silvaReliefAppId = getValue(BigDecimal.class, row[18], "submittedToFrpa108"); boolean submittedApp = silvaReliefAppId.compareTo(BigDecimal.ZERO) > 0; searchOpeningDto.setSubmittedToFrpa(submittedApp); if (submittedApp) { @@ -270,19 +281,23 @@ private Query setQueryParameters(OpeningSearchFiltersDto filtersDto, String nati } // 8. Regen delay start date if (filtersDto.hasValue(OpeningSearchFiltersDto.REGEN_DELAY_DATE_START)) { - log.info("Skipping filter regenDelayDateStart value. Filter not ready!"); + log.info("Setting regenDelayDateStart filter value"); + query.setParameter("regenDelayDateStart", filtersDto.getRegenDelayDateStart()); } // 9. Regen delay end date if (filtersDto.hasValue(OpeningSearchFiltersDto.REGEN_DELAY_DATE_END)) { - log.info("Skipping filter regenDelayDateEnd value. Filter not ready!"); + log.info("Setting regenDelayDateEnd filter value"); + query.setParameter("regenDelayDateEnd", filtersDto.getRegenDelayDateEnd()); } // 10. Free growing start date if (filtersDto.hasValue(OpeningSearchFiltersDto.FREE_GROWING_DATE_START)) { - log.info("Skipping filter freeGrowingDateStart value. Filter not ready!"); + log.info("Setting freeGrowingDateStart filter value"); + query.setParameter("freeGrowingDateStart", filtersDto.getFreeGrowingDateStart()); } // 11. Free growing end date if (filtersDto.hasValue(OpeningSearchFiltersDto.FREE_GROWING_DATE_END)) { - log.info("Skipping filter freeGrowingDateEnd value. Filter not ready!"); + log.info("Setting freeGrowingDateEnd filter value"); + query.setParameter("freeGrowingDateEnd", filtersDto.getFreeGrowingDateEnd()); } // 12. Update date start if (filtersDto.hasValue(OpeningSearchFiltersDto.UPDATE_DATE_START)) { @@ -313,8 +328,17 @@ private String createNativeSqlQuery(OpeningSearchFiltersDto filtersDto) { builder.append(",ou.ORG_UNIT_CODE AS orgUnitCode"); builder.append(",ou.ORG_UNIT_NAME AS orgUnitName"); builder.append(",res.CLIENT_NUMBER AS clientNumber"); - builder.append(",'TDB' AS regenDelayDate"); - builder.append(",'TBD' AS freeGrowingDate"); + + String sql; + sql = ",ADD_MONTHS(cboa.DISTURBANCE_START_DATE, (COALESCE(SMRG.LATE_OFFSET_YEARS,0)*12))"; + builder.append(sql).append(" AS regenDelayDate"); + + sql = ",ADD_MONTHS(cboa.DISTURBANCE_START_DATE, (COALESCE(SMFG.EARLY_OFFSET_YEARS,0)*12))"; + builder.append(sql).append(" AS earlyFreeGrowingDate"); + + sql = ",ADD_MONTHS(cboa.DISTURBANCE_START_DATE, (COALESCE(SMFG.LATE_OFFSET_YEARS,0)*12))"; + builder.append(sql).append(" AS lateFreeGrowingDate"); + builder.append(",o.UPDATE_TIMESTAMP AS updateTimestamp"); builder.append(",o.ENTRY_USERID AS entryUserId"); builder.append(",COALESCE(sra.SILV_RELIEF_APPLICATION_ID, 0) AS submittedToFrpa108 "); @@ -328,7 +352,14 @@ private String createNativeSqlQuery(OpeningSearchFiltersDto filtersDto) { builder.append("LEFT JOIN THE.ACTIVITY_TREATMENT_UNIT atu ON (atu.OPENING_ID = o.OPENING_ID)"); builder.append("LEFT JOIN THE.SILV_RELIEF_APPLICATION sra ON ("); builder.append(" sra.ACTIVITY_TREATMENT_UNIT_ID = atu.ACTIVITY_TREATMENT_UNIT_ID"); - builder.append(" AND sra.SILV_RELIEF_APPL_STATUS_CODE = 'APP')"); + builder.append(" AND sra.SILV_RELIEF_APPL_STATUS_CODE = 'APP') "); + builder.append("LEFT JOIN THE.STOCKING_STANDARD_UNIT ssu ON (ssu.OPENING_ID = o.OPENING_ID) "); + builder.append("LEFT JOIN THE.STOCKING_MILESTONE smrg ON ("); + builder.append(" smrg.STOCKING_STANDARD_UNIT_ID = ssu.STOCKING_STANDARD_UNIT_ID"); + builder.append(" AND SMRG.SILV_MILESTONE_TYPE_CODE = 'RG') "); + builder.append("LEFT JOIN THE.STOCKING_MILESTONE smfg ON ("); + builder.append(" smfg.STOCKING_STANDARD_UNIT_ID = ssu.STOCKING_STANDARD_UNIT_ID"); + builder.append(" AND smfg.SILV_MILESTONE_TYPE_CODE = 'FG') "); builder.append("WHERE 1=1 "); /* Filters */ @@ -400,23 +431,31 @@ private String createNativeSqlQuery(OpeningSearchFiltersDto filtersDto) { // 8. Regen delay start date if (filtersDto.hasValue(OpeningSearchFiltersDto.REGEN_DELAY_DATE_START)) { log.info("Filter regenDelayDateStart detected! date={}", filtersDto.getRegenDelayDateStart()); - log.info("Skipping Filter regenDelayDateStart. Filter not ready!"); + builder.append("AND ADD_MONTHS(cboa.DISTURBANCE_START_DATE, "); + builder.append("COALESCE(SMRG.LATE_OFFSET_YEARS,0)*12) "); + builder.append("> to_timestamp(:regenDelayDateStart,'YYYY-MM-DD')"); } // 9. Regen delay end date if (filtersDto.hasValue(OpeningSearchFiltersDto.REGEN_DELAY_DATE_END)) { log.info("Filter regenDelayDateEnd detected! date={}", filtersDto.getRegenDelayDateEnd()); - log.info("Skipping Filter regenDelayDateEnd. Filter not ready!"); + builder.append("AND ADD_MONTHS(cboa.DISTURBANCE_START_DATE, "); + builder.append("COALESCE(SMRG.LATE_OFFSET_YEARS,0)*12) "); + builder.append("< to_timestamp(:regenDelayDateEnd,'YYYY-MM-DD')"); } // 10. Free growing start date if (filtersDto.hasValue(OpeningSearchFiltersDto.FREE_GROWING_DATE_START)) { log.info( "Filter freeGrowingDateStart detected! date={}", filtersDto.getFreeGrowingDateStart()); - log.info("Skipping Filter freeGrowingDateStart. Filter not ready!"); + builder.append("AND ADD_MONTHS(cboa.DISTURBANCE_START_DATE, "); + builder.append("COALESCE(SMFG.EARLY_OFFSET_YEARS,0)*12) "); + builder.append("> to_timestamp(:freeGrowingDateStart,'YYYY-MM-DD')"); } // 11. Free growing end date if (filtersDto.hasValue(OpeningSearchFiltersDto.FREE_GROWING_DATE_END)) { log.info("Filter freeGrowingDateEnd detected! date={}", filtersDto.getFreeGrowingDateEnd()); - log.info("Skipping Filter freeGrowingDateEnd. Filter not ready!"); + builder.append("AND ADD_MONTHS(cboa.DISTURBANCE_START_DATE, "); + builder.append("COALESCE(SMFG.LATE_OFFSET_YEARS,0)*12) "); + builder.append("< to_timestamp(:freeGrowingDateEnd, 'YYYY-MM-DD')"); } // 12. Update date start if (filtersDto.hasValue(OpeningSearchFiltersDto.UPDATE_DATE_START)) { diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpointTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpointTest.java index ff0d8343..0d1665b4 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpointTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/OpeningSearchEndpointTest.java @@ -57,7 +57,8 @@ void openingSearch_happyPath_shouldSucceed() throws Exception { response.setClientNumber(null); response.setClientAcronym(null); response.setRegenDelayDate(null); - response.setFreeGrowingDate(null); + response.setEarlyFreeGrowingDate(null); + response.setLateFreeGrowingDate(null); response.setUpdateTimestamp(LocalDateTime.now()); response.setEntryUserId("TEST"); response.setSubmittedToFrpa(true); @@ -94,7 +95,10 @@ void openingSearch_happyPath_shouldSucceed() throws Exception { .andExpect(jsonPath("$.data[0].orgUnitName").value(response.getOrgUnitName())) .andExpect(jsonPath("$.data[0].clientNumber").value(response.getClientNumber())) .andExpect(jsonPath("$.data[0].regenDelayDate").value(response.getRegenDelayDate())) - .andExpect(jsonPath("$.data[0].freeGrowingDate").value(response.getFreeGrowingDate())) + .andExpect( + jsonPath("$.data[0].earlyFreeGrowingDate").value(response.getEarlyFreeGrowingDate())) + .andExpect( + jsonPath("$.data[0].lateFreeGrowingDate").value(response.getLateFreeGrowingDate())) .andExpect(jsonPath("$.data[0].entryUserId").value(response.getEntryUserId())) .andExpect(jsonPath("$.data[0].submittedToFrpa").value(response.getSubmittedToFrpa())) .andExpect(jsonPath("$.data[0].silvaReliefAppId").value(response.getSilvaReliefAppId())) diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepositoryTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepositoryTest.java index 7c31ea7c..4f1d1671 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepositoryTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/repository/OpeningSearchRepositoryTest.java @@ -305,8 +305,9 @@ void searchOpeningQuery_mainFilterNumeric_shouldSucceed() { String orgUnitCode = null; String orgUnitName = null; String clientNumber = null; - String regenTemporary = null; - String freeGrowTemporary = null; + Timestamp regenDelay = null; + Timestamp earlyFreeGrowing = null; + Timestamp lateFreeGrowing = null; Timestamp updateTimestamp = Timestamp.valueOf(LocalDateTime.now()); String userId = "TEST"; BigDecimal submittedToFrpa108 = new BigDecimal("33"); @@ -326,8 +327,9 @@ void searchOpeningQuery_mainFilterNumeric_shouldSucceed() { orgUnitCode, orgUnitName, clientNumber, - regenTemporary, - freeGrowTemporary, + regenDelay, + earlyFreeGrowing, + lateFreeGrowing, updateTimestamp, userId, submittedToFrpa108, @@ -343,25 +345,27 @@ void searchOpeningQuery_mainFilterNumeric_shouldSucceed() { Assertions.assertEquals(1, result.getPerPage()); Assertions.assertEquals(1, result.getTotalPages()); Assertions.assertEquals(1, result.getData().size()); - Assertions.assertEquals(openingId, result.getData().get(0).getOpeningId()); - Assertions.assertEquals(openingNumber, result.getData().get(0).getOpeningNumber()); - Assertions.assertEquals(category, result.getData().get(0).getCategory()); - Assertions.assertEquals(status, result.getData().get(0).getStatus()); - Assertions.assertEquals(cuttingPermitId, result.getData().get(0).getCuttingPermitId()); - Assertions.assertEquals(timberMark, result.getData().get(0).getTimberMark()); - Assertions.assertEquals(cutBlockId, result.getData().get(0).getCutBlockId()); - Assertions.assertEquals(openingGrossArea, result.getData().get(0).getOpeningGrossAreaHa()); - Assertions.assertEquals( - disturbanceStartDate.toLocalDateTime(), result.getData().get(0).getDisturbanceStartDate()); - Assertions.assertEquals(fileId, result.getData().get(0).getFileId()); - Assertions.assertEquals(orgUnitCode, result.getData().get(0).getOrgUnitCode()); - Assertions.assertEquals(orgUnitName, result.getData().get(0).getOrgUnitName()); - Assertions.assertEquals(clientNumber, result.getData().get(0).getClientNumber()); - Assertions.assertEquals(regenTemporary, result.getData().get(0).getRegenDelayDate()); - Assertions.assertEquals(freeGrowTemporary, result.getData().get(0).getFreeGrowingDate()); - Assertions.assertEquals(userId, result.getData().get(0).getEntryUserId()); - Assertions.assertEquals(true, result.getData().get(0).getSubmittedToFrpa()); - Assertions.assertEquals(33L, result.getData().get(0).getSilvaReliefAppId()); + + OpeningSearchResponseDto dto = result.getData().get(0); + Assertions.assertEquals(openingId, dto.getOpeningId()); + Assertions.assertEquals(openingNumber, dto.getOpeningNumber()); + Assertions.assertEquals(category, dto.getCategory()); + Assertions.assertEquals(status, dto.getStatus()); + Assertions.assertEquals(cuttingPermitId, dto.getCuttingPermitId()); + Assertions.assertEquals(timberMark, dto.getTimberMark()); + Assertions.assertEquals(cutBlockId, dto.getCutBlockId()); + Assertions.assertEquals(openingGrossArea, dto.getOpeningGrossAreaHa()); + Assertions.assertEquals(disturbanceStartDate.toLocalDateTime(), dto.getDisturbanceStartDate()); + Assertions.assertEquals(fileId, dto.getFileId()); + Assertions.assertEquals(orgUnitCode, dto.getOrgUnitCode()); + Assertions.assertEquals(orgUnitName, dto.getOrgUnitName()); + Assertions.assertEquals(clientNumber, dto.getClientNumber()); + Assertions.assertNull(dto.getRegenDelayDate()); + Assertions.assertNull(dto.getEarlyFreeGrowingDate()); + Assertions.assertNull(dto.getLateFreeGrowingDate()); + Assertions.assertEquals(userId, dto.getEntryUserId()); + Assertions.assertEquals(true, dto.getSubmittedToFrpa()); + Assertions.assertEquals(33L, dto.getSilvaReliefAppId()); Assertions.assertFalse(result.isHasNextPage()); } @@ -386,8 +390,9 @@ void searchOpeningQuery_mainFilterString_shouldSucceed() { String orgUnitCode = null; String orgUnitName = null; String clientNumber = null; - String regenTemporary = null; - String freeGrowTemporary = null; + Timestamp regenDelay = null; + Timestamp earlyFreeGrowing = null; + Timestamp lateFreeGrowing = null; Timestamp updateTimestamp = Timestamp.valueOf(LocalDateTime.now()); String userId = "TEST"; BigDecimal submittedToFrpa = BigDecimal.ZERO; @@ -407,8 +412,9 @@ void searchOpeningQuery_mainFilterString_shouldSucceed() { orgUnitCode, orgUnitName, clientNumber, - regenTemporary, - freeGrowTemporary, + regenDelay, + earlyFreeGrowing, + lateFreeGrowing, updateTimestamp, userId, submittedToFrpa, @@ -424,24 +430,26 @@ void searchOpeningQuery_mainFilterString_shouldSucceed() { Assertions.assertEquals(1, result.getPerPage()); Assertions.assertEquals(1, result.getTotalPages()); Assertions.assertEquals(1, result.getData().size()); - Assertions.assertEquals(openingId, result.getData().get(0).getOpeningId()); - Assertions.assertEquals(openingNumber, result.getData().get(0).getOpeningNumber()); - Assertions.assertEquals(category, result.getData().get(0).getCategory()); - Assertions.assertEquals(status, result.getData().get(0).getStatus()); - Assertions.assertEquals(cuttingPermitId, result.getData().get(0).getCuttingPermitId()); - Assertions.assertEquals(timberMark, result.getData().get(0).getTimberMark()); - Assertions.assertEquals(cutBlockId, result.getData().get(0).getCutBlockId()); - Assertions.assertEquals(openingGrossArea, result.getData().get(0).getOpeningGrossAreaHa()); - Assertions.assertEquals( - disturbanceStartDate.toLocalDateTime(), result.getData().get(0).getDisturbanceStartDate()); - Assertions.assertEquals(fileId, result.getData().get(0).getFileId()); - Assertions.assertEquals(orgUnitCode, result.getData().get(0).getOrgUnitCode()); - Assertions.assertEquals(orgUnitName, result.getData().get(0).getOrgUnitName()); - Assertions.assertEquals(clientNumber, result.getData().get(0).getClientNumber()); - Assertions.assertEquals(regenTemporary, result.getData().get(0).getRegenDelayDate()); - Assertions.assertEquals(freeGrowTemporary, result.getData().get(0).getFreeGrowingDate()); - Assertions.assertEquals(userId, result.getData().get(0).getEntryUserId()); - Assertions.assertEquals(false, result.getData().get(0).getSubmittedToFrpa()); + + OpeningSearchResponseDto dto = result.getData().get(0); + Assertions.assertEquals(openingId, dto.getOpeningId()); + Assertions.assertEquals(openingNumber, dto.getOpeningNumber()); + Assertions.assertEquals(category, dto.getCategory()); + Assertions.assertEquals(status, dto.getStatus()); + Assertions.assertEquals(cuttingPermitId, dto.getCuttingPermitId()); + Assertions.assertEquals(timberMark, dto.getTimberMark()); + Assertions.assertEquals(cutBlockId, dto.getCutBlockId()); + Assertions.assertEquals(openingGrossArea, dto.getOpeningGrossAreaHa()); + Assertions.assertEquals(disturbanceStartDate.toLocalDateTime(), dto.getDisturbanceStartDate()); + Assertions.assertEquals(fileId, dto.getFileId()); + Assertions.assertEquals(orgUnitCode, dto.getOrgUnitCode()); + Assertions.assertEquals(orgUnitName, dto.getOrgUnitName()); + Assertions.assertEquals(clientNumber, dto.getClientNumber()); + Assertions.assertNull(dto.getRegenDelayDate()); + Assertions.assertNull(dto.getEarlyFreeGrowingDate()); + Assertions.assertNull(dto.getLateFreeGrowingDate()); + Assertions.assertEquals(userId, dto.getEntryUserId()); + Assertions.assertEquals(false, dto.getSubmittedToFrpa()); Assertions.assertFalse(result.isHasNextPage()); } @@ -465,8 +473,9 @@ void searchOpeningQuery_orgUnitFilter_shouldSucceed() { String orgUnitCode = "DCR"; String orgUnitName = null; String clientNumber = null; - String regenTemporary = null; - String freeGrowTemporary = null; + Timestamp regenDelay = null; + Timestamp earlyFreeGrowing = null; + Timestamp lateFreeGrowing = null; Timestamp updateTimestamp = Timestamp.valueOf(LocalDateTime.now()); String userId = "TEST"; BigDecimal submittedToFrpa = BigDecimal.ZERO; @@ -486,8 +495,9 @@ void searchOpeningQuery_orgUnitFilter_shouldSucceed() { orgUnitCode, orgUnitName, clientNumber, - regenTemporary, - freeGrowTemporary, + regenDelay, + earlyFreeGrowing, + lateFreeGrowing, updateTimestamp, userId, submittedToFrpa, @@ -503,24 +513,26 @@ void searchOpeningQuery_orgUnitFilter_shouldSucceed() { Assertions.assertEquals(1, result.getPerPage()); Assertions.assertEquals(1, result.getTotalPages()); Assertions.assertEquals(1, result.getData().size()); - Assertions.assertEquals(openingId, result.getData().get(0).getOpeningId()); - Assertions.assertEquals(openingNumber, result.getData().get(0).getOpeningNumber()); - Assertions.assertEquals(category, result.getData().get(0).getCategory()); - Assertions.assertEquals(status, result.getData().get(0).getStatus()); - Assertions.assertEquals(cuttingPermitId, result.getData().get(0).getCuttingPermitId()); - Assertions.assertEquals(timberMark, result.getData().get(0).getTimberMark()); - Assertions.assertEquals(cutBlockId, result.getData().get(0).getCutBlockId()); - Assertions.assertEquals(openingGrossArea, result.getData().get(0).getOpeningGrossAreaHa()); - Assertions.assertEquals( - disturbanceStartDate.toLocalDateTime(), result.getData().get(0).getDisturbanceStartDate()); - Assertions.assertEquals(fileId, result.getData().get(0).getFileId()); - Assertions.assertEquals(orgUnitCode, result.getData().get(0).getOrgUnitCode()); - Assertions.assertEquals(orgUnitName, result.getData().get(0).getOrgUnitName()); - Assertions.assertEquals(clientNumber, result.getData().get(0).getClientNumber()); - Assertions.assertEquals(regenTemporary, result.getData().get(0).getRegenDelayDate()); - Assertions.assertEquals(freeGrowTemporary, result.getData().get(0).getFreeGrowingDate()); - Assertions.assertEquals(userId, result.getData().get(0).getEntryUserId()); - Assertions.assertEquals(false, result.getData().get(0).getSubmittedToFrpa()); + + OpeningSearchResponseDto dto = result.getData().get(0); + Assertions.assertEquals(openingId, dto.getOpeningId()); + Assertions.assertEquals(openingNumber, dto.getOpeningNumber()); + Assertions.assertEquals(category, dto.getCategory()); + Assertions.assertEquals(status, dto.getStatus()); + Assertions.assertEquals(cuttingPermitId, dto.getCuttingPermitId()); + Assertions.assertEquals(timberMark, dto.getTimberMark()); + Assertions.assertEquals(cutBlockId, dto.getCutBlockId()); + Assertions.assertEquals(openingGrossArea, dto.getOpeningGrossAreaHa()); + Assertions.assertEquals(disturbanceStartDate.toLocalDateTime(), dto.getDisturbanceStartDate()); + Assertions.assertEquals(fileId, dto.getFileId()); + Assertions.assertEquals(orgUnitCode, dto.getOrgUnitCode()); + Assertions.assertEquals(orgUnitName, dto.getOrgUnitName()); + Assertions.assertEquals(clientNumber, dto.getClientNumber()); + Assertions.assertNull(dto.getRegenDelayDate()); + Assertions.assertNull(dto.getEarlyFreeGrowingDate()); + Assertions.assertNull(dto.getLateFreeGrowingDate()); + Assertions.assertEquals(userId, dto.getEntryUserId()); + Assertions.assertEquals(false, dto.getSubmittedToFrpa()); Assertions.assertFalse(result.isHasNextPage()); } @@ -544,8 +556,9 @@ void searchOpeningQuery_allFilters_shouldSucceed() { String orgUnitCode = filters.getOrgUnit(); String orgUnitName = "Org Name"; String clientNumber = "00012797"; - String regenTemporary = "TBD"; - String freeGrowTemporary = "TBD"; + Timestamp regenDelay = null; + Timestamp earlyFreeGrowing = Timestamp.valueOf(LocalDateTime.now()); + Timestamp lateFreeGrowing = Timestamp.valueOf(LocalDateTime.now()); Timestamp updateTimestamp = Timestamp.valueOf(LocalDateTime.now()); String entryUserId = filters.getEntryUserId(); BigDecimal submittedToFrpa = BigDecimal.ZERO; @@ -565,8 +578,9 @@ void searchOpeningQuery_allFilters_shouldSucceed() { orgUnitCode, orgUnitName, clientNumber, - regenTemporary, - freeGrowTemporary, + regenDelay, + earlyFreeGrowing, + lateFreeGrowing, updateTimestamp, entryUserId, submittedToFrpa, @@ -582,24 +596,26 @@ void searchOpeningQuery_allFilters_shouldSucceed() { Assertions.assertEquals(1, result.getPerPage()); Assertions.assertEquals(1, result.getTotalPages()); Assertions.assertEquals(1, result.getData().size()); - Assertions.assertEquals(openingId, result.getData().get(0).getOpeningId()); - Assertions.assertEquals(openingNumber, result.getData().get(0).getOpeningNumber()); - Assertions.assertEquals(category, result.getData().get(0).getCategory()); - Assertions.assertEquals(status, result.getData().get(0).getStatus()); - Assertions.assertEquals(cuttingPermitId, result.getData().get(0).getCuttingPermitId()); - Assertions.assertEquals(timberMark, result.getData().get(0).getTimberMark()); - Assertions.assertEquals(cutBlockId, result.getData().get(0).getCutBlockId()); - Assertions.assertEquals(openingGrossArea, result.getData().get(0).getOpeningGrossAreaHa()); - Assertions.assertEquals( - disturbanceStartDate.toLocalDateTime(), result.getData().get(0).getDisturbanceStartDate()); - Assertions.assertEquals(fileId, result.getData().get(0).getFileId()); - Assertions.assertEquals(orgUnitCode, result.getData().get(0).getOrgUnitCode()); - Assertions.assertEquals(orgUnitName, result.getData().get(0).getOrgUnitName()); - Assertions.assertEquals(clientNumber, result.getData().get(0).getClientNumber()); - Assertions.assertEquals(regenTemporary, result.getData().get(0).getRegenDelayDate()); - Assertions.assertEquals(freeGrowTemporary, result.getData().get(0).getFreeGrowingDate()); - Assertions.assertEquals(entryUserId, result.getData().get(0).getEntryUserId()); - Assertions.assertEquals(false, result.getData().get(0).getSubmittedToFrpa()); + + OpeningSearchResponseDto dto = result.getData().get(0); + Assertions.assertEquals(openingId, dto.getOpeningId()); + Assertions.assertEquals(openingNumber, dto.getOpeningNumber()); + Assertions.assertEquals(category, dto.getCategory()); + Assertions.assertEquals(status, dto.getStatus()); + Assertions.assertEquals(cuttingPermitId, dto.getCuttingPermitId()); + Assertions.assertEquals(timberMark, dto.getTimberMark()); + Assertions.assertEquals(cutBlockId, dto.getCutBlockId()); + Assertions.assertEquals(openingGrossArea, dto.getOpeningGrossAreaHa()); + Assertions.assertEquals(disturbanceStartDate.toLocalDateTime(), dto.getDisturbanceStartDate()); + Assertions.assertEquals(fileId, dto.getFileId()); + Assertions.assertEquals(orgUnitCode, dto.getOrgUnitCode()); + Assertions.assertEquals(orgUnitName, dto.getOrgUnitName()); + Assertions.assertEquals(clientNumber, dto.getClientNumber()); + Assertions.assertNull(dto.getRegenDelayDate()); + Assertions.assertEquals(earlyFreeGrowing, Timestamp.valueOf(dto.getEarlyFreeGrowingDate())); + Assertions.assertEquals(lateFreeGrowing, Timestamp.valueOf(dto.getLateFreeGrowingDate())); + Assertions.assertEquals(entryUserId, dto.getEntryUserId()); + Assertions.assertEquals(false, dto.getSubmittedToFrpa()); Assertions.assertFalse(result.isHasNextPage()); } diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningServiceTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningServiceTest.java index 79b27b86..56d0e9e6 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningServiceTest.java @@ -265,8 +265,9 @@ void openingSearch_fileId_shouldSucceed() { dto.setOrgUnitName(""); dto.setClientNumber(""); dto.setClientAcronym(""); - dto.setRegenDelayDate(""); - dto.setFreeGrowingDate(""); + dto.setRegenDelayDate(LocalDateTime.now()); + dto.setEarlyFreeGrowingDate(LocalDateTime.now()); + dto.setLateFreeGrowingDate(LocalDateTime.now()); dto.setUpdateTimestamp(LocalDateTime.now()); dto.setEntryUserId(""); dto.setSubmittedToFrpa(false); @@ -300,7 +301,10 @@ void openingSearch_fileId_shouldSucceed() { Assertions.assertEquals(dto.getOrgUnitName(), result.getData().get(0).getOrgUnitName()); Assertions.assertEquals(dto.getClientNumber(), result.getData().get(0).getClientNumber()); Assertions.assertEquals(dto.getRegenDelayDate(), result.getData().get(0).getRegenDelayDate()); - Assertions.assertEquals(dto.getFreeGrowingDate(), result.getData().get(0).getFreeGrowingDate()); + Assertions.assertEquals( + dto.getEarlyFreeGrowingDate(), result.getData().get(0).getEarlyFreeGrowingDate()); + Assertions.assertEquals( + dto.getLateFreeGrowingDate(), result.getData().get(0).getLateFreeGrowingDate()); Assertions.assertEquals(dto.getEntryUserId(), result.getData().get(0).getEntryUserId()); Assertions.assertEquals(dto.getSubmittedToFrpa(), result.getData().get(0).getSubmittedToFrpa()); Assertions.assertFalse(result.isHasNextPage()); @@ -330,8 +334,9 @@ void openingSearch_orgUnit_shouldSucceed() { dto.setOrgUnitName(""); dto.setClientNumber(""); dto.setClientAcronym(""); - dto.setRegenDelayDate(""); - dto.setFreeGrowingDate(""); + dto.setRegenDelayDate(LocalDateTime.now()); + dto.setEarlyFreeGrowingDate(LocalDateTime.now()); + dto.setLateFreeGrowingDate(LocalDateTime.now()); dto.setUpdateTimestamp(LocalDateTime.now()); dto.setEntryUserId(""); dto.setSubmittedToFrpa(false); @@ -365,7 +370,10 @@ void openingSearch_orgUnit_shouldSucceed() { Assertions.assertEquals(dto.getOrgUnitName(), result.getData().get(0).getOrgUnitName()); Assertions.assertEquals(dto.getClientNumber(), result.getData().get(0).getClientNumber()); Assertions.assertEquals(dto.getRegenDelayDate(), result.getData().get(0).getRegenDelayDate()); - Assertions.assertEquals(dto.getFreeGrowingDate(), result.getData().get(0).getFreeGrowingDate()); + Assertions.assertEquals( + dto.getEarlyFreeGrowingDate(), result.getData().get(0).getEarlyFreeGrowingDate()); + Assertions.assertEquals( + dto.getLateFreeGrowingDate(), result.getData().get(0).getLateFreeGrowingDate()); Assertions.assertEquals(dto.getEntryUserId(), result.getData().get(0).getEntryUserId()); Assertions.assertEquals(dto.getSubmittedToFrpa(), result.getData().get(0).getSubmittedToFrpa()); Assertions.assertFalse(result.isHasNextPage());