Skip to content

Commit

Permalink
Adjust tests after BatchOpsMetadatReindexer behaviour changes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobias-hotz committed Nov 5, 2024
1 parent 6a123dc commit 702dc20
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 702dc20

Please sign in to comment.