From 8cbc6674e2f9830078b85a2a159d63771bcde4a1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 29 Jan 2025 00:38:14 +0000 Subject: [PATCH 1/3] fix(deps): update dependency com.nimbusds:nimbus-jose-jwt to v10 --- backend/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/pom.xml b/backend/pom.xml index 33a5632d..93650b5c 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 From 1c62b582b295baa23245038d6d54056f396dbf20 Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Fri, 31 Jan 2025 16:15:59 -0800 Subject: [PATCH 2/3] chore(tests): fixing tests --- .../UserActionsEndpointIntegrationTest.java | 32 +++++++++++++++---- .../service/OpeningTrendsServiceTest.java | 11 ++++--- .../oracle/util/PaginationUtilTest.java | 2 +- 3 files changed, 34 insertions(+), 11 deletions(-) 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 8b7dc72e..2788b4ca 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,12 @@ 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 java.time.format.TextStyle; +import java.util.Locale; +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 +29,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 +84,11 @@ 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("$[0].month").value(LocalDate.now().getMonthValue())) + .andExpect(jsonPath("$[0].amount").value(3)) + .andExpect(jsonPath("$[1].monthName").value(LocalDate.now().plusMonths(1).getMonth().getDisplayName( + TextStyle.SHORT, Locale.CANADA))) + .andExpect(jsonPath("$[1].amount").value(0)); } @Test @@ -93,8 +113,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("$[0].month").value(LocalDate.now().getMonthValue())) + .andExpect(jsonPath("$[0].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 03dcb9da..34fb1540 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 8beed3af..82b1dc5b 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)); From 24bf2a1e9b247ad37b251653472af1fe4c322a2a Mon Sep 17 00:00:00 2001 From: Paulo Gomes da Cruz Junior Date: Tue, 4 Feb 2025 08:28:22 -0800 Subject: [PATCH 3/3] chore(tests): fixing tests --- .../oracle/endpoint/UserActionsEndpoint.java | 17 +++++++++++------ .../UserActionsEndpointIntegrationTest.java | 13 ++++--------- 2 files changed, 15 insertions(+), 15 deletions(-) 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 514ba241..904ee676 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 2788b4ca..0a961fe6 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 @@ -11,8 +11,6 @@ import ca.bc.gov.restapi.results.oracle.repository.OpeningRepository; import java.time.LocalDate; import java.time.LocalDateTime; -import java.time.format.TextStyle; -import java.util.Locale; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -84,11 +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(LocalDate.now().getMonthValue())) - .andExpect(jsonPath("$[0].amount").value(3)) - .andExpect(jsonPath("$[1].monthName").value(LocalDate.now().plusMonths(1).getMonth().getDisplayName( - TextStyle.SHORT, Locale.CANADA))) - .andExpect(jsonPath("$[1].amount").value(0)); + .andExpect(jsonPath("$[11].month").value(LocalDate.now().getMonthValue())) + .andExpect(jsonPath("$[11].amount").value(3)); } @Test @@ -113,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(LocalDate.now().getMonthValue())) - .andExpect(jsonPath("$[0].amount").value(3)); + .andExpect(jsonPath("$[11].month").value(LocalDate.now().getMonthValue())) + .andExpect(jsonPath("$[11].amount").value(3)); } @Test