From 434670fb8d788f8afa33c78cf1f71757099103e4 Mon Sep 17 00:00:00 2001 From: Martin Gaievski Date: Wed, 2 Nov 2022 12:34:35 -0700 Subject: [PATCH] Fix unit test assertion logic Signed-off-by: Martin Gaievski --- .../org/opensearch/knn/index/codec/KNNCodecTestCase.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/opensearch/knn/index/codec/KNNCodecTestCase.java b/src/test/java/org/opensearch/knn/index/codec/KNNCodecTestCase.java index 43ae19320..edb3ed75d 100644 --- a/src/test/java/org/opensearch/knn/index/codec/KNNCodecTestCase.java +++ b/src/test/java/org/opensearch/knn/index/codec/KNNCodecTestCase.java @@ -57,12 +57,11 @@ import java.util.function.Function; import java.util.stream.Collectors; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import static org.opensearch.Version.CURRENT; @@ -321,7 +320,7 @@ public void testKnnVectorIndex( IndexReader reader = writer.getReader(); writer.close(); - verify(perFieldKnnVectorsFormatSpy).getKnnVectorsFormatForField(anyString()); + verify(perFieldKnnVectorsFormatSpy, atLeastOnce()).getKnnVectorsFormatForField(eq(FIELD_NAME_ONE)); IndexSearcher searcher = new IndexSearcher(reader); Query query = KNNQueryFactory.create(KNNEngine.LUCENE, "dummy", FIELD_NAME_ONE, new float[] { 1.0f, 0.0f, 0.0f }, 1); @@ -348,7 +347,7 @@ public void testKnnVectorIndex( ResourceWatcherService resourceWatcherService = createDisabledResourceWatcherService(); NativeMemoryLoadStrategy.IndexLoadStrategy.initialize(resourceWatcherService); - verify(perFieldKnnVectorsFormatSpy, times(2)).getKnnVectorsFormatForField(anyString()); + verify(perFieldKnnVectorsFormatSpy, atLeastOnce()).getKnnVectorsFormatForField(eq(FIELD_NAME_TWO)); IndexSearcher searcher1 = new IndexSearcher(reader1); Query query1 = KNNQueryFactory.create(KNNEngine.LUCENE, "dummy", FIELD_NAME_TWO, new float[] { 1.0f, 0.0f }, 1);