Test fix
This commit is contained in:
parent
f978bc3039
commit
dc1f48ffed
|
@ -9,9 +9,9 @@ package ca.uhn.fhir.jpa.search.reindex;
|
|||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
|
@ -98,6 +98,8 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
private FhirContext myContext;
|
||||
@PersistenceContext(type = PersistenceContextType.TRANSACTION)
|
||||
private EntityManager myEntityManager;
|
||||
@Autowired
|
||||
private ISearchParamRegistry mySearchParamRegistry;
|
||||
|
||||
@VisibleForTesting
|
||||
void setReindexJobDaoForUnitTest(IResourceReindexJobDao theReindexJobDao) {
|
||||
|
@ -186,7 +188,6 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
runReindexingPass();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(Transactional.TxType.NEVER)
|
||||
public Integer runReindexingPass() {
|
||||
|
@ -232,9 +233,6 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
expungeJobsMarkedAsDeleted();
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private ISearchParamRegistry mySearchParamRegistry;
|
||||
|
||||
private int runReindexJobs() {
|
||||
Collection<ResourceReindexJobEntity> jobs = getResourceReindexJobEntities();
|
||||
|
||||
|
@ -277,6 +275,11 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
});
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public void setSearchParamRegistryForUnitTest(ISearchParamRegistry theSearchParamRegistry) {
|
||||
mySearchParamRegistry = theSearchParamRegistry;
|
||||
}
|
||||
|
||||
private int runReindexJob(ResourceReindexJobEntity theJob) {
|
||||
if (theJob.getSuspendedUntil() != null) {
|
||||
if (theJob.getSuspendedUntil().getTime() > System.currentTimeMillis()) {
|
||||
|
@ -288,6 +291,11 @@ public class ResourceReindexingSvcImpl implements IResourceReindexingSvc {
|
|||
StopWatch sw = new StopWatch();
|
||||
AtomicInteger counter = new AtomicInteger();
|
||||
|
||||
/*
|
||||
* On the first time we run a particular reindex job, let's make sure we
|
||||
* have the latest search parameters loaded. This is good since a common reason to
|
||||
* be reindexing is that the search parameters have changed in some way.
|
||||
*/
|
||||
if (theJob.getThresholdLow() == null) {
|
||||
mySearchParamRegistry.forceRefresh();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import ca.uhn.fhir.jpa.dao.data.IResourceReindexJobDao;
|
|||
import ca.uhn.fhir.jpa.dao.data.IResourceTableDao;
|
||||
import ca.uhn.fhir.jpa.entity.ResourceReindexJobEntity;
|
||||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.searchparam.registry.ISearchParamRegistry;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -63,6 +64,8 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest {
|
|||
@Captor
|
||||
private ArgumentCaptor<Date> myHighCaptor;
|
||||
private ResourceReindexJobEntity mySingleJob;
|
||||
@Mock
|
||||
private ISearchParamRegistry mySearchParamRegistry;
|
||||
|
||||
@Override
|
||||
protected FhirContext getContext() {
|
||||
|
@ -87,6 +90,7 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest {
|
|||
mySvc.setReindexJobDaoForUnitTest(myReindexJobDao);
|
||||
mySvc.setResourceTableDaoForUnitTest(myResourceTableDao);
|
||||
mySvc.setTxManagerForUnitTest(myTxManager);
|
||||
mySvc.setSearchParamRegistryForUnitTest(mySearchParamRegistry);
|
||||
mySvc.start();
|
||||
}
|
||||
|
||||
|
@ -175,6 +179,8 @@ public class ResourceReindexingSvcImplTest extends BaseJpaTest {
|
|||
verify(myReindexJobDao, times(1)).getReindexCount(any());
|
||||
verify(myReindexJobDao, times(1)).setReindexCount(any(), anyInt());
|
||||
verifyNoMoreInteractions(myReindexJobDao);
|
||||
|
||||
verify(mySearchParamRegistry, times(1)).forceRefresh();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
Loading…
Reference in New Issue