@Test
public void testCreateBusinessObjectFormatExternalInterface()
{

    // Create a business object format to external interface mapping key.
    BusinessObjectFormatExternalInterfaceKey businessObjectFormatExternalInterfaceKey =
        new BusinessObjectFormatExternalInterfaceKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, EXTERNAL_INTERFACE);
    // Create a business object format to external interface mapping create request.
    BusinessObjectFormatExternalInterfaceCreateRequest businessObjectFormatExternalInterfaceCreateRequest =
        new BusinessObjectFormatExternalInterfaceCreateRequest(businessObjectFormatExternalInterfaceKey);
    // Create a business object format to external interface mapping.
    BusinessObjectFormatExternalInterface businessObjectFormatExternalInterface =
        new BusinessObjectFormatExternalInterface(ID, businessObjectFormatExternalInterfaceKey);
    // Create a business object format entity.
    BusinessObjectFormatEntity businessObjectFormatEntity = new BusinessObjectFormatEntity();
    // Create a external interface entity.
    ExternalInterfaceEntity externalInterfaceEntity = new ExternalInterfaceEntity();
    // Mock the external calls.
    when(businessObjectFormatDaoHelper
        .getBusinessObjectFormatEntity(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null)))
        .thenReturn(businessObjectFormatEntity);
    when(externalInterfaceDaoHelper.getExternalInterfaceEntity(EXTERNAL_INTERFACE)).thenReturn(externalInterfaceEntity);
    when(businessObjectFormatExternalInterfaceDao
        .getBusinessObjectFormatExternalInterfaceByBusinessObjectFormatAndExternalInterface(businessObjectFormatEntity, externalInterfaceEntity))
        .thenReturn(null);
    when(businessObjectFormatExternalInterfaceHelper
        .createBusinessObjectFormatExternalInterfaceFromEntity(any(BusinessObjectFormatExternalInterfaceEntity.class)))
        .thenReturn(businessObjectFormatExternalInterface);
    // Call the method under test.
    BusinessObjectFormatExternalInterface result =
        businessObjectFormatExternalInterfaceService.createBusinessObjectFormatExternalInterface(businessObjectFormatExternalInterfaceCreateRequest);
    // Validate the results.
    assertEquals(businessObjectFormatExternalInterface, result);
    // Verify the external calls.
    verify(businessObjectFormatExternalInterfaceHelper)
        .validateAndTrimBusinessObjectFormatExternalInterfaceCreateRequest(businessObjectFormatExternalInterfaceCreateRequest);
    verify(businessObjectFormatDaoHelper)
        .getBusinessObjectFormatEntity(new BusinessObjectFormatKey(NAMESPACE, BDEF_NAME, FORMAT_USAGE_CODE, FORMAT_FILE_TYPE_CODE, null));
    verify(externalInterfaceDaoHelper).getExternalInterfaceEntity(EXTERNAL_INTERFACE);
    verify(businessObjectFormatExternalInterfaceDao)
        .getBusinessObjectFormatExternalInterfaceByBusinessObjectFormatAndExternalInterface(businessObjectFormatEntity, externalInterfaceEntity);
    verify(businessObjectFormatExternalInterfaceDao).saveAndRefresh(any(BusinessObjectFormatExternalInterfaceEntity.class));
    verify(businessObjectFormatExternalInterfaceHelper)
        .createBusinessObjectFormatExternalInterfaceFromEntity(any(BusinessObjectFormatExternalInterfaceEntity.class));
    verifyNoMoreInteractionsHelper();
}