SearchIndexHelperServiceImpl implements SearchIndexHelperService { protected boolean validateSearchIndexSize(String indexName, int expectedIndexSize) { final long indexSize = indexFunctionsDao.getNumberOfTypesInIndex(indexName); boolean result = true; if (indexSize != expectedIndexSize) { LOGGER.error("Index validation failed, expected index size {}, does not equal actual index size {}.", expectedIndexSize, indexSize); result = false; } return result; }  @Override @Async Future<Void> indexAllBusinessObjectDefinitions(SearchIndexKey searchIndexKey); @Override @Async Future<Void> indexAllTags(SearchIndexKey searchIndexKey); static final int BUSINESS_OBJECT_DEFINITIONS_CHUNK_SIZE; }
@Test public void testValidateSearchIndexSizeValidationFails() { when(indexFunctionsDao.getNumberOfTypesInIndex(SEARCH_INDEX_NAME)).thenReturn(1L); boolean response = searchIndexHelperServiceImpl.validateSearchIndexSize(SEARCH_INDEX_NAME, 2); verify(indexFunctionsDao).getNumberOfTypesInIndex(SEARCH_INDEX_NAME); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionHelper, indexFunctionsDao, searchIndexDaoHelper); assertFalse(response); }
@Test public void testValidateSearchIndexSizeValidationPasses() { when(indexFunctionsDao.getNumberOfTypesInIndex(SEARCH_INDEX_NAME)).thenReturn(2L); boolean response = searchIndexHelperServiceImpl.validateSearchIndexSize(SEARCH_INDEX_NAME, 2); verify(indexFunctionsDao).getNumberOfTypesInIndex(SEARCH_INDEX_NAME); verifyNoMoreInteractions(businessObjectDefinitionDao, businessObjectDefinitionHelper, indexFunctionsDao, searchIndexDaoHelper); assertTrue(response); }