Search in sources :

Example 1 with Location

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));
}
Also used : LocationLevel(cwms.radar.data.dto.LocationLevel) Location(cwms.radar.data.dto.Location) Disabled(org.junit.jupiter.api.Disabled)

Example 2 with Location

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);
        }
    }
}
Also used : LocationLevel(cwms.radar.data.dto.LocationLevel) Location(cwms.radar.data.dto.Location) Disabled(org.junit.jupiter.api.Disabled)

Example 3 with Location

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));
}
Also used : Location(cwms.radar.data.dto.Location) Test(org.junit.jupiter.api.Test)

Example 4 with Location

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();
    }
}
Also used : Location(cwms.radar.data.dto.Location) Test(org.junit.jupiter.api.Test)

Example 5 with Location

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");
    }
}
Also used : IOException(java.io.IOException) Location(cwms.radar.data.dto.Location)

Aggregations

Location (cwms.radar.data.dto.Location)15 IOException (java.io.IOException)6 Test (org.junit.jupiter.api.Test)5 Timer (com.codahale.metrics.Timer)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 RadarError (cwms.radar.api.errors.RadarError)3 LocationsDao (cwms.radar.data.dao.LocationsDao)3 LocationLevel (cwms.radar.data.dto.LocationLevel)3 ContentType (cwms.radar.formatters.ContentType)3 FormattingException (cwms.radar.formatters.FormattingException)3 DSLContext (org.jooq.DSLContext)3 Disabled (org.junit.jupiter.api.Disabled)3 BeanDescription (com.fasterxml.jackson.databind.BeanDescription)1 JavaType (com.fasterxml.jackson.databind.JavaType)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 BeanPropertyDefinition (com.fasterxml.jackson.databind.introspect.BeanPropertyDefinition)1 BigDecimal (java.math.BigDecimal)1