use of cwms.radar.data.dto.Location 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.Location 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.Location in project cwms-radar-api by USACE.
the class LocationsDaoTest method testDeleteLocation.
@Test
void testDeleteLocation() throws Exception {
Location location = buildTestLocation();
LocationsDaoImpl locationsDao = new LocationsDaoImpl(getDslContext(getConnection(), OFFICE_ID));
locationsDao.storeLocation(location);
locationsDao.deleteLocation(location.getName(), location.getOfficeId());
assertThrows(IOException.class, () -> locationsDao.getLocation(location.getName(), UnitSystem.EN.getValue(), OFFICE_ID));
}
use of cwms.radar.data.dto.Location in project cwms-radar-api by USACE.
the class LocationsDaoTest method testRenameLocation.
@Test
void testRenameLocation() throws Exception {
Location location = buildTestLocation();
Location renamedLocation = new Location.Builder(location).withName("RENAMED_TEST_LOCATION2").build();
LocationsDaoImpl locationsDao = new LocationsDaoImpl(getDslContext(getConnection(), OFFICE_ID));
try {
locationsDao.storeLocation(location);
locationsDao.renameLocation(location.getName(), renamedLocation);
assertThrows(IOException.class, () -> locationsDao.getLocation(location.getName(), UnitSystem.EN.getValue(), OFFICE_ID));
assertNotNull(locationsDao.getLocation(renamedLocation.getName(), UnitSystem.EN.getValue(), OFFICE_ID));
} finally {
locationsDao.deleteLocation(renamedLocation.getName(), location.getOfficeId());
cleanUpRoutine();
}
}
use of cwms.radar.data.dto.Location in project cwms-radar-api by USACE.
the class LocationsDaoTest method cleanUpRoutine.
private void cleanUpRoutine() throws Exception {
Location location = buildTestLocation();
LocationsDaoImpl locationsDao = new LocationsDaoImpl(getDslContext(getConnection(), OFFICE_ID));
try {
locationsDao.deleteLocation(location.getName(), location.getOfficeId());
} catch (IOException ex) {
System.out.println("Location already successfully deleted. Clean-up complete");
}
}
Aggregations