diff --git a/services/src/test/java/org/fao/geonet/services/metadata/BatchOpsMetadatReindexerTest.java b/services/src/test/java/org/fao/geonet/services/metadata/BatchOpsMetadatReindexerTest.java index 293dd9c6f72..f1a0d7402d0 100644 --- a/services/src/test/java/org/fao/geonet/services/metadata/BatchOpsMetadatReindexerTest.java +++ b/services/src/test/java/org/fao/geonet/services/metadata/BatchOpsMetadatReindexerTest.java @@ -5,7 +5,6 @@ import org.fao.geonet.kernel.search.EsSearchManager; import org.fao.geonet.kernel.search.ISearchManager; import org.fao.geonet.kernel.search.index.BatchOpsMetadataReindexer; -import org.fao.geonet.kernel.search.submission.DirectIndexSubmittor; import org.fao.geonet.kernel.search.submission.IIndexSubmittor; import org.fao.geonet.util.ThreadUtils; import org.junit.Test; @@ -68,7 +67,7 @@ public void syncMultiThread() throws Exception { } @Test - public void syncManyThreadButRunInCurrent() throws Exception { + public void syncManyThreadButAwaitCompletion() throws Exception { int numberOfAvailableThreads = 4; final Set<Thread> usedTread = new HashSet<>(); prepareEnvMocks(numberOfAvailableThreads); @@ -80,8 +79,8 @@ public void syncManyThreadButRunInCurrent() throws Exception { ArgumentCaptor<String> metadataIdCaptor = captureIndexationLaunched(mockDataMan); assertEquals("1-2-3-4", metadataIdCaptor.getAllValues().stream().sorted().collect(Collectors.joining("-"))); - assertEquals(1, usedTread.size()); - assertEquals(Thread.currentThread(), usedTread.iterator().next()); + assertEquals(numberOfAvailableThreads, usedTread.size()); + assertNotSame(Thread.currentThread(), usedTread.iterator().next()); } @Test @@ -134,7 +133,7 @@ public void asyncMultiThread() throws Exception { } @Test - public void asyncManyThreadButRunInCurrent() throws Exception { + public void asyncManyThreadButAwaitCurrent() throws Exception { int numberOfAvailableThreads = 4; final Set<Thread> usedTread = new HashSet<>(); prepareEnvMocks(numberOfAvailableThreads); @@ -165,8 +164,8 @@ public void run() { assertEquals(4, toTest.getProcessed()); ArgumentCaptor<String> metadataIdCaptor = captureIndexationLaunched(mockDataMan); assertEquals("1-2-3-4", metadataIdCaptor.getAllValues().stream().sorted().collect(Collectors.joining("-"))); - assertEquals(1, usedTread.size()); - assertEquals(currentThread, usedTread.iterator().next()); + assertEquals(numberOfAvailableThreads, usedTread.size()); + assertNotSame(Thread.currentThread(), usedTread.iterator().next()); } private void prepareEnvMocks(int numberOfAvailableThreads) {