Search in sources :

Example 1 with Persister

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();
}
Also used : LookupUUIDConfiguration(datawave.webservice.query.configuration.LookupUUIDConfiguration) ClosedQueryCache(datawave.webservice.query.cache.ClosedQueryCache) QueryCache(datawave.webservice.query.cache.QueryCache) EJBContext(javax.ejb.EJBContext) QueryLogicFactoryImpl(datawave.webservice.query.logic.QueryLogicFactoryImpl) QueryExpirationConfiguration(datawave.webservice.query.cache.QueryExpirationConfiguration) AuditBean(datawave.webservice.common.audit.AuditBean) CreatedQueryLogicCacheBean(datawave.webservice.query.cache.CreatedQueryLogicCacheBean) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) ClosedQueryCache(datawave.webservice.query.cache.ClosedQueryCache) AccumuloConnectionFactory(datawave.webservice.common.connection.AccumuloConnectionFactory) ColumnVisibilitySecurityMarking(datawave.marking.ColumnVisibilitySecurityMarking) QueryTraceCache(datawave.webservice.query.cache.QueryTraceCache) QueryMetricsBean(datawave.webservice.query.metric.QueryMetricsBean) DefaultAuditParameterBuilder(datawave.webservice.common.audit.DefaultAuditParameterBuilder) Persister(datawave.webservice.query.factory.Persister) QueryMetricFactoryImpl(datawave.microservice.querymetric.QueryMetricFactoryImpl) AuditService(datawave.webservice.common.audit.AuditService) MockHttpResponse(org.jboss.resteasy.mock.MockHttpResponse) Before(org.junit.Before)

Example 2 with Persister

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);
}
Also used : ClosedQueryCache(datawave.webservice.query.cache.ClosedQueryCache) QueryCache(datawave.webservice.query.cache.QueryCache) VoidResponse(datawave.webservice.result.VoidResponse) QueryMetricsBean(datawave.webservice.query.metric.QueryMetricsBean) Persister(datawave.webservice.query.factory.Persister) QueryMetricFactoryImpl(datawave.microservice.querymetric.QueryMetricFactoryImpl) QueryLogicFactory(datawave.webservice.query.logic.QueryLogicFactory) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

QueryMetricFactoryImpl (datawave.microservice.querymetric.QueryMetricFactoryImpl)2 ClosedQueryCache (datawave.webservice.query.cache.ClosedQueryCache)2 QueryCache (datawave.webservice.query.cache.QueryCache)2 Persister (datawave.webservice.query.factory.Persister)2 QueryMetricsBean (datawave.webservice.query.metric.QueryMetricsBean)2 ColumnVisibilitySecurityMarking (datawave.marking.ColumnVisibilitySecurityMarking)1 AuditBean (datawave.webservice.common.audit.AuditBean)1 AuditService (datawave.webservice.common.audit.AuditService)1 DefaultAuditParameterBuilder (datawave.webservice.common.audit.DefaultAuditParameterBuilder)1 AccumuloConnectionFactory (datawave.webservice.common.connection.AccumuloConnectionFactory)1 QueryParametersImpl (datawave.webservice.query.QueryParametersImpl)1 CreatedQueryLogicCacheBean (datawave.webservice.query.cache.CreatedQueryLogicCacheBean)1 QueryExpirationConfiguration (datawave.webservice.query.cache.QueryExpirationConfiguration)1 QueryTraceCache (datawave.webservice.query.cache.QueryTraceCache)1 LookupUUIDConfiguration (datawave.webservice.query.configuration.LookupUUIDConfiguration)1 QueryLogicFactory (datawave.webservice.query.logic.QueryLogicFactory)1 QueryLogicFactoryImpl (datawave.webservice.query.logic.QueryLogicFactoryImpl)1 VoidResponse (datawave.webservice.result.VoidResponse)1 EJBContext (javax.ejb.EJBContext)1 MockHttpResponse (org.jboss.resteasy.mock.MockHttpResponse)1