@Test
public void testUpdateBusinessObjectDataParentsBusinessObjectDataNotInPreRegistrationState()
{

    // Create a business object data key for the first parent.
    BusinessObjectDataKey businessObjectDataParentOneKey =
        new BusinessObjectDataKey(NAMESPACE_2, BDEF_NAME_2, FORMAT_USAGE_CODE_2, FORMAT_FILE_TYPE_CODE_2, FORMAT_VERSION, PARTITION_VALUE_2,
            SUBPARTITION_VALUES_2, DATA_VERSION);
    // Create a business object data key for the second parent.
    BusinessObjectDataKey businessObjectDataParentTwoKey =
        new BusinessObjectDataKey(NAMESPACE_3, BDEF_NAME_3, FORMAT_USAGE_CODE_3, FORMAT_FILE_TYPE_CODE_3, FORMAT_VERSION, PARTITION_VALUE_3,
            SUBPARTITION_VALUES_3, DATA_VERSION);
    // Create a business object data key for the child.
    BusinessObjectDataKey businessObjectDataChildKey =
        new BusinessObjectDataKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, FORMAT_VERSION, PARTITION_VALUE, SUBPARTITION_VALUES,
            DATA_VERSION);
    // Create first business object data parent.
    BusinessObjectDataEntity businessObjectDataParentOneEntity =
        businessObjectDataDaoTestHelper.createBusinessObjectDataEntity(businessObjectDataParentOneKey, LATEST_VERSION_FLAG_SET, BDATA_STATUS);
    // Create a child business object data entity having a non pre-registration status.
    BusinessObjectDataEntity businessObjectDataChildEntity = businessObjectDataDaoTestHelper
        .createBusinessObjectDataEntity(businessObjectDataChildKey, LATEST_VERSION_FLAG_SET, BusinessObjectDataStatusEntity.VALID);
    // Associate child and first parent business object data entities.
    businessObjectDataParentOneEntity.getBusinessObjectDataChildren().add(businessObjectDataChildEntity);
    businessObjectDataChildEntity.getBusinessObjectDataParents().add(businessObjectDataParentOneEntity);
    // Create a business object data parents update request.
    BusinessObjectDataParentsUpdateRequest businessObjectDataParentsUpdateRequest =
        new BusinessObjectDataParentsUpdateRequest(Collections.singletonList(businessObjectDataParentTwoKey));
    // Mock the external calls.
    when(businessObjectDataDaoHelper.getBusinessObjectDataEntity(businessObjectDataChildKey)).thenReturn(businessObjectDataChildEntity);
    // Try to call the method under test.
    try
    {
        businessObjectDataServiceImpl.updateBusinessObjectDataParents(businessObjectDataChildKey, businessObjectDataParentsUpdateRequest);
        fail();
    }
    catch (IllegalArgumentException e)
    {
        assertEquals(String
            .format("Unable to update parents for business object data because it has \"%s\" status, which is not one of pre-registration statuses.",
                BusinessObjectDataStatusEntity.VALID), e.getMessage());
    }
    // Verify the external calls.
    verify(businessObjectDataHelper).validateBusinessObjectDataKey(businessObjectDataChildKey, true, true);
    verify(businessObjectDataDaoHelper).validateBusinessObjectDataKeys(businessObjectDataParentsUpdateRequest.getBusinessObjectDataParents());
    verify(businessObjectDataDaoHelper).getBusinessObjectDataEntity(businessObjectDataChildKey);
    verifyNoMoreInteractionsHelper();
    // Validate the business object data entity.
    assertEquals(1, CollectionUtils.size(businessObjectDataChildEntity.getBusinessObjectDataParents()));
    assertEquals(businessObjectDataParentOneEntity, businessObjectDataChildEntity.getBusinessObjectDataParents().get(0));
}