From adf6345d9d450c7b7879319c391d72ce55640c41 Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Fri, 22 Aug 2025 22:36:05 +0000 Subject: [PATCH 1/6] Initial test to confirm #1242 --- .../java/cwms/cda/api/LevelsControllerTestIT.java | 13 +++++++------ .../java/fixtures/CwmsDataApiSetupCallback.java | 1 + .../src/test/resources/cwms/cda/data/sql/users.sql | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 6 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 40d129369..a351310c5 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 @@ -101,9 +101,10 @@ void cleanup() throws Exception { }); } - @Test - void test_location_level() throws Exception { - createLocation("level_as_single_value", true, OFFICE); + @ParameterizedTest + @ValueSource(strings = {"SPK", "SWT", "MVP"}) + void test_location_level(String office) throws Exception { + createLocation("level_as_single_value", true, office); String levelId = "level_as_single_value.Stor.Ave.1Day.Regulating"; ZonedDateTime time = ZonedDateTime.of(2023, 6, 1, 0, 0, 0, 0, ZoneId.of("America/Los_Angeles")); LocationLevel level = new ConstantLocationLevel.Builder(levelId, time) @@ -113,7 +114,7 @@ void test_location_level() throws Exception { .build(); levelList.add(level); CwmsDataApiSetupCallback.getDatabaseLink().connection(c -> { - DSLContext dsl = dslContext(c, OFFICE); + DSLContext dsl = dslContext(c, office); LocationLevelsDaoImpl dao = new LocationLevelsDaoImpl(dsl); dao.storeLocationLevel(level); }); @@ -123,7 +124,7 @@ void test_location_level() throws Exception { .log().ifValidationFails(LogDetail.ALL,true) .accept(Formats.JSONV2) .contentType(Formats.JSONV2) - .queryParam("office", OFFICE) + .queryParam("office", office) .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) .when() .redirects().follow(true) @@ -143,7 +144,7 @@ void test_location_level() throws Exception { .log().ifValidationFails(LogDetail.ALL,true) .accept(Formats.JSONV2) .contentType(Formats.JSONV2) - .queryParam("office", OFFICE) + .queryParam("office", office) .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) .queryParam(UNIT, "ac-ft") .when() diff --git a/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java b/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java index 6fafb2664..661293e8d 100644 --- a/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java +++ b/cwms-data-api/src/test/java/fixtures/CwmsDataApiSetupCallback.java @@ -220,6 +220,7 @@ private void loadDefaultData(CwmsDatabaseContainer cwmsDb) throws SQLException { user = cwmsDb.getUsername(); } logger.atInfo().log(String.format("Running %s as %s %s", data, user, cwmsDb.getPassword())); + logger.atInfo().log("Webuser = " + webUser); cwmsDb.executeSQL(loadResourceAsString(user_resource[1]).replace("&pduser", cwmsDb.getPdUser()) .replace("&user", cwmsDb.getUsername()) .replace("&webuser", webUser) diff --git a/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql b/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql index 8cbb41a7e..50a11cc4d 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql +++ b/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql @@ -41,6 +41,12 @@ begin cwms_sec.add_user_to_group('&webuser','CWMS Users', 'SWT'); cwms_sec.add_user_to_group('&webuser','CWMS PD Users', 'SWT'); cwms_sec.add_user_to_group('&webuser','CWMS DBA Users', 'SWT'); + cwms_sec.add_user_to_group('&webuser','All Users', 'MVP'); + cwms_sec.add_user_to_group('&webuser','CWMS Users', 'MVP'); + cwms_sec.add_user_to_group('&webuser','CWMS PD Users', 'MVP'); + cwms_sec.add_user_to_group('&webuser','CWMS DBA Users', 'MVP'); + + cwms_sec.add_user_to_group('&user','All Users', 'HQ'); cwms_sec.add_user_to_group('&user','CWMS Users', 'HQ'); cwms_sec.add_user_to_group('&user','CWMS PD Users', 'HQ'); @@ -49,6 +55,14 @@ begin cwms_sec.add_user_to_group('&user','CWMS Users', 'SPK'); cwms_sec.add_user_to_group('&user','CWMS PD Users', 'SPK'); cwms_sec.add_user_to_group('&user','CWMS DBA Users', 'SPK'); + cwms_sec.add_user_to_group('&user','All Users', 'SWT'); + cwms_sec.add_user_to_group('&user','CWMS Users', 'SWT'); + cwms_sec.add_user_to_group('&user','CWMS PD Users', 'SWT'); + cwms_sec.add_user_to_group('&user','CWMS DBA Users', 'SWT'); + cwms_sec.add_user_to_group('&user','All Users', 'MVP'); + cwms_sec.add_user_to_group('&user','CWMS Users', 'MVP'); + cwms_sec.add_user_to_group('&user','CWMS PD Users', 'MVP'); + cwms_sec.add_user_to_group('&user','CWMS DBA Users', 'MVP'); execute immediate 'grant execute on cwms_upass to web_user'; /** Add a couple of districts*/ begin From 7f3ff6a3fd9181af8ce289c48daa7e2c7367a1d2 Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Mon, 25 Aug 2025 16:13:29 +0000 Subject: [PATCH 2/6] Adjust test setup. --- .../src/test/java/cwms/cda/api/LevelsControllerTestIT.java | 2 +- cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql | 4 +++- 2 files changed, 4 insertions(+), 2 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 a351310c5..5f7779c72 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 @@ -108,7 +108,7 @@ void test_location_level(String office) throws Exception { String levelId = "level_as_single_value.Stor.Ave.1Day.Regulating"; ZonedDateTime time = ZonedDateTime.of(2023, 6, 1, 0, 0, 0, 0, ZoneId.of("America/Los_Angeles")); LocationLevel level = new ConstantLocationLevel.Builder(levelId, time) - .withOfficeId(OFFICE) + .withOfficeId(office) .withLevelUnitsId("ac-ft") .withConstantValue(1.0) .build(); diff --git a/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql b/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql index 50a11cc4d..6322b788a 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql +++ b/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql @@ -41,11 +41,13 @@ begin cwms_sec.add_user_to_group('&webuser','CWMS Users', 'SWT'); cwms_sec.add_user_to_group('&webuser','CWMS PD Users', 'SWT'); cwms_sec.add_user_to_group('&webuser','CWMS DBA Users', 'SWT'); + cwms_sec.add_user_to_group('&webuser','All Users', 'MVP'); + /* cwms_sec.add_user_to_group('&webuser','CWMS Users', 'MVP'); cwms_sec.add_user_to_group('&webuser','CWMS PD Users', 'MVP'); cwms_sec.add_user_to_group('&webuser','CWMS DBA Users', 'MVP'); - +*/ cwms_sec.add_user_to_group('&user','All Users', 'HQ'); cwms_sec.add_user_to_group('&user','CWMS Users', 'HQ'); From 560ca9e15a1b188585418fe1f160710dc2e94a76 Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Mon, 25 Aug 2025 16:55:30 +0000 Subject: [PATCH 3/6] location level getOne returns expected results. --- .../java/cwms/cda/api/LevelsController.java | 3 ++- .../cda/data/dao/LocationLevelsDaoImpl.java | 2 +- .../cwms/cda/api/LevelsControllerTestIT.java | 19 +++++++++++++++++++ .../resources/cwms/cda/data/sql/users.sql | 7 +------ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java b/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java index d681878e4..3bf0d1a94 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java @@ -330,7 +330,8 @@ public void getAll(@NotNull Context ctx) { @OpenApiParam(name = OFFICE, required = true, description = "Specifies the " + "office of the Location Level to be returned"), @OpenApiParam(name = EFFECTIVE_DATE, required = true, description = "Specifies " - + "the effective date of Location Level to be returned. " + + "the effective date of Location Level to be returned. The most recent level " + + "on or before this time will be returned." + "Expected formats are `YYYY-MM-DDTHH:MM` or `YYYY-MM-DDTHH:MM:SS`"), @OpenApiParam(name = TIMEZONE, description = "Specifies the time zone of " + "the values of the effective date field (unless otherwise " diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java index a49ba0f27..d5fc019a5 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java @@ -483,7 +483,7 @@ public LocationLevel retrieveLocationLevel(String locationLevelName, String pUni LOCATION_LEVEL_T level = CWMS_LEVEL_PACKAGE.call_RETRIEVE_LOCATION_LEVEL__2( configuration, locationLevelName, units, date, "UTC", null, null, - null, "T", officeId, "VN"); + null, "F", officeId, "VN"); if (level == null) { throw new NotFoundException("Location level not found: " + locationLevelName); } 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 5f7779c72..db4ef12c8 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 @@ -157,6 +157,25 @@ void test_location_level(String office) throws Exception { .statusCode(is(HttpServletResponse.SC_OK)) .body("level-units-id",equalTo("ac-ft")) .body("constant-value",equalTo(1.0F)); + + // test modified effective date + given() + .log().ifValidationFails(LogDetail.ALL,true) + .accept(Formats.JSONV2) + .contentType(Formats.JSONV2) + .queryParam("office", office) + .queryParam(EFFECTIVE_DATE, time.plusDays(1L).toInstant().toString()) + .queryParam(UNIT, "ac-ft") + .when() + .redirects().follow(true) + .redirects().max(3) + .get("/levels/{level-id}", levelId) + .then() + .assertThat() + .log().ifValidationFails(LogDetail.ALL,true) + .statusCode(is(HttpServletResponse.SC_OK)) + .body("level-units-id",equalTo("ac-ft")) + .body("constant-value",equalTo(1.0F)); } @Test diff --git a/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql b/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql index 6322b788a..8d6136b83 100644 --- a/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql +++ b/cwms-data-api/src/test/resources/cwms/cda/data/sql/users.sql @@ -41,13 +41,8 @@ begin cwms_sec.add_user_to_group('&webuser','CWMS Users', 'SWT'); cwms_sec.add_user_to_group('&webuser','CWMS PD Users', 'SWT'); cwms_sec.add_user_to_group('&webuser','CWMS DBA Users', 'SWT'); - + cwms_sec.add_user_to_group('&webuser','All Users', 'MVP'); - /* - cwms_sec.add_user_to_group('&webuser','CWMS Users', 'MVP'); - cwms_sec.add_user_to_group('&webuser','CWMS PD Users', 'MVP'); - cwms_sec.add_user_to_group('&webuser','CWMS DBA Users', 'MVP'); -*/ cwms_sec.add_user_to_group('&user','All Users', 'HQ'); cwms_sec.add_user_to_group('&user','CWMS Users', 'HQ'); From 4380d0f6b8eaf7914d7e9932862d42e168429b5d Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Mon, 25 Aug 2025 19:16:11 +0000 Subject: [PATCH 4/6] Add exact match as a parameter. --- .../main/java/cwms/cda/api/Controllers.java | 1 + .../java/cwms/cda/api/LevelsController.java | 15 +++++++++---- .../cwms/cda/data/dao/LocationLevelsDao.java | 2 +- .../cda/data/dao/LocationLevelsDaoImpl.java | 6 +++--- .../cwms/cda/api/LevelsControllerTestIT.java | 21 +++++++++++++++++++ .../cda/data/dao/LocationLevelsDaoTest.java | 10 ++++----- 6 files changed, 42 insertions(+), 13 deletions(-) diff --git a/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java b/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java index 8e82f5095..346030bc6 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/Controllers.java @@ -110,6 +110,7 @@ public final class Controllers { public static final String TEMPLATE_ID_MASK = "template-id-mask"; public static final String STORE_TEMPLATE = "store-template"; public static final String REPLACE_BASE_CURVE = "replace-base-curve"; + public static final String EFFECTIVE_DATE_EXACT = "use-exact-effective-date"; public static final String TIMESERIES_ID_REGEX = "timeseries-id-regex"; public static final String TIMESERIES_ID = "timeseries-id"; diff --git a/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java b/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java index 3bf0d1a94..6561573db 100644 --- a/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java +++ b/cwms-data-api/src/main/java/cwms/cda/api/LevelsController.java @@ -330,9 +330,14 @@ public void getAll(@NotNull Context ctx) { @OpenApiParam(name = OFFICE, required = true, description = "Specifies the " + "office of the Location Level to be returned"), @OpenApiParam(name = EFFECTIVE_DATE, required = true, description = "Specifies " - + "the effective date of Location Level to be returned. The most recent level " - + "on or before this time will be returned." + + "the effective date of Location Level to be returned." + "Expected formats are `YYYY-MM-DDTHH:MM` or `YYYY-MM-DDTHH:MM:SS`"), + @OpenApiParam(name= EFFECTIVE_DATE_EXACT, required = false, description = "If true" + + " only a level with the exact provided date will be returned. If false" + + " The most recent level on or before this time will be returned." + + " The default is false.", + type = Boolean.class + ), @OpenApiParam(name = TIMEZONE, description = "Specifies the time zone of " + "the values of the effective date field (unless otherwise " + "specified), as well as the time zone of any times in the response." @@ -365,6 +370,8 @@ public void getOne(@NotNull Context ctx, @NotNull String levelId) { String dateString = queryParamAsClass(ctx, new String[]{EFFECTIVE_DATE, DATE}, String.class, null, metrics, name(LevelsController.class.getName(), GET_ONE)); + boolean exactDateMatch = queryParamAsClass(ctx, new String[]{EFFECTIVE_DATE_EXACT}, + Boolean.class, false, metrics, name(LevelsController.class.getName(),GET_ONE)); String timezone = ctx.queryParamAsClass(TIMEZONE, String.class) .getOrDefault("UTC"); @@ -375,7 +382,7 @@ String.class, null, metrics, name(LevelsController.class.getName(), LocationLevelsDao levelsDao = getLevelsDao(dsl); //retrieveLocationLevel will throw an error if level does not exist LocationLevel locationLevel = levelsDao.retrieveLocationLevel(levelId, - units, unmarshalledDateTime, office); + units, unmarshalledDateTime, office, exactDateMatch); ctx.json(locationLevel); ctx.status(HttpServletResponse.SC_OK); } @@ -432,7 +439,7 @@ public void update(@NotNull Context ctx, @NotNull String oldLevelId) { ZoneId.systemDefault().getId()); //retrieveLocationLevel will throw an error if level does not exist LocationLevel existingLevelLevel = levelsDao.retrieveLocationLevel(oldLevelId, - UnitSystem.EN.getValue(), unmarshalledDateTime, officeId); + UnitSystem.EN.getValue(), unmarshalledDateTime, officeId, true); existingLevelLevel = updatedClearedFields(ctx.body(), contentType.getType(), existingLevelLevel); //only store (update) if level does exist diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDao.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDao.java index 822e8ff8e..1fd8039e6 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDao.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDao.java @@ -43,7 +43,7 @@ void deleteLocationLevel(String locationLevelName, ZonedDateTime date, String of void renameLocationLevel(String oldLocationLevelName, String newLocationLevelName, String officeId); LocationLevel retrieveLocationLevel(String locationLevelName, String unitSystem, - ZonedDateTime effectiveDate, String officeId); + ZonedDateTime effectiveDate, String officeId, boolean exactDateMatch); String getLocationLevels(String format, String names, String office, String unit, String datum, String begin, diff --git a/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java b/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java index d5fc019a5..90e5c8037 100644 --- a/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java +++ b/cwms-data-api/src/main/java/cwms/cda/data/dao/LocationLevelsDaoImpl.java @@ -458,7 +458,7 @@ public void renameLocationLevel(String oldLocationLevelName, String newLocationL @Override public LocationLevel retrieveLocationLevel(String locationLevelName, String pUnits, - ZonedDateTime effectiveDate, String officeId) { + ZonedDateTime effectiveDate, String officeId,boolean exactDateMatch) { Timestamp date = Timestamp.from(effectiveDate.toInstant()); String[] levelIdParts = locationLevelIdParsingPattern.split(locationLevelName); if (levelIdParts.length <= 2) { @@ -483,9 +483,9 @@ public LocationLevel retrieveLocationLevel(String locationLevelName, String pUni LOCATION_LEVEL_T level = CWMS_LEVEL_PACKAGE.call_RETRIEVE_LOCATION_LEVEL__2( configuration, locationLevelName, units, date, "UTC", null, null, - null, "F", officeId, "VN"); + null, formatBool(exactDateMatch), officeId, "VN"); if (level == null) { - throw new NotFoundException("Location level not found: " + locationLevelName); + throw new NotFoundException("Location level not found: " + officeId + "/" + locationLevelName); } Timestamp pEffectiveDate = level.getLEVEL_DATE(); ZonedDateTime realEffectiveDate = ZonedDateTime.ofInstant(pEffectiveDate.toInstant(), effectiveDate.getZone()); 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 db4ef12c8..b2852eb47 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 @@ -176,6 +176,24 @@ void test_location_level(String office) throws Exception { .statusCode(is(HttpServletResponse.SC_OK)) .body("level-units-id",equalTo("ac-ft")) .body("constant-value",equalTo(1.0F)); + + // test modified effective date using exact match + given() + .log().ifValidationFails(LogDetail.ALL,true) + .accept(Formats.JSONV2) + .contentType(Formats.JSONV2) + .queryParam("office", office) + .queryParam(EFFECTIVE_DATE, time.plusDays(1L).toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) + .queryParam(UNIT, "ac-ft") + .when() + .redirects().follow(true) + .redirects().max(3) + .get("/levels/{level-id}", levelId) + .then() + .assertThat() + .log().ifValidationFails(LogDetail.ALL,true) + .statusCode(is(HttpServletResponse.SC_NOT_FOUND)); } @Test @@ -1355,6 +1373,7 @@ void testStoreRetrieveAllVirtualLocationLevelsPaged() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) @@ -1372,6 +1391,7 @@ void testStoreRetrieveAllVirtualLocationLevelsPaged() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) @@ -1389,6 +1409,7 @@ void testStoreRetrieveAllVirtualLocationLevelsPaged() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) diff --git a/cwms-data-api/src/test/java/cwms/cda/data/dao/LocationLevelsDaoTest.java b/cwms-data-api/src/test/java/cwms/cda/data/dao/LocationLevelsDaoTest.java index 6b762a63c..50009a0c7 100644 --- a/cwms-data-api/src/test/java/cwms/cda/data/dao/LocationLevelsDaoTest.java +++ b/cwms-data-api/src/test/java/cwms/cda/data/dao/LocationLevelsDaoTest.java @@ -70,7 +70,7 @@ void testStore() throws Exception locationsDao.storeLocation(location, false); LocationLevelsDao levelsDao = new LocationLevelsDaoImpl(getDslContext(getConnection(), OFFICE_ID)); levelsDao.storeLocationLevel(levelToStore); - LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), "LRL"); + LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), "LRL", true); assertNotNull(retrievedLevel); assertEquals(levelToStore.getLocationLevelId(), retrievedLevel.getLocationLevelId()); assertEquals(levelToStore.getLevelDate(), retrievedLevel.getLevelDate()); @@ -92,10 +92,10 @@ void testDeleteLocationLevel() throws Exception Location location = buildTestLocation("TEST_LOC5"); locationsDao.storeLocation(location, false); levelsDao.storeLocationLevel(levelToStore); - LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), OFFICE_ID); + LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), OFFICE_ID, true); assertNotNull(retrievedLevel); levelsDao.deleteLocationLevel(levelToStore.getLocationLevelId(), levelToStore.getLevelDate(), OFFICE_ID, true); - assertThrows(IOException.class, () -> levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), OFFICE_ID)); + assertThrows(IOException.class, () -> levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), OFFICE_ID, true)); } @Disabled @@ -114,7 +114,7 @@ void testUpdate() throws Exception String format = Formats.JSON; SeasonalLocationLevel levelFromBody = deserializeLocationLevel(body, Formats.JSON, OFFICE_ID); - existingLocationLevel = (SeasonalLocationLevel) levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelFromBody.getLevelDate(), OFFICE_ID); + existingLocationLevel = (SeasonalLocationLevel) levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelFromBody.getLevelDate(), OFFICE_ID, true); existingLocationLevel = updatedClearedFields(body, format, existingLocationLevel); //only store (update) if level does exist updatedLocationLevel = getUpdatedLocationLevel(existingLocationLevel, levelFromBody); @@ -126,7 +126,7 @@ void testUpdate() throws Exception } else { levelsDao.storeLocationLevel(updatedLocationLevel); } - LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(updatedLocationLevel.getLocationLevelId(), UnitSystem.EN.getValue(), updatedLocationLevel.getLevelDate(), OFFICE_ID); + LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(updatedLocationLevel.getLocationLevelId(), UnitSystem.EN.getValue(), updatedLocationLevel.getLevelDate(), OFFICE_ID, true); assertNotNull(retrievedLevel); } finally { From e9d920acb6443a4aff30d66029fa49135279c6a8 Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Mon, 25 Aug 2025 20:58:53 +0000 Subject: [PATCH 5/6] Additional test adjustments. --- .../src/test/java/cwms/cda/api/LevelsControllerTestIT.java | 3 +++ 1 file changed, 3 insertions(+) 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 b2852eb47..89a334482 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 @@ -1006,6 +1006,7 @@ void testStoreRetrieveVirtualLocationLevels() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) @@ -1175,6 +1176,7 @@ void testStoreRetrieveAllVirtualLocationLevels() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) @@ -1566,6 +1568,7 @@ void testStoreDeleteVirtualLocationLevel(String deletionMethod) throws Exception .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) From 4c633ffd08f47e1754f0d3899d689aa648cc86bb Mon Sep 17 00:00:00 2001 From: Mike Neilson Date: Mon, 25 Aug 2025 21:19:26 +0000 Subject: [PATCH 6/6] Adjust even more sections. --- .../src/test/java/cwms/cda/api/LevelsControllerTestIT.java | 6 ++++++ 1 file changed, 6 insertions(+) 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 89a334482..59e91ce9f 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 @@ -1023,6 +1023,7 @@ void testStoreRetrieveVirtualLocationLevels() throws Exception { .contentType(Formats.JSONV2) .queryParam("office", OFFICE) .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .queryParam(UNIT, "ft") .when() .redirects().follow(true) @@ -1040,6 +1041,7 @@ void testStoreRetrieveVirtualLocationLevels() throws Exception { .contentType(Formats.JSONV2) .queryParam("office", OFFICE) .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .queryParam(UNIT, "EN") .when() .redirects().follow(true) @@ -1058,6 +1060,7 @@ void testStoreRetrieveVirtualLocationLevels() throws Exception { .contentType(Formats.JSONV2) .queryParam("office", OFFICE) .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .queryParam(UNIT, "ft3") .when() .redirects().follow(true) @@ -1194,6 +1197,7 @@ void testStoreRetrieveAllVirtualLocationLevels() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) @@ -1211,6 +1215,7 @@ void testStoreRetrieveAllVirtualLocationLevels() throws Exception { .queryParam(Controllers.OFFICE, OFFICE) .queryParam(UNIT, "SI") .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .when() .redirects().follow(true) .redirects().max(3) @@ -1586,6 +1591,7 @@ void testStoreDeleteVirtualLocationLevel(String deletionMethod) throws Exception .contentType(Formats.JSONV2) .queryParam("office", OFFICE) .queryParam(EFFECTIVE_DATE, time.toInstant().toString()) + .queryParam(EFFECTIVE_DATE_EXACT, true) .queryParam(UNIT, "ft3") .when() .redirects().follow(true)