Skip to content

Commit

Permalink
[NYS2AWS-134] more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pvriel committed Feb 11, 2025
1 parent 810e3e5 commit ad79a5c
Showing 1 changed file with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package eu.xenit.alfresco.healthprocessor.plugins.solr;

import eu.xenit.alfresco.healthprocessor.indexing.IndexingStrategy;
import eu.xenit.alfresco.healthprocessor.indexing.txnaggregation.TransactionAggregationIndexingStrategy;
import eu.xenit.alfresco.healthprocessor.util.TransactionHelper;
import io.micrometer.core.instrument.MeterRegistry;
import lombok.NonNull;
import org.alfresco.repo.domain.node.AbstractNodeDAOImpl;
import org.alfresco.service.cmr.repository.NodeRef;
Expand All @@ -10,6 +12,7 @@
import org.junit.jupiter.api.Test;

import java.util.*;
import java.util.function.ToDoubleFunction;

import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any;
Expand Down Expand Up @@ -83,4 +86,28 @@ void testChosenIndexerStrategy() {
assertThrows(IllegalStateException.class, () -> new SolrUndersizedTransactionsHealthProcessorPlugin(true, 1, wrongProperties, transactionHelper, nodeDAO));
}

@Test
public void isBoundToMeterRegistry() {
MeterRegistry meterRegistry = mock(MeterRegistry.class);
new SolrUndersizedTransactionsHealthProcessorPlugin(true, 1, properties, transactionHelper, nodeDAO, meterRegistry);
verify(meterRegistry, times(1)).gauge(anyString(), any(), any(ToDoubleFunction.class));
}

@Test
public void canHandleLongTransactions() throws InterruptedException {
transactionHelper = mock(TransactionHelper.class);
doAnswer(invocation -> {
Thread.sleep(1000);
return null;
}).when(transactionHelper).inNewTransaction(any(Runnable.class), eq(false));
plugin = new SolrUndersizedTransactionsHealthProcessorPlugin(true, 1, properties, transactionHelper, nodeDAO);

// Trigger the queue behaviour.
for (int i = 0; i < 5; i++) plugin.process(testNodes.keySet());

Thread.sleep(8_000);
verify(transactionHelper, times(5)).inNewTransaction(any(Runnable.class), eq(false));

}

}

0 comments on commit ad79a5c

Please sign in to comment.