use of datawave.webservice.query.factory.Persister in project datawave by NationalSecurityAgency.
the class QueryExecutorBeanTest method setup.
@Before
public void setup() throws Exception {
System.setProperty(NpeUtils.NPE_OU_PROPERTY, "iamnotaperson");
System.setProperty("dw.metadatahelper.all.auths", "A,B,C,D");
QueryTraceCache traceCache = new QueryTraceCache();
Whitebox.invokeMethod(traceCache, "init");
cache = new QueryCache();
cache.init();
closedCache = new ClosedQueryCache();
bean = new QueryExecutorBean();
connectionFactory = createStrictMock(AccumuloConnectionFactory.class);
auditor = new AuditBean();
auditService = createStrictMock(AuditService.class);
metrics = createStrictMock(QueryMetricsBean.class);
queryLogicFactory = createStrictMock(QueryLogicFactoryImpl.class);
persister = createStrictMock(Persister.class);
predictor = createStrictMock(QueryPredictor.class);
ctx = createStrictMock(EJBContext.class);
qlCache = new CreatedQueryLogicCacheBean();
queryExpirationConf = new QueryExpirationConfiguration();
queryExpirationConf.setPageSizeShortCircuitCheckTime(45);
queryExpirationConf.setPageShortCircuitTimeout(58);
queryExpirationConf.setCallTime(60);
connectionRequestBean = createStrictMock(AccumuloConnectionRequestBean.class);
setInternalState(auditor, AuditService.class, auditService);
setInternalState(auditor, AuditParameterBuilder.class, new DefaultAuditParameterBuilder());
setInternalState(connectionRequestBean, EJBContext.class, ctx);
setInternalState(bean, QueryCache.class, cache);
setInternalState(bean, ClosedQueryCache.class, closedCache);
setInternalState(bean, AccumuloConnectionFactory.class, connectionFactory);
setInternalState(bean, AuditBean.class, auditor);
setInternalState(bean, QueryMetricsBean.class, metrics);
setInternalState(bean, QueryLogicFactory.class, queryLogicFactory);
setInternalState(bean, QueryExpirationConfiguration.class, queryExpirationConf);
setInternalState(bean, Persister.class, persister);
setInternalState(bean, QueryPredictor.class, predictor);
setInternalState(bean, EJBContext.class, ctx);
setInternalState(bean, CreatedQueryLogicCacheBean.class, qlCache);
setInternalState(bean, QueryTraceCache.class, traceCache);
setInternalState(bean, Multimap.class, HashMultimap.create());
setInternalState(bean, LookupUUIDConfiguration.class, new LookupUUIDConfiguration());
setInternalState(bean, SecurityMarking.class, new ColumnVisibilitySecurityMarking());
setInternalState(bean, QueryParameters.class, new QueryParametersImpl());
setInternalState(bean, QueryMetricFactory.class, new QueryMetricFactoryImpl());
setInternalState(bean, AccumuloConnectionRequestBean.class, connectionRequestBean);
// RESTEasy mock stuff
dispatcher = MockDispatcherFactory.createDispatcher();
dispatcher.getRegistry().addSingletonResource(bean, "/DataWave/Query");
response = new MockHttpResponse();
}
use of datawave.webservice.query.factory.Persister in project datawave by NationalSecurityAgency.
the class ExtendedQueryExecutorBeanTest method testPurgeQueryCacheAndMiscAccessors_HappyPath.
@Test
public void testPurgeQueryCacheAndMiscAccessors_HappyPath() throws Exception {
// Set expectations
this.cache.clear();
// Run the test
PowerMock.replayAll();
QueryExecutorBean subject = new QueryExecutorBean();
setInternalState(subject, QueryCache.class, cache);
setInternalState(subject, ClosedQueryCache.class, closedCache);
setInternalState(subject, QueryMetricFactory.class, new QueryMetricFactoryImpl());
VoidResponse result1 = subject.purgeQueryCache();
QueryMetricsBean result5 = subject.getMetrics();
QueryLogicFactory result6 = subject.getQueryFactory();
Persister result7 = subject.getPersister();
QueryCache result8 = subject.getQueryCache();
PowerMock.verifyAll();
// Verify results
assertNotNull("Expected a non-null response", result1);
assertNull("Expected a null metrics instance", result5);
assertNull("Expected a null query logic factory", result6);
assertNull("Expected a null persister", result7);
assertNotNull("Expected a NON-null cache", result8);
}
Aggregations