From a50d2a0ce935886413ef60c5717fd20f6d479d75 Mon Sep 17 00:00:00 2001 From: zack-rma Date: Tue, 25 Aug 2026 10:07:06 -0700 Subject: [PATCH] CWMS-2518 bug recreation data insertion test --- .../cwms/cda/api/LevelsControllerTestIT.java | 39 +++++++++++++++++++ .../java/cwms/cda/api/LocationCleanup.java | 10 ++--- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/cwms-data-api/src/test/java/cwms/cda/api/LevelsControllerTestIT.java b/cwms-data-api/src/test/java/cwms/cda/api/LevelsControllerTestIT.java index 22e7bc0c95..e8b393592b 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/LevelsControllerTestIT.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/LevelsControllerTestIT.java @@ -2567,4 +2567,43 @@ private void createVirtualLocation(String specXml, String setXml, ZonedDateTime } }); } + + @Test + void test_insert_test_Data() throws Exception { + String locName = "SuperiorLake"; + createLocation(locName, true, OFFICE); + String levelId = String.format("%s.Stage.Ave.1Month.CoordinatedStatistics", locName); + ZonedDateTime time = ZonedDateTime.ofInstant(Instant.parse("2025-06-27T21:00:00Z"), ZoneId.of("UTC")); + List seasonalValues = new ArrayList<>(); + for (int i = 0; i < 12; i++) { + seasonalValues.add(new SeasonalValueBean.Builder().withValue(601.51 * 1.01).withOffsetMonths(i + 1).build()); + } + + SeasonalLocationLevel level = new SeasonalLocationLevel.Builder(levelId, time.toInstant()) + .withOfficeId(OFFICE) + .withLevelUnitsId("ft") + .withInterpolateString("F") + .withIntervalMonths(12) + .withSeasonalValues(seasonalValues) + .build(); + + String levelJson = Formats.format(new ContentType(Formats.JSONV2), level); + + given() + .log().ifValidationFails(LogDetail.ALL, true) + .queryParam(Controllers.OFFICE, OFFICE) + .header("Authorization", TestAccounts.KeyUser.SPK_NORMAL.toHeaderValue()) + .body(levelJson) + .contentType(Formats.JSONV2) + .when() + .redirects() + .follow(true) + .redirects() + .max(3) + .post("/levels/") + .then() + .log().ifValidationFails(LogDetail.ALL, true) + .assertThat() + .statusCode(is(HttpServletResponse.SC_CREATED)); + } } diff --git a/cwms-data-api/src/test/java/cwms/cda/api/LocationCleanup.java b/cwms-data-api/src/test/java/cwms/cda/api/LocationCleanup.java index d0e89be4fe..7eed49d653 100644 --- a/cwms-data-api/src/test/java/cwms/cda/api/LocationCleanup.java +++ b/cwms-data-api/src/test/java/cwms/cda/api/LocationCleanup.java @@ -46,11 +46,11 @@ public class LocationCleanup implements TestExecutionListener { @Override public void testPlanExecutionFinished(TestPlan testPlan) { - try { - cleanupLocations(); - } catch (IOException e) { - throw new RuntimeException(e); - } +// try { +// cleanupLocations(); +// } catch (IOException e) { +// throw new RuntimeException(e); +// } } /**