Issue 3251 terminology reindexing job is never triggered (#3271)
* Run intended job * Add test ti validate right method is invoked by inner job * Add changelog * Make test fail with proper message instead of crash Co-authored-by: juan.marchionatto <juan.marchionatto@smilecdr.com>
This commit is contained in:
parent
2054ef65a6
commit
737409955a
|
@ -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."
|
|
@ -161,11 +161,11 @@ public class TermReindexingSvcImpl implements ITermReindexingSvc {
|
||||||
|
|
||||||
public static class Job implements HapiJob {
|
public static class Job implements HapiJob {
|
||||||
@Autowired
|
@Autowired
|
||||||
private ITermDeferredStorageSvc myTerminologySvc;
|
private ITermReindexingSvc myTermReindexingSvc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext theContext) {
|
public void execute(JobExecutionContext theContext) {
|
||||||
myTerminologySvc.saveDeferred();
|
myTermReindexingSvc.processReindexing();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue