From 0a70f2bbb6344b4dde9e8fa4369259e295e74167 Mon Sep 17 00:00:00 2001 From: rma-rripken <89810919+rma-rripken@users.noreply.github.com> Date: Wed, 11 Feb 2026 14:20:28 -0800 Subject: [PATCH 1/3] There is no reason that the filtered time series needs to test against pseudo regular data. This change adds a new json file with values on the hour, for testing this works and won't fail in relation to LRTS. --- .../TimeSeriesFilteredControllerTestIT.java | 32 +++++++++---------- .../resources/cwms/cda/api/lrl/1hour.json | 27 ++++++++++++++++ 2 files changed, 42 insertions(+), 17 deletions(-) create mode 100644 cwms-data-api/src/test/resources/cwms/cda/api/lrl/1hour.json diff --git a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java index 13befcf7d..ab643045e 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java @@ -10,6 +10,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.flogger.FluentLogger; import cwms.cda.formatters.Formats; import fixtures.TestAccounts; import io.restassured.RestAssured; @@ -28,14 +29,15 @@ @Tag("integration") class TimeSeriesFilteredControllerTestIT extends DataApiTestIT { + static FluentLogger logger = FluentLogger.forEnclosingClass(); + public static final String JSON_FILE = "/cwms/cda/api/lrl/1hour.json"; @ParameterizedTest @ValueSource(strings = {Formats.JSONV2, Formats.DEFAULT}) void test_filter_nulls(String format) throws Exception { ObjectMapper mapper = new ObjectMapper(); - InputStream resource = this.getClass().getResourceAsStream( - "/cwms/cda/api/lrl/pseudo_reg_1hour.json"); + InputStream resource = this.getClass().getResourceAsStream(JSON_FILE); assertNotNull(resource); String tsData = IOUtils.toString(resource, StandardCharsets.UTF_8); @@ -74,7 +76,7 @@ void test_filter_nulls(String format) throws Exception { .queryParam(Controllers.UNIT,"cfs") .queryParam(Controllers.NAME, ts.get(Controllers.NAME).asText()) .queryParam(Controllers.BEGIN,"2023-01-11T12:00:00-00:00") - .queryParam(Controllers.END,"2023-01-11T13:00:00-00:00") + .queryParam(Controllers.END,"2023-01-11T15:00:00-00:00") .when() .redirects().follow(true) .redirects().max(3) @@ -98,7 +100,7 @@ void test_filter_nulls(String format) throws Exception { .queryParam(Controllers.UNIT,"cfs") .queryParam(Controllers.NAME, ts.get(Controllers.NAME).asText()) .queryParam(Controllers.BEGIN,"2023-01-11T12:00:00-00:00") - .queryParam(Controllers.END,"2023-01-11T13:00:00-00:00") + .queryParam(Controllers.END,"2023-01-11T15:00:00-00:00") .queryParam(Controllers.QUERY,"value!=null") .when() .redirects().follow(true) @@ -110,7 +112,7 @@ void test_filter_nulls(String format) throws Exception { .statusCode(is(HttpServletResponse.SC_OK)) .body("time-series.values[0][0]", equalTo(1673438400000L)) .body("time-series.values[0][1]", closeTo(500.0,0.0001)) - .body("time-series.values[1][0]", equalTo(1673442000000L)) + .body("time-series.values[1][0]", equalTo(1673449200000L)) .body("time-series.values[1][1]", closeTo(600.0,0.0001)) .body("time-series.values.size()", equalTo(2)) ; @@ -124,8 +126,7 @@ void test_filter_nulls(String format) throws Exception { void test_min_value(String format) throws Exception { ObjectMapper mapper = new ObjectMapper(); - InputStream resource = this.getClass().getResourceAsStream( - "/cwms/cda/api/lrl/pseudo_reg_1hour.json"); + InputStream resource = this.getClass().getResourceAsStream(JSON_FILE); assertNotNull(resource); String tsData = IOUtils.toString(resource, StandardCharsets.UTF_8); @@ -164,7 +165,7 @@ void test_min_value(String format) throws Exception { .queryParam(Controllers.UNIT,"cfs") .queryParam(Controllers.NAME, ts.get(Controllers.NAME).asText()) .queryParam(Controllers.BEGIN,"2023-01-11T12:00:00-00:00") - .queryParam(Controllers.END,"2023-01-11T13:00:00-00:00") + .queryParam(Controllers.END,"2023-01-11T15:00:00-00:00") .queryParam(Controllers.QUERY, "value>550.0") .when() .redirects().follow(true) @@ -188,8 +189,7 @@ void test_min_value(String format) throws Exception { void test_max_value(String format) throws Exception { ObjectMapper mapper = new ObjectMapper(); - InputStream resource = this.getClass().getResourceAsStream( - "/cwms/cda/api/lrl/pseudo_reg_1hour.json"); + InputStream resource = this.getClass().getResourceAsStream(JSON_FILE); assertNotNull(resource); String tsData = IOUtils.toString(resource, StandardCharsets.UTF_8); @@ -228,7 +228,7 @@ void test_max_value(String format) throws Exception { .queryParam(Controllers.UNIT,"cfs") .queryParam(Controllers.NAME, ts.get(Controllers.NAME).asText()) .queryParam(Controllers.BEGIN,"2023-01-11T12:00:00-00:00") - .queryParam(Controllers.END,"2023-01-11T13:00:00-00:00") + .queryParam(Controllers.END,"2023-01-11T15:00:00-00:00") .queryParam(Controllers.QUERY, "value<=550.0") .when() .redirects().follow(true) @@ -252,8 +252,7 @@ void test_max_value(String format) throws Exception { void test_min_max_value_combined(String format) throws Exception { ObjectMapper mapper = new ObjectMapper(); - InputStream resource = this.getClass().getResourceAsStream( - "/cwms/cda/api/lrl/pseudo_reg_1hour.json"); + InputStream resource = this.getClass().getResourceAsStream(JSON_FILE); assertNotNull(resource); String tsData = IOUtils.toString(resource, StandardCharsets.UTF_8); @@ -292,7 +291,7 @@ void test_min_max_value_combined(String format) throws Exception { .queryParam(Controllers.UNIT,"cfs") .queryParam(Controllers.NAME, ts.get(Controllers.NAME).asText()) .queryParam(Controllers.BEGIN,"2023-01-11T12:00:00-00:00") - .queryParam(Controllers.END,"2023-01-11T13:00:00-00:00") + .queryParam(Controllers.END,"2023-01-11T15:00:00-00:00") .queryParam(Controllers.QUERY, "value>450.0 and value <=550.0") .when() .redirects().follow(true) @@ -316,8 +315,7 @@ void test_min_max_value_combined(String format) throws Exception { void test_all_filters_combined(String format) throws Exception { ObjectMapper mapper = new ObjectMapper(); - InputStream resource = this.getClass().getResourceAsStream( - "/cwms/cda/api/lrl/pseudo_reg_1hour.json"); + InputStream resource = this.getClass().getResourceAsStream(JSON_FILE); assertNotNull(resource); String tsData = IOUtils.toString(resource, StandardCharsets.UTF_8); @@ -356,7 +354,7 @@ void test_all_filters_combined(String format) throws Exception { .queryParam(Controllers.UNIT,"cfs") .queryParam(Controllers.NAME, ts.get(Controllers.NAME).asText()) .queryParam(Controllers.BEGIN,"2023-01-11T12:00:00-00:00") - .queryParam(Controllers.END,"2023-01-11T13:00:00-00:00") + .queryParam(Controllers.END,"2023-01-11T15:00:00-00:00") .queryParam(Controllers.QUERY, "value!=null and value>450.0 and value <=550.0") .when() .redirects().follow(true) diff --git a/cwms-data-api/src/test/resources/cwms/cda/api/lrl/1hour.json b/cwms-data-api/src/test/resources/cwms/cda/api/lrl/1hour.json new file mode 100644 index 000000000..1a72a1bd3 --- /dev/null +++ b/cwms-data-api/src/test/resources/cwms/cda/api/lrl/1hour.json @@ -0,0 +1,27 @@ +{ + "name": "Calhoun.Flow.Inst.1Hour.0.cda-test", + "office-id": "SPK", + "units": "cfs", + "values": [ + [ + 1673438400000, + 500, + 0 + ], + [ + 1673442000000, + null, + 5 + ], + [ + 1673445600000, + -340282346638528859811704183484516925440, + 5 + ], + [ + 1673449200000, + 600, + 0 + ] + ] +} \ No newline at end of file From 17d8a268c930d1564d2663a8586eb3b04caeb9ec Mon Sep 17 00:00:00 2001 From: rma-rripken <89810919+rma-rripken@users.noreply.github.com> Date: Wed, 11 Feb 2026 14:28:25 -0800 Subject: [PATCH 2/3] There is no reason that the filtered time series needs to test against pseudo regular data. This change adds a new json file with values on the hour, for testing this works and won't fail in relation to LRTS. --- .../java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java index ab643045e..4c9d43a0b 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/TimeSeriesFilteredControllerTestIT.java @@ -175,7 +175,7 @@ void test_min_value(String format) throws Exception { .log().ifValidationFails(LogDetail.ALL,true) .assertThat() .statusCode(is(HttpServletResponse.SC_OK)) - .body("time-series.values[0][0]", equalTo(1673442000000L)) + .body("time-series.values[0][0]", equalTo(1673449200000L)) .body("time-series.values[0][1]", closeTo(600.0,0.0001)) .body("time-series.values.size()", equalTo(1)) ; From 9280598afb6e0f68b2afe9c129e9586f76569306 Mon Sep 17 00:00:00 2001 From: rma-rripken <89810919+rma-rripken@users.noreply.github.com> Date: Wed, 11 Feb 2026 15:15:36 -0800 Subject: [PATCH 3/3] BinaryTimeSeriesControllerTestIT wasn't always cleaning up the time series it had created --- .../api/BinaryTimeSeriesControllerTestIT.java | 51 ++++++++++++++++--- 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/cwms-data-api/src/test/java/cwms/cda/api/BinaryTimeSeriesControllerTestIT.java b/cwms-data-api/src/test/java/cwms/cda/api/BinaryTimeSeriesControllerTestIT.java index 51724eba8..7637c3c2d 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/BinaryTimeSeriesControllerTestIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/BinaryTimeSeriesControllerTestIT.java @@ -15,9 +15,7 @@ import org.apache.http.NameValuePair; import org.apache.http.client.utils.URIBuilder; import org.jetbrains.annotations.NotNull; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.BeforeEach; -import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.*; import javax.servlet.http.HttpServletResponse; import java.io.ByteArrayOutputStream; @@ -29,7 +27,7 @@ import java.util.Map; import java.util.Objects; import java.util.Random; -import org.junit.jupiter.api.Test; + import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.ValueSource; @@ -58,6 +56,28 @@ static void create() throws Exception { random.nextBytes(LARGE_BYTES); } + @AfterEach + void tearDown() throws Exception { + TestAccounts.KeyUser user = TestAccounts.KeyUser.SPK_NORMAL; + given() + .log().ifValidationFails(LogDetail.ALL, true) + .accept(Formats.JSONV2) + .header("Authorization", user.toHeaderValue()) + .queryParam(Controllers.OFFICE, OFFICE) + .when() + .redirects().follow(true) + .redirects().max(3) + .queryParam(Controllers.OFFICE, OFFICE) + .queryParam(Controllers.BEGIN, BEGIN_STR) + .queryParam(Controllers.END, END_STR) + .queryParam(Controllers.OFFICE, OFFICE) + .delete("/timeseries/binary/" + tsId) + .then() + .log().ifValidationFails(LogDetail.ALL, true) + .assertThat() + .statusCode(is(HttpServletResponse.SC_NO_CONTENT)); + } + @BeforeEach void setup() throws Exception { tsId = locationId + ".Flow.Inst.1Hour.0." + Instant.now().getEpochSecond() + (int)(Math.random() * 100); @@ -138,6 +158,24 @@ void test_get_create_get(String format) throws IOException { .body("binary-values.size()", equalTo(3)) ; + // Delete the binary time series + given() + .log().ifValidationFails(LogDetail.ALL, true) + .accept(format) + .header("Authorization", user.toHeaderValue()) + .queryParam(Controllers.OFFICE, OFFICE) + .when() + .redirects().follow(true) + .redirects().max(3) + .queryParam(Controllers.OFFICE, OFFICE) + .queryParam(Controllers.BEGIN, BEGIN_STR) + .queryParam(Controllers.END, END_STR) + .queryParam(Controllers.OFFICE, OFFICE) + .delete("/timeseries/binary/" + tsId) + .then() + .log().ifValidationFails(LogDetail.ALL, true) + .assertThat() + .statusCode(is(HttpServletResponse.SC_NO_CONTENT)); } @@ -545,7 +583,7 @@ void test_create_get_update_get(String format) throws IOException { // 2)Create the binary time series // 3)Retrieve the binary time series and assert that it exists // 4)Update the binary time series - // 5)Retrieve the binary time series and assert that it does not exist + // 5)Retrieve the binary time series and assert that value has updated // Step 1) @@ -637,7 +675,7 @@ void test_create_get_update_get(String format) throws IOException { String newValue = "bmV3VmFsdWU="; // Step 5) - // Retrieve the binary time series and assert that it does not exist + // Retrieve the binary time series and assert that it has new value given() .log().ifValidationFails(LogDetail.ALL,true) .accept(format) @@ -656,6 +694,7 @@ void test_create_get_update_get(String format) throws IOException { .body("binary-values.size()", equalTo(3)) .body("binary-values[1].binary-value", equalTo(newValue)) ; + } @NotNull