diff --git a/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_7_0/3251-terminology-reindexing-job-is-never-triggered.yaml b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_7_0/3251-terminology-reindexing-job-is-never-triggered.yaml new file mode 100644 index 00000000000..f337254e07a --- /dev/null +++ b/hapi-fhir-docs/src/main/resources/ca/uhn/hapi/fhir/changelog/5_7_0/3251-terminology-reindexing-job-is-never-triggered.yaml @@ -0,0 +1,4 @@ +--- +type: fix +title: "Terminology reindexing job was launching the wrong process, so terminology reindexing was never + launched. This has been fixed." diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImpl.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImpl.java index 012afcf2420..07246061972 100644 --- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImpl.java +++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImpl.java @@ -161,11 +161,11 @@ public class TermReindexingSvcImpl implements ITermReindexingSvc { public static class Job implements HapiJob { @Autowired - private ITermDeferredStorageSvc myTerminologySvc; + private ITermReindexingSvc myTermReindexingSvc; @Override public void execute(JobExecutionContext theContext) { - myTerminologySvc.saveDeferred(); + myTermReindexingSvc.processReindexing(); } } diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImplTest.java new file mode 100644 index 00000000000..bf66f7ace42 --- /dev/null +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/TermReindexingSvcImplTest.java @@ -0,0 +1,39 @@ +package ca.uhn.fhir.jpa.term; + +import ca.uhn.fhir.jpa.term.api.ITermReindexingSvc; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.quartz.JobExecutionContext; +import org.springframework.test.util.ReflectionTestUtils; + +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.atLeastOnce; +import static org.mockito.Mockito.verify; + +@ExtendWith(MockitoExtension.class) +class TermReindexingSvcImplTest { + + @Mock JobExecutionContext myJobExecutionContext; + @Mock ITermReindexingSvc jobReindexingSvc; + + + @Test + void validateReindexingJobExecutesReindexing() { + TermReindexingSvcImpl.Job innerJob = new TermReindexingSvcImpl.Job(); + + // validates that inner Job has an myTermReindexingSvc field of class ITermReindexingSvc + try { + ReflectionTestUtils.setField(innerJob, "myTermReindexingSvc", jobReindexingSvc); + } catch (Exception theE) { + fail("ITermReindexingSvc implementation inner Job doesn't have a 'myTermReindexingSvc' property"); + } + + innerJob.execute(myJobExecutionContext); + + // validates that inner Job calls myTermReindexingSvc.processReindexing when executed + verify(jobReindexingSvc, atLeastOnce()).processReindexing(); + } + +}