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:
jmarchionatto 2022-01-06 13:29:01 -05:00 committed by GitHub
parent 2054ef65a6
commit 737409955a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 2 deletions

View File

@ -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."

View File

@ -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();
}
}

View File

@ -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();
}
}