use of cwms.radar.data.dto.LocationLevel in project cwms-radar-api by USACE.
the class LocationLevelsDaoTest method testDeleteLocationLevel.
@Disabled
void testDeleteLocationLevel() throws Exception {
LocationLevelsDao levelsDao = new LocationLevelsDaoImpl(getDslContext(getConnection(), "LRL"));
LocationLevel levelToStore = buildExampleLevel("TEST_LOC5");
LocationsDao locationsDao = new LocationsDaoImpl(getDslContext(getConnection(), OFFICE_ID));
Location location = buildTestLocation("TEST_LOC5");
locationsDao.storeLocation(location);
levelsDao.storeLocationLevel(levelToStore, ZoneId.of("UTC"));
LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), OFFICE_ID);
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));
}
use of cwms.radar.data.dto.LocationLevel in project cwms-radar-api by USACE.
the class LocationLevelsDaoTest method deserializeLocationLevel.
private LocationLevel deserializeLocationLevel(String body, String format, String office) throws IOException {
ObjectMapper om = getObjectMapperForFormat(format);
LocationLevel retVal;
try {
retVal = om.readValue(body, LocationLevel.class);
retVal = new LocationLevel.Builder(retVal).withOfficeId(office).build();
} catch (Exception e) {
throw new IOException("Failed to deserialize level");
}
return retVal;
}
use of cwms.radar.data.dto.LocationLevel in project cwms-radar-api by USACE.
the class LocationLevelsDaoTest method buildExampleLevel.
LocationLevel buildExampleLevel(String locationName) throws Exception {
String dateString = "1999-12-05T10:15:30+01:00[UTC]";
List<SeasonalValueBean> seasonalValues = new ArrayList<>();
SeasonalValueBean seasonalVal = new SeasonalValueBean.Builder(10.0).withOffsetMinutes(BigInteger.valueOf(0)).withOffsetMonths(0).build();
seasonalValues.add(0, seasonalVal);
ZonedDateTimeAdapter zonedDateTimeAdapter = new ZonedDateTimeAdapter();
ZonedDateTime unmarshalledDateTime = zonedDateTimeAdapter.unmarshal(dateString);
LocationLevel retval = new LocationLevel.Builder(locationName + ".Elev.Inst.0.Bottom of Inlet", unmarshalledDateTime).withOfficeId(OFFICE_ID).withLevelComment("For testing").withLevelUnitsId(Unit.FEET.getValue()).withSeasonalValues(seasonalValues).withIntervalMonths(1).build();
return retval;
}
use of cwms.radar.data.dto.LocationLevel in project cwms-radar-api by USACE.
the class LocationLevelsDaoTest method testStore.
@Disabled
void testStore() throws Exception {
LocationLevel levelToStore = null;
Location location = null;
try {
levelToStore = buildExampleLevel("TEST_LOC");
LocationsDao locationsDao = new LocationsDaoImpl(getDslContext(getConnection(), OFFICE_ID));
location = buildTestLocation("TEST_LOC");
locationsDao.storeLocation(location);
LocationLevelsDao levelsDao = new LocationLevelsDaoImpl(getDslContext(getConnection(), OFFICE_ID));
levelsDao.storeLocationLevel(levelToStore, ZoneId.of("UTC"));
LocationLevel retrievedLevel = levelsDao.retrieveLocationLevel(levelToStore.getLocationLevelId(), UnitSystem.EN.getValue(), levelToStore.getLevelDate(), "LRL");
assertNotNull(retrievedLevel);
assertEquals(levelToStore.getLocationLevelId(), retrievedLevel.getLocationLevelId());
assertEquals(levelToStore.getLevelDate(), retrievedLevel.getLevelDate());
} finally {
if (levelToStore != null) {
deleteLevel(levelToStore);
}
}
}
use of cwms.radar.data.dto.LocationLevel in project cwms-radar-api by USACE.
the class LevelControllerTest method testDeserializeTimeSeriesLevelJSON.
@Test
void testDeserializeTimeSeriesLevelJSON() throws Exception {
ZonedDateTimeAdapter dateTimeAdapter = new ZonedDateTimeAdapter();
String json = loadResourceAsString("cwms/radar/api/levels_timeseries_create.json");
assertNotNull(json);
LocationLevel level = LevelsController.deserializeLocationLevel(json, Formats.JSON, OFFICE_ID);
assertNotNull(level);
assertEquals("LOC_TEST.Elev.Inst.0.Bottom of Inlet", level.getLocationLevelId());
assertEquals(OFFICE_ID, level.getOfficeId());
assertEquals("ft", level.getLevelUnitsId());
assertEquals(dateTimeAdapter.unmarshal("2008-12-03T10:15:30+01:00[UTC]"), level.getLevelDate());
assertEquals("RYAN3.Stage.Inst.5Minutes.0.ZSTORE_TS_TEST630", level.getSeasonalTimeSeriesId());
}
Aggregations