@Test
public void testValidateBusinessObjectDataNoRetentionInformation()
{

    // Create a version-less business object format key.
    BusinessObjectFormatKey businessObjectFormatKey =
        new BusinessObjectFormatKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, NO_FORMAT_VERSION);
    // Create a business object data key.
    BusinessObjectDataKey businessObjectDataKey =
        new BusinessObjectDataKey(BDEF_NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, INITIAL_FORMAT_VERSION, PARTITION_VALUE,
            NO_SUBPARTITION_VALUES, DATA_VERSION);
    // Create a retention type entity.
    RetentionTypeEntity retentionTypeEntity = new RetentionTypeEntity();
    // Create a business object format entity which is not the latest format version.
    BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
    businessObjectFormatEntity.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION);
    businessObjectFormatEntity.setLatestVersion(false);
    // Create a latest version business object format entity with missing retention type.
    BusinessObjectFormatEntity latestVersionBusinessObjectFormatEntity = new BusinessObjectFormatEntity();
    latestVersionBusinessObjectFormatEntity.setBusinessObjectFormatVersion(INITIAL_FORMAT_VERSION);
    latestVersionBusinessObjectFormatEntity.setLatestVersion(true);
    latestVersionBusinessObjectFormatEntity.setRetentionType(null);
    latestVersionBusinessObjectFormatEntity.setRetentionPeriodInDays(RETENTION_PERIOD_DAYS);
    // Create a business object data entity.
    BusinessObjectDataEntity businessObjectDataEntity = new BusinessObjectDataEntity();
    businessObjectDataEntity.setBusinessObjectFormat(businessObjectFormatEntity);
    businessObjectDataEntity.setPartitionValue(PARTITION_VALUE);
    // Create a current timestamp.
    Timestamp currentTimestamp = new Timestamp(new Date().getTime());
    // Mock the external calls.
    when(businessObjectFormatDao.getBusinessObjectFormatByAltKey(businessObjectFormatKey)).thenReturn(latestVersionBusinessObjectFormatEntity);
    when(businessObjectFormatHelper.businessObjectFormatKeyToString(businessObjectFormatKey)).thenReturn(BUSINESS_OBJECT_FORMAT_KEY_AS_STRING);
    when(herdDao.getCurrentTimestamp()).thenReturn(currentTimestamp);
    // Try to call the method under test.
    try
    {
        businessObjectDataInitiateDestroyHelperServiceImpl.validateBusinessObjectData(businessObjectDataEntity, businessObjectDataKey);
        fail();
    }
    catch (IllegalArgumentException e)
    {
        assertEquals(String.format("Retention information is not configured for the business object format. Business object format: {%s}",
            BUSINESS_OBJECT_FORMAT_KEY_AS_STRING), e.getMessage());
    }
    // Update the latest business object format version to have retention type - PARTITION_VALUE specified but without a retention period.
    retentionTypeEntity.setCode(RetentionTypeEntity.PARTITION_VALUE);
    latestVersionBusinessObjectFormatEntity.setRetentionType(retentionTypeEntity);
    latestVersionBusinessObjectFormatEntity.setRetentionPeriodInDays(null);
    // Try to call the method under test.
    try
    {
        businessObjectDataInitiateDestroyHelperServiceImpl.validateBusinessObjectData(businessObjectDataEntity, businessObjectDataKey);
        fail();
    }
    catch (IllegalArgumentException e)
    {
        assertEquals(String.format("Retention period in days must be specified for %s retention type.", RetentionTypeEntity.PARTITION_VALUE),
            e.getMessage());
    }
    // Update the latest business object format version to have retention type - BDATA_RETENTION_DATE specified but with a retention period.
    // Retention period in days value must only be specified for PARTITION_VALUE retention type.
    retentionTypeEntity.setCode(RetentionTypeEntity.BDATA_RETENTION_DATE);
    latestVersionBusinessObjectFormatEntity.setRetentionType(retentionTypeEntity);
    latestVersionBusinessObjectFormatEntity.setRetentionPeriodInDays(RETENTION_PERIOD_DAYS);
    // Try to call the method under test.
    try
    {
        businessObjectDataInitiateDestroyHelperServiceImpl.validateBusinessObjectData(businessObjectDataEntity, businessObjectDataKey);
        fail();
    }
    catch (IllegalArgumentException e)
    {
        assertEquals(String.format("A retention period in days cannot be specified for %s retention type.", RetentionTypeEntity.BDATA_RETENTION_DATE),
            e.getMessage());
    }
    // Verify the external calls.
    verify(businessObjectFormatDao, times(3)).getBusinessObjectFormatByAltKey(businessObjectFormatKey);
    verify(businessObjectFormatHelper, times(1)).businessObjectFormatKeyToString(businessObjectFormatKey);
    verify(herdDao, times(3)).getCurrentTimestamp();
    verifyNoMoreInteractionsHelper();
}