Work on subscriptions

This commit is contained in:
jamesagnew 2020-04-02 21:15:07 -04:00
parent 6baf1995c9
commit 43b4d8e0e3
4 changed files with 27 additions and 18 deletions

View File

@ -76,18 +76,14 @@ import java.util.Set;
public class PersistedJpaBundleProvider implements IBundleProvider {
private static final Logger ourLog = LoggerFactory.getLogger(PersistedJpaBundleProvider.class);
private final RequestDetails myRequest;
@Autowired
private FhirContext myContext;
/*
* Autowired fields
*/
@PersistenceContext
private EntityManager myEntityManager;
@Autowired
private ISearchCoordinatorSvc mySearchCoordinatorSvc;
@Autowired
private ISearchCacheSvc mySearchCacheSvc;
private Search mySearchEntity;
private String myUuid;
private boolean myCacheHit;
private IInterceptorBroadcaster myInterceptorBroadcaster;
@Autowired
private SearchBuilderFactory mySearchBuilderFactory;
@ -95,6 +91,22 @@ public class PersistedJpaBundleProvider implements IBundleProvider {
private DaoRegistry myDaoRegistry;
@Autowired
protected PlatformTransactionManager myTxManager;
@Autowired
private FhirContext myContext;
@Autowired
private ISearchCoordinatorSvc mySearchCoordinatorSvc;
@Autowired
/*
* Non autowired fields (will be different for every instance
* of this class, since it's a prototype
*/
private final RequestDetails myRequest;
private ISearchCacheSvc mySearchCacheSvc;
private Search mySearchEntity;
private String myUuid;
private boolean myCacheHit;
/**
* Constructor

View File

@ -138,15 +138,6 @@ public class SearchCoordinatorSvcImplTest {
when(myTxManager.getTransaction(any())).thenReturn(mock(TransactionStatus.class));
when(myPersistedJpaBundleProviderFactory.newInstance(nullable(RequestDetails.class), nullable(String.class))).thenAnswer(t->{
String uuid = t.getArgument(1, String.class);
RequestDetails requestDetails = t.getArgument(0, RequestDetails.class);
PersistedJpaBundleProvider retVal = new PersistedJpaBundleProvider(requestDetails, uuid);
retVal.setTxManagerForUnitTest(myTxManager);
retVal.setSearchCoordinatorSvcForUnitTest(mySvc);
return retVal;
});
when(myPersistedJpaBundleProviderFactory.newInstanceFirstPage(nullable(RequestDetails.class), nullable(Search.class), nullable(SearchCoordinatorSvcImpl.SearchTask.class), nullable(ISearchBuilder.class))).thenAnswer(t->{
RequestDetails requestDetails = t.getArgument(0, RequestDetails.class);
Search search = t.getArgument(1, Search.class);

View File

@ -36,6 +36,7 @@ public class SubscriptionValidatingInterceptorTest {
mySvc.setSubscriptionCanonicalizerForUnitTest(new SubscriptionCanonicalizer(myCtx));
mySvc.setDaoRegistryForUnitTest(myDaoRegistry);
mySvc.setSubscriptionStrategyEvaluatorForUnitTest(mySubscriptionStrategyEvaluator);
mySvc.setFhirContextForUnitTest(myCtx);
}
@Test

View File

@ -42,6 +42,11 @@ public class SubscriptionValidatingInterceptor {
validateSubmittedSubscription(theResource);
}
@VisibleForTesting
public void setFhirContextForUnitTest(FhirContext theFhirContext) {
myFhirContext = theFhirContext;
}
public void validateSubmittedSubscription(IBaseResource theSubscription) {
if (!"Subscription".equals(myFhirContext.getResourceDefinition(theSubscription).getName())) {
return;