BusinessObjectDataStorageUnitServiceImpl implements BusinessObjectDataStorageUnitService { @PublishNotificationMessages @NamespacePermission(fields = "#request.businessObjectDataStorageUnitKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public BusinessObjectDataStorageUnitCreateResponse createBusinessObjectDataStorageUnit(BusinessObjectDataStorageUnitCreateRequest request) { return createBusinessObjectDataStorageUnitImpl(request); }  @PublishNotificationMessages @NamespacePermission(fields = "#request.businessObjectDataStorageUnitKey.namespace", permissions = NamespacePermissionEnum.WRITE) @Override @Transactional(propagation = Propagation.REQUIRES_NEW) BusinessObjectDataStorageUnitCreateResponse createBusinessObjectDataStorageUnit(BusinessObjectDataStorageUnitCreateRequest request);  }
@Test public void testCreateBusinessObjectDataStorageUnit() { BusinessObjectDataKey businessObjectDataKey = new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION); BusinessObjectDataStorageUnitKey businessObjectDataStorageUnitKey = new BusinessObjectDataStorageUnitKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES, DATA_VERSION, STORAGE_NAME); StorageDirectory storageDirectory = new StorageDirectory(STORAGE_DIRECTORY_PATH); List<StorageFile> storageFiles = Arrays.asList(new StorageFile(FILE_NAME, FILE_SIZE, ROW_COUNT), new StorageFile(FILE_NAME_2, FILE_SIZE_2, ROW_COUNT_2)); BusinessObjectDataStorageUnitCreateRequest request = new BusinessObjectDataStorageUnitCreateRequest(businessObjectDataStorageUnitKey, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES); BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity(); businessObjectDataEntity.setId(ID); StorageEntity storageEntity = new StorageEntity(); storageEntity.setName(STORAGE_NAME); List<StorageFileEntity> storageFileEntities = Arrays.asList(new StorageFileEntity(), new StorageFileEntity()); StorageUnitEntity storageUnitEntity = new StorageUnitEntity(); storageUnitEntity.setBusinessObjectData(businessObjectDataEntity); storageUnitEntity.setStorage(storageEntity); storageUnitEntity.setDirectoryPath(STORAGE_DIRECTORY_PATH); storageUnitEntity.setStorageFiles(storageFileEntities); BusinessObjectDataStorageUnitCreateResponse expectedResponse = new BusinessObjectDataStorageUnitCreateResponse(businessObjectDataStorageUnitKey, storageDirectory, storageFiles); when(storageUnitHelper.getBusinessObjectDataKey(businessObjectDataStorageUnitKey)).thenReturn(businessObjectDataKey); when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity); when(storageDaoHelper.getStorageEntity(STORAGE_NAME)).thenReturn(storageEntity); when(businessObjectDataDaoHelper .createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES)) .thenReturn(storageUnitEntity); when(businessObjectDataHelper.createBusinessObjectDataKeyFromEntity(businessObjectDataEntity)).thenReturn(businessObjectDataKey); when(storageUnitHelper.createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME)).thenReturn(businessObjectDataStorageUnitKey); when(storageFileHelper.createStorageFilesFromEntities(storageFileEntities)).thenReturn(storageFiles); BusinessObjectDataStorageUnitCreateResponse result = businessObjectDataStorageUnitServiceImpl.createBusinessObjectDataStorageUnit(request); verify(storageUnitHelper).validateBusinessObjectDataStorageUnitKey(businessObjectDataStorageUnitKey); verify(storageFileHelper).validateCreateRequestStorageFiles(storageFiles); verify(storageUnitHelper).getBusinessObjectDataKey(businessObjectDataStorageUnitKey); verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey); verify(storageDaoHelper).getStorageEntity(STORAGE_NAME); verify(businessObjectDataDaoHelper) .createStorageUnitEntity(businessObjectDataEntity, storageEntity, storageDirectory, storageFiles, NO_DISCOVER_STORAGE_FILES); verify(businessObjectDataHelper).createBusinessObjectDataKeyFromEntity(businessObjectDataEntity); verify(storageUnitHelper).createBusinessObjectDataStorageUnitKey(businessObjectDataKey, STORAGE_NAME); verify(storageFileHelper).createStorageFilesFromEntities(storageFileEntities); verify(storageUnitDao).saveAndRefresh(storageUnitEntity); verifyNoMoreInteractionsHelper(); assertEquals(expectedResponse, result); }