StorageUnitDaoHelper { public StorageUnitEntity getStorageUnitEntity(String storageName, BusinessObjectDataEntity businessObjectDataEntity) { StorageUnitEntity storageUnitEntity = null; StorageEntity storageEntity = storageDao.getStorageByName(storageName); if (storageEntity != null) { storageUnitEntity = storageUnitDao.getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageEntity); } if (storageUnitEntity == null) { throw new ObjectNotFoundException(String.format("Could not find storage unit in \"%s\" storage for the business object data {%s}.", storageName, businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity))); } return storageUnitEntity; }  StorageUnitEntity findExplicitlyRegisteredSubPartitionInStorageForBusinessObjectData(StorageEntity storageEntity,
        BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectFormat businessObjectFormat, BusinessObjectDataKey businessObjectDataKey); StorageUnitEntity getStorageUnitEntity(String storageName, BusinessObjectDataEntity businessObjectDataEntity); StorageUnitEntity getStorageUnitEntityByBusinessObjectDataAndStorage(BusinessObjectDataEntity businessObjectDataEntity, StorageEntity storageEntity); StorageUnitEntity getStorageUnitEntityByKey(BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey); void setStorageUnitStatus(StorageUnitEntity storageUnitEntity, StorageUnitStatusEntity storageUnitStatusEntity); void updateStorageUnitStatus(StorageUnitEntity storageUnitEntity, String storageUnitStatus, String reason); void updateStorageUnitStatus(StorageUnitEntity storageUnitEntity, StorageUnitStatusEntity storageUnitStatusEntity, String reason); void validateNoExplicitlyRegisteredSubPartitionInStorageForBusinessObjectData(StorageEntity storageEntity,
        BusinessObjectFormatEntity businessObjectFormatEntity, BusinessObjectDataKey businessObjectDataKey, String s3KeyPrefix);  }
@Test public void testGetStorageUnitEntityByBusinessObjectDataAndStorageName() { BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); StorageEntity storageEntity = new StorageEntity(); when(storageDao.getStorageByName(STORAGE_NAME)).thenReturn(storageEntity); when(storageUnitDao.getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageEntity)).thenReturn(storageUnitEntity); StorageUnitEntity result = storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity); assertEquals(storageUnitEntity, result); verify(storageDao).getStorageByName(STORAGE_NAME); verify(storageUnitDao).getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageEntity); verifyNoMoreInteractionsHelper(); }
@Test public void testGetStorageUnitEntityByBusinessObjectDataAndStorageNameStorageUnitNoExists() { BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); StorageEntity storageEntity = new StorageEntity(); when(storageDao.getStorageByName(STORAGE_NAME)).thenReturn(storageEntity); when(storageUnitDao.getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageEntity)).thenReturn(null); when(businessObjectDataHelper.businessObjectDataEntityAltKeyToString(businessObjectDataEntity)).thenReturn(BUSINESS_OBJECT_DATA_KEY_AS_STRING); try { storageUnitDaoHelper.getStorageUnitEntity(STORAGE_NAME, businessObjectDataEntity); fail(); } catch (ObjectNotFoundException e) { assertEquals(String .format("Could not find storage unit in \"%s\" storage for the business object data {%s}.", STORAGE_NAME, BUSINESS_OBJECT_DATA_KEY_AS_STRING), e.getMessage()); } verify(storageDao).getStorageByName(STORAGE_NAME); verify(storageUnitDao).getStorageUnitByBusinessObjectDataAndStorage(businessObjectDataEntity, storageEntity); verify(businessObjectDataHelper).businessObjectDataEntityAltKeyToString(businessObjectDataEntity); verifyNoMoreInteractionsHelper(); }