Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revisit tests and new version options #298

Merged
merged 10 commits into from
Apr 24, 2023
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ public SearchRequestWrapper(SearchRequest request, Map<String, Object> parameter
maxConcurrentShardRequests(request.maxConcurrentShardRequests());
minCompatibleShardNode(request.minCompatibleShardNode());
minScore(request.minScore());
// TODO: JM: Review
// pit(request.pit());
postFilter(request.postFilter());
preFilterShardSize(request.preFilterShardSize());
preference(request.preference());
Expand All @@ -258,8 +256,6 @@ public SearchRequestWrapper(SearchRequest request, Map<String, Object> parameter
timeout(request.timeout());
trackScores(request.trackScores());
trackTotalHits(request.trackTotalHits());
// TODO: JM: Review
// type(request.type());
version(request.version());

// override values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@
import java.util.List;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;

/**
* Unit tests for {@link OpenSearchBinaryFileWithMetadataBatchIndexer}.
Expand Down Expand Up @@ -112,7 +110,7 @@ public void testUpdateMetadataWithRemovedBinaries() {


// TODO: JM: Revisit test case
// @Test
@Test
public void testUpdateBinary() {
setupMetadataSearchResult();

Expand All @@ -121,24 +119,24 @@ public void testUpdateBinary() {

batchIndexer.updateIndex(INDEX_ID, SITE_NAME, contentStoreService, context, updateSet, updateStatus);

assertEquals(1, updateStatus.getAttemptedUpdatesAndDeletes());
assertTrue(updateStatus.getSuccessfulUpdates().contains(BINARY_FILENAME1));
verify(searchService).indexBinary(
eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1), any(Content.class), eq(getExpectedMetadata()));
// Binary files are no longer processed by AbstractBinaryFileWithMetadataBatchIndexer
assertEquals(0, updateStatus.getAttemptedUpdatesAndDeletes());
assertFalse(updateStatus.getSuccessfulUpdates().contains(BINARY_FILENAME1));
verify(searchService, times(0)).indexBinary(
eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1), any(Content.class), eq(getExpectedMetadata()));
}


// TODO: JM: Revisit test case
// @Test
@Test
public void testDeleteBinary() {
UpdateSet updateSet = new UpdateSet(Collections.emptyList(), Collections.singletonList(BINARY_FILENAME1));
UpdateStatus updateStatus = new UpdateStatus();

batchIndexer.updateIndex(INDEX_ID, SITE_NAME, contentStoreService, context, updateSet, updateStatus);

assertEquals(1, updateStatus.getAttemptedUpdatesAndDeletes());
assertTrue(updateStatus.getSuccessfulDeletes().contains(BINARY_FILENAME1));
verify(searchService).delete(eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1));
// Binary files are no longer processed by AbstractBinaryFileWithMetadataBatchIndexer
assertEquals(0, updateStatus.getAttemptedUpdatesAndDeletes());
assertFalse(updateStatus.getSuccessfulDeletes().contains(BINARY_FILENAME1));
verify(searchService, times(0)).delete(eq(INDEX_ID), eq(SITE_NAME), eq(BINARY_FILENAME1));
}

@Test
Expand All @@ -165,7 +163,7 @@ protected void setupBinariesSearchResults() {
}

protected void setupMetadataSearchResult() {
when(searchService.searchField(eq(INDEX_ID), eq("metadataPath"), any()))
lenient().when(searchService.searchField(eq(INDEX_ID), eq("metadataPath"), any()))
.thenReturn(List.of(getExpectedMetadata().get("metadataPath").toString()));
}

Expand Down