diff --git a/backend/pom.xml b/backend/pom.xml index 33a5632d1..93650b5cc 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -525,7 +525,7 @@ com.nimbusds nimbus-jose-jwt - 9.47 + 10.0.1 org.testcontainers diff --git a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpoint.java b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpoint.java index 514ba241b..904ee676c 100644 --- a/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpoint.java +++ b/backend/src/main/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpoint.java @@ -59,14 +59,19 @@ public ResponseEntity> getOpeningsSubmissionTrends( LocalDate entryDateEnd ) { + LocalDate end = getDateOrDefault(entryDateEnd, + //If we have an end date, we get it, otherwise we use the current date, + // and no matter if we have the start date or not, we add a year to the end date + getDateOrDefault(entryDateStart,LocalDate.now().minusYears(1)).plusYears(1) + ); + LocalDate bgn = getDateOrDefault(entryDateEnd,LocalDate.now().minusYears(1)); + + log.info("AS date per request of Mr Dates {} {}", bgn, end); + List resultList = openingTrendsService.getOpeningSubmissionTrends( - getDateOrDefault(entryDateStart,LocalDate.now().minusYears(1)), - getDateOrDefault(entryDateEnd, - //If we have an end date, we get it, otherwise we use the current date, - // and no matter if we have the start date or not, we add a year to the end date - getDateOrDefault(entryDateStart,LocalDate.now().minusYears(1)).plusYears(1) - ), + bgn, + end, orgUnits, statusCodes ); diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpointIntegrationTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpointIntegrationTest.java index 8b7dc72e2..0a961fe6d 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpointIntegrationTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/endpoint/UserActionsEndpointIntegrationTest.java @@ -8,6 +8,10 @@ import ca.bc.gov.restapi.results.extensions.AbstractTestContainerIntegrationTest; import ca.bc.gov.restapi.results.extensions.WithMockJwt; +import ca.bc.gov.restapi.results.oracle.repository.OpeningRepository; +import java.time.LocalDate; +import java.time.LocalDateTime; +import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +27,19 @@ class UserActionsEndpointIntegrationTest extends AbstractTestContainerIntegratio @Autowired private MockMvc mockMvc; + @Autowired + private OpeningRepository openingRepository; + + @BeforeEach + public void beforeEach(){ + + openingRepository + .findAll() + .stream() + .map(entity -> entity.withUpdateTimestamp(LocalDateTime.now().minusMonths(2))) + .forEach(openingRepository::save); + } + @Test @DisplayName("User recent actions requests test with data should succeed") void getUserRecentOpeningsActions_withData_shouldSucceed() throws Exception { @@ -65,10 +82,8 @@ void getOpeningsSubmissionTrends_happyPath_shouldSucceed() throws Exception { .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(jsonPath("$[0].month").value("12")) - .andExpect(jsonPath("$[0].amount").value(0)) - .andExpect(jsonPath("$[1].monthName").value("Jan")) - .andExpect(jsonPath("$[1].amount").value(3)); + .andExpect(jsonPath("$[11].month").value(LocalDate.now().getMonthValue())) + .andExpect(jsonPath("$[11].amount").value(3)); } @Test @@ -93,8 +108,8 @@ void getOpeningsSubmissionTrends_withFilters_shouldSucceed() throws Exception { .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) - .andExpect(jsonPath("$[0].month").value("12")) - .andExpect(jsonPath("$[0].amount").value(0)); + .andExpect(jsonPath("$[11].month").value(LocalDate.now().getMonthValue())) + .andExpect(jsonPath("$[11].amount").value(3)); } @Test diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningTrendsServiceTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningTrendsServiceTest.java index 03dcb9dac..34fb1540c 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningTrendsServiceTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/service/OpeningTrendsServiceTest.java @@ -8,6 +8,7 @@ import ca.bc.gov.restapi.results.postgres.dto.OpeningsPerYearDto; import java.time.LocalDate; import java.time.LocalDateTime; +import java.time.Month; import java.time.format.TextStyle; import java.util.List; import java.util.Locale; @@ -64,8 +65,7 @@ void getOpeningSubmissionTrends_noFilters_shouldSucceed() { null ); - String monthName = now.getMonth().name().toLowerCase(); - monthName = monthName.substring(0, 1).toUpperCase() + monthName.substring(1, 3); + String monthName = now.getMonth().getDisplayName(TextStyle.SHORT, Locale.CANADA); Assertions.assertFalse(list.isEmpty()); Assertions.assertEquals(12, list.size()); @@ -111,8 +111,7 @@ void getOpeningSubmissionTrends_statusFilter_shouldSucceed() { List.of("APP") ); - String monthName = now.getMonth().name().toLowerCase(); - monthName = monthName.substring(0, 1).toUpperCase() + monthName.substring(1, 3); + String monthName = now.getMonth().getDisplayName(TextStyle.SHORT, Locale.CANADA); Assertions.assertFalse(list.isEmpty()); Assertions.assertEquals(12, list.size()); @@ -206,4 +205,8 @@ class TestOpeningTrendsProjection implements OpeningTrendsProjection { } + private String getMonthName(int month) { + return Month.of(month).getDisplayName(TextStyle.SHORT, Locale.CANADA); + } + } \ No newline at end of file diff --git a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/util/PaginationUtilTest.java b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/util/PaginationUtilTest.java index 8beed3af2..82b1dc5b0 100644 --- a/backend/src/test/java/ca/bc/gov/restapi/results/oracle/util/PaginationUtilTest.java +++ b/backend/src/test/java/ca/bc/gov/restapi/results/oracle/util/PaginationUtilTest.java @@ -34,7 +34,7 @@ void getStartIndexTest() { } @Test - @DisplayName("") + @DisplayName("End index test") void getEndIndexTest() { Assertions.assertEquals(40, PaginationUtil.getEndIndex(30, 10, 47)); Assertions.assertEquals(47, PaginationUtil.getEndIndex(40, 10, 47));