diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPI.java b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPI.java index af1fc975a56b..b294ef42d3c7 100644 --- a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPI.java +++ b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPI.java @@ -6,6 +6,7 @@ import com.dotcms.jobs.business.job.Job; import com.dotcms.jobs.business.job.JobPaginatedResult; import com.dotcms.jobs.business.processor.JobProcessor; +import com.dotcms.jobs.business.queue.JobQueue; import com.dotmarketing.exception.DotDataException; import java.util.Map; import java.util.concurrent.TimeUnit; @@ -116,6 +117,11 @@ String createJob(String queueName, Map parameters) */ CircuitBreaker getCircuitBreaker(); + /** + * @return The JobQueue instance + */ + JobQueue getJobQueue(); + /** * @return The size of the thread pool */ diff --git a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java index 3b6dfcb25415..e32d6189d114 100644 --- a/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java +++ b/dotCMS/src/main/java/com/dotcms/jobs/business/api/JobQueueManagerAPIImpl.java @@ -343,6 +343,12 @@ public CircuitBreaker getCircuitBreaker() { return this.circuitBreaker; } + @Override + @VisibleForTesting + public JobQueue getJobQueue() { + return this.jobQueue; + } + @Override @VisibleForTesting public int getThreadPoolSize() { diff --git a/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java b/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java index 9eaafb88e8e3..521aa1cfd8a5 100644 --- a/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java +++ b/dotcms-integration/src/test/java/com/dotcms/jobs/business/api/JobQueueManagerAPICDITest.java @@ -1,5 +1,7 @@ package com.dotcms.jobs.business.api; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertSame; @@ -15,7 +17,6 @@ import org.jboss.weld.junit5.WeldInitiator; import org.jboss.weld.junit5.WeldJunit5Extension; import org.jboss.weld.junit5.WeldSetup; -import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; @@ -66,7 +67,7 @@ void test_SingletonBehavior() { @Test void test_CDIInjection() { assertNotNull(jobQueueManagerAPI, "JobQueueManagerAPI should be injected"); - Assertions.assertInstanceOf(JobQueueManagerAPIImpl.class, jobQueueManagerAPI, + assertInstanceOf(JobQueueManagerAPIImpl.class, jobQueueManagerAPI, "JobQueueManagerAPI should be an instance of JobQueueManagerAPIImpl"); } @@ -78,14 +79,18 @@ void test_CDIInjection() { @Test void test_JobQueueManagerAPIFields() { + assertNotNull(jobQueueManagerAPI.getJobQueue(), "JobQueue should be injected"); + assertInstanceOf(JobQueue.class, jobQueueManagerAPI.getJobQueue(), + "Injected object should implement JobQueue interface"); + assertNotNull(jobQueueManagerAPI.getCircuitBreaker(), "CircuitBreaker should be injected"); assertNotNull(jobQueueManagerAPI.getDefaultRetryStrategy(), "Retry strategy should be injected"); - Assertions.assertEquals(10, jobQueueManagerAPI.getThreadPoolSize(), + assertEquals(10, jobQueueManagerAPI.getThreadPoolSize(), "ThreadPoolSize should be greater than 0"); - Assertions.assertInstanceOf(ExponentialBackoffRetryStrategy.class, + assertInstanceOf(ExponentialBackoffRetryStrategy.class, jobQueueManagerAPI.getDefaultRetryStrategy(), "Retry strategy should be an instance of ExponentialBackoffRetryStrategy"); }