@Test
public void testExecuteFunctionForBusinessObjectDefinitionEntitiesJsonParseException()
{

    // Create a list of business object definition entities.
    final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities = Collections.unmodifiableList(Arrays.asList(
        businessObjectDefinitionDaoTestHelper.createBusinessObjectDefinitionEntity(BDEF_NAMESPACE, BDEF_NAME, DATA_PROVIDER_NAME, BDEF_DESCRIPTION,
            businessObjectDefinitionServiceTestHelper.getNewAttributes()), businessObjectDefinitionDaoTestHelper
            .createBusinessObjectDefinitionEntity(BDEF_NAMESPACE_2, BDEF_NAME_2, DATA_PROVIDER_NAME_2, BDEF_DESCRIPTION_2,
                businessObjectDefinitionServiceTestHelper.getNewAttributes2())));
    businessObjectDefinitionEntities.forEach(entity ->
    {
        entity.setDescriptiveBusinessObjectFormat(new BusinessObjectFormatEntity());
        entity.getDescriptiveBusinessObjectFormat().setSchemaColumns(new ArrayList<>());
        entity.setSubjectMatterExperts(new ArrayList<>());
    });
    // Mock the external calls.
    when(jsonHelper.objectToJson(any()))
        .thenThrow(new IllegalStateException(new JsonParseException("Failed to Parse", new JsonLocation("SRC", 100L, 1, 2))));
    // Execute a function for all business object definition entities.
    businessObjectDefinitionHelper
        .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, businessObjectDefinitionEntities,
            (indexName, id, json) ->
            {
            });
    // Verify the external calls.
    verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any());
    verifyNoMoreInteractions(alternateKeyHelper, jsonHelper);
}