Skip to content

Set the level date to the actual date rather than parameterized date #1081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,9 @@ public LocationLevel retrieveLocationLevel(String locationLevelName, String pUni
logger.info("Default units are " + defaultUnits);
units = defaultUnits;
}
return new LocationLevel.Builder(locationLevelName, effectiveDate)
Timestamp pEffectiveDate = level.getP_EFFECTIVE_DATE();
ZonedDateTime realEffectiveDate = ZonedDateTime.ofInstant(pEffectiveDate.toInstant(), effectiveDate.getZone());
return new LocationLevel.Builder(locationLevelName, realEffectiveDate)
.withLevelUnitsId(units)
.withAttributeUnitsId(units)
.withInterpolateString(level.getP_INTERPOLATE())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,44 @@ void test_location_level() throws Exception {
.body("constant-value",equalTo(1.0F));
}

@Test
void test_retrieve_effective_date() throws Exception {
createLocation("level_with_effect", true, OFFICE);
String levelId = "level_with_effect.Flow.Ave.1Day.Regulating";
ZonedDateTime time = ZonedDateTime.of(2023, 6, 1, 0, 0, 0, 0, ZoneId.of("America/Los_Angeles"));
CwmsDataApiSetupCallback.getDatabaseLink().connection(c -> {
LocationLevel level = new LocationLevel.Builder(levelId, time)
.withOfficeId(OFFICE)
.withConstantValue(1.0)
.withLevelUnitsId("cms")
.build();
levelList.add(level);
DSLContext dsl = dslContext(c, OFFICE);
LocationLevelsDaoImpl dao = new LocationLevelsDaoImpl(dsl);
dao.storeLocationLevel(level);
});

ExtractableResponse<Response> response = given()
.log().ifValidationFails(LogDetail.ALL, true)
.accept(Formats.JSONV2)
.contentType(Formats.JSONV2)
.queryParam(Controllers.OFFICE, OFFICE)
.queryParam(LEVEL_ID_MASK, "level_with_effect*")
.queryParam(BEGIN, "2020-06-01T00:00:00Z")
.when()
.redirects().follow(true)
.redirects().max(3)
.get("/levels/")
.then()
.log().ifValidationFails(LogDetail.ALL, true)
.assertThat()
.statusCode(is(HttpServletResponse.SC_OK))
.extract();

assertEquals("2023-06-01T07:00:00Z", response.path("levels[0].level-date"));
}


@Test
void test_retrieve_time_window() throws Exception {
createLocation("level_get_all_loc_1", true, OFFICE);
Expand Down
Loading