use of org.finra.herd.model.api.xml.StorageKey in project herd by FINRAOS.
the class StorageServiceTest method testGetStorageInvalidStorageName.
@Test
public void testGetStorageInvalidStorageName() {
// Try getting a storage that doesn't exist.
try {
storageService.getStorage(new StorageKey(INVALID_VALUE));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageKey in project herd by FINRAOS.
the class StorageServiceTest method testDeleteStorageInvalidName.
@Test
public void testDeleteStorageInvalidName() {
// Try to delete a storage which doesn't exist.
try {
storageService.deleteStorage(new StorageKey(INVALID_VALUE));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageKey in project herd by FINRAOS.
the class StorageServiceTest method testDeleteStorageConstraintViolation.
/*
* This test is ignored because the constraint validation is a DB dependent feature. This method had inconsistent behavior between Oracle and PostgreSQL.
* Oracle was throwing the error after each statement, whereas PostgreSQL would not because it by default raises error only when transaction is committed.
*
* Besides, this test case is not valid as a use case as normal transactions wouldn't delete after insert within same transaction.
*/
@Ignore
@Test(expected = PersistenceException.class)
public void testDeleteStorageConstraintViolation() throws Exception {
// Create a storage unit entity that refers to a newly created storage.
final StorageUnitEntity storageUnitEntity = storageUnitDaoTestHelper.createStorageUnitEntity(STORAGE_NAME, BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, LATEST_VERSION_FLAG_SET, BDATA_STATUS, STORAGE_UNIT_STATUS, NO_STORAGE_DIRECTORY_PATH);
executeWithoutLogging(SqlExceptionHelper.class, new Command() {
@Override
public void execute() {
// Delete the storage which is invalid because there still exists a storage unit entity that references it.
StorageKey alternateKey = new StorageKey(storageUnitEntity.getStorage().getName());
storageService.deleteStorage(alternateKey);
}
});
}
use of org.finra.herd.model.api.xml.StorageKey in project herd by FINRAOS.
the class StorageServiceTest method testGetAllStorage.
@Test
public void testGetAllStorage() {
// Get a list of test storage keys.
List<StorageKey> storageKeys = storageDaoTestHelper.getTestStorageKeys();
// Create and persist test storage entities.
for (StorageKey storageKey : storageKeys) {
storageDaoTestHelper.createStorageEntity(storageKey.getStorageName());
}
// Retrieve a list of storage keys.
StorageKeys result = storageService.getAllStorage();
// Validate the results.
assertNotNull(result);
assertTrue(result.getStorageKeys().containsAll(storageKeys));
}
Aggregations