BusinessObjectDefinitionHelper { public void executeFunctionForBusinessObjectDefinitionEntities(final String indexName, final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities, final TriConsumer<String, String, String> function) { businessObjectDefinitionEntities.forEach(businessObjectDefinitionEntity -> { businessObjectDefinitionEntity.getAttributes().size(); businessObjectDefinitionEntity.getBusinessObjectDefinitionTags().size(); businessObjectDefinitionEntity.getBusinessObjectFormats().size(); businessObjectDefinitionEntity.getColumns().size(); businessObjectDefinitionEntity.getSampleDataFiles().size(); businessObjectDefinitionEntity.getSubjectMatterExperts().size(); final String jsonString = safeObjectMapperWriteValueAsString(businessObjectDefinitionEntity); if (StringUtils.isNotEmpty(jsonString)) { try { function.accept(indexName, businessObjectDefinitionEntity.getId().toString(), jsonString); } catch (Exception ex) { LOGGER.warn("Index operation exception is logged {} for {}, {}, {}", ex, indexName, businessObjectDefinitionEntity.getId().toString(), jsonString); } } }); LOGGER.info("Finished processing {} business object definitions with a search index function.", businessObjectDefinitionEntities.size()); }  String businessObjectDefinitionKeyToString(BusinessObjectDefinitionKey businessObjectDefinitionKey); void executeFunctionForBusinessObjectDefinitionEntities(final String indexName,
        final List<BusinessObjectDefinitionEntity> businessObjectDefinitionEntities, final TriConsumer<String, String, String> function); BusinessObjectDefinitionKey getBusinessObjectDefinitionKey(BusinessObjectDefinitionColumnKey businessObjectDefinitionColumnKey); void validateBusinessObjectDefinitionKey(BusinessObjectDefinitionKey key); String safeObjectMapperWriteValueAsString(final BusinessObjectDefinitionEntity businessObjectDefinitionEntity); void processTagSearchScoreMultiplier(final BusinessObjectDefinitionEntity businessObjectDefinitionEntity);  }
@Test public void testExecuteFunctionForBusinessObjectDefinitionEntities() { 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<>()); }); when(jsonHelper.objectToJson(any())).thenReturn(JSON_STRING); businessObjectDefinitionHelper .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, businessObjectDefinitionEntities, (indexName, id, json) -> { }); verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); }
@Test public void testExecuteFunctionForBusinessObjectDefinitionEntitiesJsonParseException() { 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<>()); }); when(jsonHelper.objectToJson(any())) .thenThrow(new IllegalStateException(new JsonParseException("Failed to Parse", new JsonLocation("SRC", 100L, 1, 2)))); businessObjectDefinitionHelper .executeFunctionForBusinessObjectDefinitionEntities(SEARCH_INDEX_NAME, businessObjectDefinitionEntities, (indexName, id, json) -> { }); verify(jsonHelper, times(businessObjectDefinitionEntities.size())).objectToJson(any()); verifyNoMoreInteractions(alternateKeyHelper, jsonHelper); }