@Test
public void testCleanupS3StorageUnitWithIllegalArgumentException()
{

    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey =
        new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES,
            DATA_VERSION);
    // Create a storage unit key.
    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);
    // Create mocks
    BusinessObjectDataEntity businessObjectDataEntity = mock(BusinessObjectDataEntity.class);
    // Create storage units
    StoragePlatformEntity storagePlatformEntity = new StoragePlatformEntity();
    storagePlatformEntity.setName(StoragePlatformEntity.S3);
    StorageEntity storageEntity = new StorageEntity();
    storageEntity.setStoragePlatform(storagePlatformEntity);
    StorageUnitEntity storageUnitEntity1 = new StorageUnitEntity();
    storageUnitEntity1.setStorage(storageEntity);
    StorageUnitEntity storageUnitEntity2 = new StorageUnitEntity();
    storageUnitEntity2.setStorage(storageEntity);
    Collection<StorageUnitEntity> storageUnitEntities = Lists.newArrayList();
    storageUnitEntities.add(storageUnitEntity1);
    storageUnitEntities.add(storageUnitEntity2);
    // Mock the external calls.
    when(mockBusinessObjectDataHelper.createBusinessObjectDataKeyFromStorageUnitKey(businessObjectDataStorageUnitKey)).thenReturn(businessObjectDataKey);
    when(mockBusinessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataKey)).thenReturn(businessObjectDataEntity);
    when(businessObjectDataEntity.getStorageUnits()).thenReturn(storageUnitEntities);
    when(mockBusinessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey))
        .thenReturn(businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey));
    // Call the method under test.
    try
    {
        cleanupDestroyedBusinessObjectDataService.cleanupS3StorageUnit(businessObjectDataStorageUnitKey);
    }
    catch (IllegalArgumentException illegalArgumentException)
    {
        assertThat(illegalArgumentException.getMessage(), is(equalTo("Business object data has multiple (2) S3 storage units. Business object data: {" +
            businessObjectDataHelper.businessObjectDataKeyToString(businessObjectDataKey) + "}")));
    }
    // Verify the external calls.
    verify(mockBusinessObjectDataHelper).createBusinessObjectDataKeyFromStorageUnitKey(businessObjectDataStorageUnitKey);
    verify(mockBusinessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataKey);
    verify(businessObjectDataEntity).getStorageUnits();
    verify(mockBusinessObjectDataHelper).businessObjectDataKeyToString(businessObjectDataKey);
    verifyNoMoreInteractions(businessObjectDataEntity);
    verifyNoMoreInteractionsHelper();
}