use of org.finra.herd.model.api.xml.StorageAttributesUpdateRequest in project herd by FINRAOS.
the class StorageRestControllerTest method testUpdateStorageAttributes.
@Test
public void testUpdateStorageAttributes() {
// Create a storage key.
StorageKey storageKey = new StorageKey(STORAGE_NAME);
// Create a storage update request.
StorageAttributesUpdateRequest storageAttributesUpdateRequest = new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes());
// Create a storage.
Storage storage = new Storage(STORAGE_NAME, STORAGE_PLATFORM_CODE, businessObjectDefinitionServiceTestHelper.getNewAttributes());
// Mock the external calls.
when(storageService.updateStorageAttributes(storageKey, storageAttributesUpdateRequest)).thenReturn(storage);
// Call the method under test.
Storage result = storageRestController.updateStorageAttributes(STORAGE_NAME, storageAttributesUpdateRequest);
// Verify the external calls.
verify(storageService).updateStorageAttributes(storageKey, storageAttributesUpdateRequest);
verifyNoMoreInteractions(storageService);
// Validate the returned object.
assertEquals(storage, result);
}
use of org.finra.herd.model.api.xml.StorageAttributesUpdateRequest in project herd by FINRAOS.
the class StorageServiceTest method testUpdateStorageAttributes.
@Test
public void testUpdateStorageAttributes() {
// Create and persist a valid storage.
StorageCreateRequest request = getNewStorageCreateRequest();
Storage storage = storageService.createStorage(request);
// Update attributes for the storage.
Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
// Validate the results.
assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), businessObjectDefinitionServiceTestHelper.getNewAttributes2()), result);
}
use of org.finra.herd.model.api.xml.StorageAttributesUpdateRequest in project herd by FINRAOS.
the class StorageServiceTest method testUpdateStorageAttributesRemoveAllAttributes.
@Test
public void testUpdateStorageAttributesRemoveAllAttributes() {
// Create and persist a valid storage.
StorageCreateRequest request = getNewStorageCreateRequest();
Storage storage = storageService.createStorage(request);
// Update attributes for the storage.
Storage result = storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(NO_ATTRIBUTES));
// Validate the results.
assertEquals(new Storage(storage.getName(), storage.getStoragePlatformName(), NO_ATTRIBUTES), result);
}
use of org.finra.herd.model.api.xml.StorageAttributesUpdateRequest in project herd by FINRAOS.
the class StorageServiceTest method testUpdateStorageAttributesStorageHasDuplicateAttributes.
@Test
public void testUpdateStorageAttributesStorageHasDuplicateAttributes() {
// Create and persist a valid storage.
StorageCreateRequest request = getNewStorageCreateRequest();
Storage storage = storageService.createStorage(request);
// Add a duplicate attribute to the storage.
StorageEntity storageEntity = storageDao.getStorageByName(storage.getName());
StorageAttributeEntity storageAttributeEntity = new StorageAttributeEntity();
storageAttributeEntity.setStorage(storageEntity);
storageAttributeEntity.setName(request.getAttributes().get(0).getName().toUpperCase());
storageEntity.getAttributes().add(storageAttributeEntity);
storageDao.saveAndRefresh(storageEntity);
// Try to update attributes for the storage.
try {
storageService.updateStorageAttributes(new StorageKey(storage.getName()), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes2()));
} catch (IllegalStateException e) {
assertEquals(String.format("Found duplicate attribute with name \"%s\" for \"%s\" storage.", request.getAttributes().get(0).getName().toLowerCase(), storage.getName()), e.getMessage());
}
}
use of org.finra.herd.model.api.xml.StorageAttributesUpdateRequest in project herd by FINRAOS.
the class StorageServiceTest method testUpdateStorageAttributesStorageNoExists.
@Test
public void testUpdateStorageAttributesStorageNoExists() {
// Try to update attributes for a storage that doesn't yet exist.
try {
storageService.updateStorageAttributes(new StorageKey(INVALID_VALUE), new StorageAttributesUpdateRequest(businessObjectDefinitionServiceTestHelper.getNewAttributes()));
fail();
} catch (ObjectNotFoundException e) {
assertEquals(String.format("Storage with name \"%s\" doesn't exist.", INVALID_VALUE), e.getMessage());
}
}
Aggregations