Search in sources :

Example 1 with QueryPersistence

use of datawave.webservice.query.QueryPersistence in project datawave by NationalSecurityAgency.

the class QueryExecutorBeanTest method testCreateWithNoSelectedAuths.

@SuppressWarnings("unchecked")
@Test(expected = DatawaveWebApplicationException.class)
public void testCreateWithNoSelectedAuths() throws Exception {
    String queryLogicName = "EventQueryLogic";
    String queryName = "Something";
    String query = "FOO == BAR";
    Date beginDate = new Date();
    Date expirationDate = DateUtils.addDays(new Date(), 1);
    int pagesize = 10;
    QueryPersistence persist = QueryPersistence.TRANSIENT;
    Set<QueryImpl.Parameter> parameters = new HashSet<>();
    // need to call the getQueryByName() method. Maybe a partial mock of QueryExecutorBean would be better
    // setup principal mock
    String userDN = "CN=Guy Some Other soguy, OU=MY_SUBDIVISION, OU=MY_DIVISION, O=ORG, C=US";
    String[] auths = new String[2];
    auths[0] = "PRIVATE";
    auths[1] = "PUBLIC";
    QueryImpl q = new QueryImpl();
    q.setBeginDate(beginDate);
    q.setEndDate(beginDate);
    q.setExpirationDate(expirationDate);
    q.setPagesize(pagesize);
    q.setParameters(parameters);
    q.setQuery(query);
    q.setQueryAuthorizations(StringUtils.join(auths, ","));
    q.setQueryLogicName(queryLogicName);
    q.setUserDN(userDN);
    q.setId(UUID.randomUUID());
    @SuppressWarnings("rawtypes") QueryLogic logic = createMock(BaseQueryLogic.class);
    MultivaluedMap<String, String> p = new MultivaluedMapImpl<>();
    p.putSingle(QueryParameters.QUERY_AUTHORIZATIONS, "");
    p.putSingle(QueryParameters.QUERY_BEGIN, QueryParametersImpl.formatDate(beginDate));
    p.putSingle(QueryParameters.QUERY_END, QueryParametersImpl.formatDate(beginDate));
    p.putSingle(QueryParameters.QUERY_EXPIRATION, QueryParametersImpl.formatDate(expirationDate));
    p.putSingle(QueryParameters.QUERY_NAME, queryName);
    p.putSingle(QueryParameters.QUERY_PAGESIZE, Integer.toString(pagesize));
    p.putSingle(QueryParameters.QUERY_STRING, query);
    p.putSingle(QueryParameters.QUERY_PERSISTENCE, persist.name());
    p.putSingle(ColumnVisibilitySecurityMarking.VISIBILITY_MARKING, "PRIVATE|PUBLIC");
    InMemoryInstance instance = new InMemoryInstance();
    Connector c = instance.getConnector("root", new PasswordToken(""));
    QueryParameters qp = new QueryParametersImpl();
    MultivaluedMap<String, String> optionalParameters = new MultivaluedMapImpl<>();
    optionalParameters.putAll(qp.getUnknownParameters(p));
    DatawaveUser user = new DatawaveUser(SubjectIssuerDNPair.of(userDN, "<CN=MY_CA, OU=MY_SUBDIVISION, OU=MY_DIVISION, O=ORG, C=US>"), UserType.USER, Arrays.asList(auths), null, null, 0L);
    DatawavePrincipal principal = new DatawavePrincipal(Collections.singletonList(user));
    String[] dns = principal.getDNs();
    Arrays.sort(dns);
    List<String> dnList = Arrays.asList(dns);
    PowerMock.resetAll();
    EasyMock.expect(ctx.getCallerPrincipal()).andReturn(principal).anyTimes();
    suppress(constructor(QueryParametersImpl.class));
    EasyMock.expect(persister.create(userDN, dnList, (SecurityMarking) Whitebox.getField(bean.getClass(), "marking").get(bean), queryLogicName, (QueryParameters) Whitebox.getField(bean.getClass(), "qp").get(bean), optionalParameters)).andReturn(q);
    EasyMock.expect(queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn(logic);
    EasyMock.expect(logic.getRequiredQueryParameters()).andReturn(Collections.EMPTY_SET);
    EasyMock.expect(logic.containsDNWithAccess(dnList)).andReturn(true);
    EasyMock.expect(logic.getMaxPageSize()).andReturn(0);
    EasyMock.expect(logic.getAuditType(EasyMock.<Query>anyObject())).andReturn(AuditType.ACTIVE).anyTimes();
    EasyMock.expect(logic.getSelectors(anyObject())).andReturn(null);
    Map<String, String> auditParams = new HashMap<>();
    auditParams.put(QueryParameters.QUERY_STRING, p.getFirst(QueryParameters.QUERY_STRING));
    auditParams.put(AuditParameters.USER_DN, userDN);
    auditParams.put(AuditParameters.QUERY_SECURITY_MARKING_COLVIZ, "PRIVATE|PUBLIC");
    auditParams.put(AuditParameters.QUERY_AUDIT_TYPE, AuditType.ACTIVE.name());
    auditParams.put(AuditParameters.QUERY_LOGIC_CLASS, "EventQueryLogic");
    EasyMock.expect(auditService.audit(eq(auditParams))).andReturn(null);
    logic.close();
    EasyMock.expectLastCall();
    persister.remove(anyObject(Query.class));
    PowerMock.replayAll();
    bean.createQuery(queryLogicName, p);
    PowerMock.verifyAll();
}
Also used : Connector(org.apache.accumulo.core.client.Connector) Query(datawave.webservice.query.Query) HashMap(java.util.HashMap) DatawaveUser(datawave.security.authorization.DatawaveUser) MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) InMemoryInstance(datawave.accumulo.inmemory.InMemoryInstance) BaseQueryLogic(datawave.webservice.query.logic.BaseQueryLogic) QueryLogic(datawave.webservice.query.logic.QueryLogic) QueryParameters(datawave.webservice.query.QueryParameters) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) Date(java.util.Date) DatawavePrincipal(datawave.security.authorization.DatawavePrincipal) QueryImpl(datawave.webservice.query.QueryImpl) PasswordToken(org.apache.accumulo.core.client.security.tokens.PasswordToken) QueryPersistence(datawave.webservice.query.QueryPersistence) HashSet(java.util.HashSet) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 2 with QueryPersistence

use of datawave.webservice.query.QueryPersistence in project datawave by NationalSecurityAgency.

the class ExtendedQueryExecutorBeanTest method testCreateQuery_auditException.

@Test(expected = DatawaveWebApplicationException.class)
public void testCreateQuery_auditException() throws Exception {
    String queryLogicName = "queryLogicName";
    String query = "query";
    String queryName = "queryName";
    String queryVisibility = "A&B";
    long currentTime = System.currentTimeMillis();
    Date beginDate = new Date(currentTime - 5000);
    Date endDate = new Date(currentTime - 1000);
    String queryAuthorizations = "AUTH_1";
    Date expirationDate = new Date(currentTime + 999999);
    int pagesize = 10;
    QueryPersistence persistenceMode = QueryPersistence.PERSISTENT;
    boolean trace = false;
    String userName = "userName";
    String userSid = "userSid";
    String userDN = "userDN";
    SubjectIssuerDNPair userDNpair = SubjectIssuerDNPair.of(userDN);
    List<String> dnList = Collections.singletonList(userDN);
    UUID queryId = UUID.randomUUID();
    long pageNumber = 0L;
    HashMap<String, Collection<String>> authsMap = new HashMap<>();
    authsMap.put("USERDN", Arrays.asList(queryAuthorizations));
    MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl<>();
    queryParameters.putSingle(QueryParameters.QUERY_STRING, query);
    queryParameters.putSingle(QueryParameters.QUERY_NAME, queryName);
    queryParameters.putSingle(QueryParameters.QUERY_LOGIC_NAME, queryLogicName);
    queryParameters.putSingle(QueryParameters.QUERY_BEGIN, QueryParametersImpl.formatDate(beginDate));
    queryParameters.putSingle(QueryParameters.QUERY_END, QueryParametersImpl.formatDate(endDate));
    queryParameters.putSingle(QueryParameters.QUERY_EXPIRATION, QueryParametersImpl.formatDate(expirationDate));
    queryParameters.putSingle(QueryParameters.QUERY_AUTHORIZATIONS, queryAuthorizations);
    queryParameters.putSingle(QueryParameters.QUERY_PAGESIZE, String.valueOf(pagesize));
    queryParameters.putSingle(QueryParameters.QUERY_PERSISTENCE, persistenceMode.name());
    queryParameters.putSingle(QueryParameters.QUERY_TRACE, String.valueOf(trace));
    queryParameters.putSingle(ColumnVisibilitySecurityMarking.VISIBILITY_MARKING, queryVisibility);
    queryParameters.putSingle("valid", "param");
    expect(context.getCallerPrincipal()).andReturn(principal).anyTimes();
    expect(this.queryLogicFactory.getQueryLogic(queryLogicName, this.principal)).andReturn((QueryLogic) this.queryLogic1);
    queryLogic1.validate(queryParameters);
    expect(principal.getName()).andReturn(userName);
    expect(principal.getShortName()).andReturn(userSid);
    expect(principal.getUserDN()).andReturn(userDNpair);
    expect(principal.getDNs()).andReturn(new String[] { userDN });
    expect(this.principal.getProxyServers()).andReturn(new ArrayList<>(0)).anyTimes();
    expect(this.queryLogic1.containsDNWithAccess(Collections.singletonList(userDN))).andReturn(true);
    expect(this.queryLogic1.getAuditType(null)).andReturn(AuditType.ACTIVE);
    expect(this.principal.getAuthorizations()).andReturn((Collection) Arrays.asList(Arrays.asList(queryAuthorizations)));
    expect(this.queryLogic1.getMaxPageSize()).andReturn(10).anyTimes();
    expect(queryLogic1.getSelectors(null)).andReturn(null);
    expect(auditor.audit(queryParameters)).andThrow(new JMSRuntimeException("EXPECTED TESTING EXCEPTION"));
    queryLogic1.close();
    PowerMock.replayAll();
    QueryExecutorBean executor = new QueryExecutorBean();
    setInternalState(executor, EJBContext.class, context);
    setInternalState(executor, AccumuloConnectionFactory.class, connectionFactory);
    setInternalState(executor, ResponseObjectFactory.class, responseObjectFactory);
    setInternalState(executor, CreatedQueryLogicCacheBean.class, qlCache);
    setInternalState(executor, QueryCache.class, cache);
    setInternalState(executor, ClosedQueryCache.class, closedCache);
    setInternalState(executor, Persister.class, persister);
    setInternalState(executor, QueryLogicFactoryImpl.class, queryLogicFactory);
    setInternalState(executor, QueryExpirationConfiguration.class, queryExpirationConf);
    setInternalState(executor, AuditBean.class, auditor);
    setInternalState(executor, QueryMetricsBean.class, metrics);
    setInternalState(executor, Multimap.class, traceInfos);
    setInternalState(executor, SecurityMarking.class, new ColumnVisibilitySecurityMarking());
    setInternalState(executor, QueryParameters.class, new QueryParametersImpl());
    setInternalState(executor, QueryMetricFactory.class, new QueryMetricFactoryImpl());
    setInternalState(connectionRequestBean, EJBContext.class, context);
    setInternalState(executor, AccumuloConnectionRequestBean.class, connectionRequestBean);
    executor.createQuery(queryLogicName, queryParameters);
    PowerMock.verifyAll();
}
Also used : SubjectIssuerDNPair(datawave.security.authorization.SubjectIssuerDNPair) HashMap(java.util.HashMap) MultivaluedHashMap(javax.ws.rs.core.MultivaluedHashMap) ArrayList(java.util.ArrayList) MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) Date(java.util.Date) ColumnVisibilitySecurityMarking(datawave.marking.ColumnVisibilitySecurityMarking) QueryPersistence(datawave.webservice.query.QueryPersistence) Collection(java.util.Collection) UUID(java.util.UUID) QueryMetricFactoryImpl(datawave.microservice.querymetric.QueryMetricFactoryImpl) JMSRuntimeException(javax.jms.JMSRuntimeException) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 3 with QueryPersistence

use of datawave.webservice.query.QueryPersistence in project datawave by NationalSecurityAgency.

the class ExtendedQueryExecutorBeanTest method testCreateQueryAndNext_InvalidExpirationDate.

@Test
public void testCreateQueryAndNext_InvalidExpirationDate() throws Exception {
    // Set local test input
    String queryLogicName = "queryLogicName";
    String query = "query";
    String queryName = "queryName";
    String queryVisibility = "A&B";
    long currentTime = System.currentTimeMillis();
    Date beginDate = new Date(currentTime - 5000);
    Date endDate = new Date(currentTime - 1000);
    String queryAuthorizations = "AUTH_1";
    Date expirationDate = new Date(currentTime - 500);
    int pagesize = 1;
    int pageTimeout = -1;
    Long maxResultsOverride = null;
    QueryPersistence persistenceMode = QueryPersistence.PERSISTENT;
    String parameters = null;
    boolean trace = false;
    MultivaluedMap<String, String> p = new MultivaluedMapImpl<>();
    p.putAll(QueryParametersImpl.paramsToMap(queryLogicName, query, queryName, queryVisibility, beginDate, endDate, queryAuthorizations, expirationDate, pagesize, pageTimeout, maxResultsOverride, persistenceMode, parameters, trace));
    // Run the test
    PowerMock.replayAll();
    QueryExecutorBean subject = new QueryExecutorBean();
    setInternalState(subject, QueryParameters.class, new QueryParametersImpl());
    setInternalState(subject, QueryMetricFactory.class, new QueryMetricFactoryImpl());
    Throwable result1 = null;
    try {
        subject.createQueryAndNext(queryLogicName, p);
    } catch (DatawaveWebApplicationException e) {
        result1 = e;
    }
    PowerMock.verifyAll();
    // Verify results
    assertTrue("BadRequestException expected to have been thrown", result1 instanceof BadRequestException);
    assertEquals("Thrown exception expected to have been due to invalid expiration date", "400-3", ((QueryException) result1.getCause()).getErrorCode());
}
Also used : MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) Date(java.util.Date) QueryPersistence(datawave.webservice.query.QueryPersistence) DatawaveWebApplicationException(datawave.webservice.common.exception.DatawaveWebApplicationException) BadRequestException(datawave.webservice.common.exception.BadRequestException) QueryMetricFactoryImpl(datawave.microservice.querymetric.QueryMetricFactoryImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 4 with QueryPersistence

use of datawave.webservice.query.QueryPersistence in project datawave by NationalSecurityAgency.

the class ExtendedQueryExecutorBeanTest method testExecute_HappyPath.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Test
public void testExecute_HappyPath() throws Exception {
    // Set local test input
    String queryLogicName = "queryLogicName";
    String query = "query";
    String queryName = "queryName";
    String queryVisibility = "A&B";
    long currentTime = System.currentTimeMillis();
    Date beginDate = new Date(currentTime - 5000);
    Date endDate = new Date(currentTime - 1000);
    String queryAuthorizations = "AUTH_1";
    Date expirationDate = new Date(currentTime + 9999);
    int pagesize = 10;
    int pageTimeout = -1;
    Long maxResultsOverride = null;
    QueryPersistence persistenceMode = QueryPersistence.PERSISTENT;
    String parameters = "invalidparam; valid:param";
    boolean trace = false;
    UUID queryId = UUID.randomUUID();
    List<MediaType> mediaTypes = new ArrayList<>();
    mediaTypes.add(MediaType.APPLICATION_XML_TYPE);
    GenericResponse<String> createResponse = new GenericResponse<>();
    createResponse.setResult(queryId.toString());
    QueryImpl qp = new QueryImpl();
    qp.setQuery(query);
    qp.setQueryName(queryName);
    qp.setDnList(Collections.singletonList("someDN"));
    qp.setQueryAuthorizations(queryAuthorizations);
    qp.setColumnVisibility(queryVisibility);
    qp.setBeginDate(beginDate);
    qp.setEndDate(endDate);
    qp.setExpirationDate(expirationDate);
    qp.setPagesize(pagesize);
    qp.setPageTimeout(pageTimeout);
    qp.setColumnVisibility(queryAuthorizations);
    MultivaluedMap<String, String> params = new MultivaluedMapImpl<>();
    params.putAll(qp.toMap());
    params.putSingle(QueryParameters.QUERY_TRACE, Boolean.toString(trace));
    params.putSingle(QueryParameters.QUERY_PERSISTENCE, persistenceMode.name());
    params.putSingle(QueryParameters.QUERY_PARAMS, parameters);
    QueryExecutorBean subject = PowerMock.createPartialMock(QueryExecutorBean.class, "createQuery");
    // Set expectations of the create logic
    expect(this.context.getCallerPrincipal()).andReturn(this.principal).anyTimes();
    expect(this.principal.getProxyServers()).andReturn(new ArrayList<>(0)).anyTimes();
    expect(this.httpHeaders.getAcceptableMediaTypes()).andReturn(mediaTypes);
    expect(this.queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn((QueryLogic) this.queryLogic1);
    expect(this.queryLogic1.getTransformer(isA(Query.class))).andReturn(this.transformer);
    expect(this.transformer.createResponse(isA(ResultsPage.class))).andReturn(this.baseResponse);
    expect(subject.createQuery(queryLogicName, params, httpHeaders)).andReturn(createResponse);
    expect(this.cache.get(eq(queryId.toString()))).andReturn(this.runningQuery);
    expect(this.runningQuery.getMetric()).andReturn(this.queryMetric);
    this.queryMetric.setCreateCallTime(EasyMock.geq(0L));
    // return streaming response
    // Run the test
    PowerMock.replayAll();
    setInternalState(subject, EJBContext.class, context);
    setInternalState(subject, AccumuloConnectionFactory.class, connectionFactory);
    setInternalState(subject, ResponseObjectFactory.class, responseObjectFactory);
    setInternalState(subject, CreatedQueryLogicCacheBean.class, qlCache);
    setInternalState(subject, QueryCache.class, cache);
    setInternalState(subject, ClosedQueryCache.class, closedCache);
    setInternalState(subject, Persister.class, persister);
    setInternalState(subject, QueryLogicFactory.class, queryLogicFactory);
    setInternalState(subject, QueryExpirationConfiguration.class, queryExpirationConf);
    setInternalState(subject, AuditBean.class, auditor);
    setInternalState(subject, QueryMetricsBean.class, metrics);
    setInternalState(subject, Multimap.class, traceInfos);
    setInternalState(subject, QueryMetricFactory.class, new QueryMetricFactoryImpl());
    StreamingOutput result1 = subject.execute(queryLogicName, params, httpHeaders);
    PowerMock.verifyAll();
    // Verify results
    assertNotNull("Expected a non-null response", result1);
}
Also used : Query(datawave.webservice.query.Query) GenericResponse(datawave.webservice.result.GenericResponse) ArrayList(java.util.ArrayList) MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) ResultsPage(datawave.webservice.query.cache.ResultsPage) StreamingOutput(javax.ws.rs.core.StreamingOutput) Date(java.util.Date) QueryImpl(datawave.webservice.query.QueryImpl) QueryPersistence(datawave.webservice.query.QueryPersistence) MediaType(javax.ws.rs.core.MediaType) UUID(java.util.UUID) QueryMetricFactoryImpl(datawave.microservice.querymetric.QueryMetricFactoryImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 5 with QueryPersistence

use of datawave.webservice.query.QueryPersistence in project datawave by NationalSecurityAgency.

the class ExtendedQueryExecutorBeanTest method testDefineQuery_UncheckedException.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Test(expected = IllegalArgumentException.class)
public void testDefineQuery_UncheckedException() throws Exception {
    // Set local test input
    String queryLogicName = "queryLogicName";
    String query = "query";
    String queryName = "queryName";
    String queryVisibility = "A&B";
    long currentTime = System.currentTimeMillis();
    Date beginDate = new Date(currentTime - 5000);
    Date endDate = new Date(currentTime - 1000);
    String queryAuthorizations = "AUTH_1";
    Date expirationDate = new Date(currentTime + 10000);
    int pagesize = 10;
    int pageTimeout = -1;
    Long maxResultsOverride = null;
    QueryPersistence persistenceMode = QueryPersistence.PERSISTENT;
    String userName = "userName";
    String userSid = "userSid";
    String userDN = "userdn";
    SubjectIssuerDNPair userDNpair = SubjectIssuerDNPair.of(userDN);
    boolean trace = false;
    List<String> dnList = Collections.singletonList(userDN);
    UUID queryId = UUID.randomUUID();
    MultivaluedMap<String, String> queryParameters = new MultivaluedMapImpl<>();
    queryParameters.putAll(QueryParametersImpl.paramsToMap(null, query, queryName, queryVisibility, beginDate, endDate, queryAuthorizations, expirationDate, pagesize, pageTimeout, maxResultsOverride, persistenceMode, null, trace));
    queryParameters.putSingle("valid", "param");
    ColumnVisibilitySecurityMarking marking = new ColumnVisibilitySecurityMarking();
    marking.validate(queryParameters);
    QueryParameters qp = new QueryParametersImpl();
    qp.validate(queryParameters);
    MultivaluedMap<String, String> op = new MultivaluedMapImpl<>();
    op.putAll(qp.getUnknownParameters(queryParameters));
    op.putSingle(PrivateAuditConstants.LOGIC_CLASS, queryLogicName);
    op.putSingle(PrivateAuditConstants.COLUMN_VISIBILITY, queryVisibility);
    op.putSingle(PrivateAuditConstants.USER_DN, userDNpair.subjectDN());
    // Set expectations
    queryLogic1.validate(queryParameters);
    expect(this.context.getCallerPrincipal()).andReturn(this.principal).anyTimes();
    expect(this.principal.getName()).andReturn(userName);
    expect(this.principal.getShortName()).andReturn(userSid);
    expect(this.principal.getDNs()).andReturn(new String[] { userDN });
    expect(this.principal.getProxyServers()).andReturn(new ArrayList<>(0));
    expect(this.principal.getAuthorizations()).andReturn((Collection) Arrays.asList(Arrays.asList(queryAuthorizations)));
    expect(this.principal.getUserDN()).andReturn(userDNpair);
    expect(persister.create(eq(userDNpair.subjectDN()), eq(dnList), eq(marking), eq(queryLogicName), eq(qp), eq(op))).andReturn(this.query);
    expect(this.query.getId()).andReturn(queryId).times(3);
    expect(this.queryLogicFactory.getQueryLogic(queryLogicName, principal)).andReturn((QueryLogic) this.queryLogic1);
    expect(this.queryLogic1.getMaxPageSize()).andReturn(100).times(2);
    expect(this.traceInfos.get(userSid)).andReturn(new ArrayList<>(0));
    expect(this.traceInfos.get(null)).andReturn(Arrays.asList(PatternWrapper.wrap(query)));
    PowerMock.mockStaticPartial(Trace.class, "start");
    expect(Trace.start("query:define")).andReturn(this.span);
    expect(this.queryLogic1.getConnectionPriority()).andThrow(ILLEGAL_STATE_EXCEPTION);
    // TODO: 1.8.1: no longer done
    // expect(this.span.parent()).andReturn(this.span);
    // expect(this.span.parent()).andReturn(this.span);
    this.span.stop();
    // Run the test
    PowerMock.replayAll();
    try {
        QueryExecutorBean subject = new QueryExecutorBean();
        setInternalState(subject, EJBContext.class, context);
        setInternalState(subject, Persister.class, persister);
        setInternalState(subject, QueryLogicFactory.class, queryLogicFactory);
        setInternalState(subject, QueryExpirationConfiguration.class, queryExpirationConf);
        setInternalState(subject, Multimap.class, traceInfos);
        setInternalState(subject, SecurityMarking.class, new ColumnVisibilitySecurityMarking());
        setInternalState(subject, QueryParameters.class, new QueryParametersImpl());
        setInternalState(subject, QueryMetricFactory.class, new QueryMetricFactoryImpl());
        subject.defineQuery(queryLogicName, queryParameters);
    } finally {
        PowerMock.verifyAll();
    }
}
Also used : SubjectIssuerDNPair(datawave.security.authorization.SubjectIssuerDNPair) MultivaluedMapImpl(org.jboss.resteasy.specimpl.MultivaluedMapImpl) QueryParameters(datawave.webservice.query.QueryParameters) QueryParametersImpl(datawave.webservice.query.QueryParametersImpl) Date(java.util.Date) ColumnVisibilitySecurityMarking(datawave.marking.ColumnVisibilitySecurityMarking) QueryPersistence(datawave.webservice.query.QueryPersistence) UUID(java.util.UUID) QueryMetricFactoryImpl(datawave.microservice.querymetric.QueryMetricFactoryImpl) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

QueryPersistence (datawave.webservice.query.QueryPersistence)30 Date (java.util.Date)29 Test (org.junit.Test)29 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)29 QueryMetricFactoryImpl (datawave.microservice.querymetric.QueryMetricFactoryImpl)27 MultivaluedMapImpl (org.jboss.resteasy.specimpl.MultivaluedMapImpl)26 QueryParametersImpl (datawave.webservice.query.QueryParametersImpl)23 DatawaveWebApplicationException (datawave.webservice.common.exception.DatawaveWebApplicationException)18 ArrayList (java.util.ArrayList)17 UUID (java.util.UUID)17 ColumnVisibilitySecurityMarking (datawave.marking.ColumnVisibilitySecurityMarking)15 QueryParameters (datawave.webservice.query.QueryParameters)15 NoResultsQueryException (datawave.webservice.query.exception.NoResultsQueryException)15 QueryException (datawave.webservice.query.exception.QueryException)14 SubjectIssuerDNPair (datawave.security.authorization.SubjectIssuerDNPair)12 Collection (java.util.Collection)10 HashSet (java.util.HashSet)10 BadRequestException (datawave.webservice.common.exception.BadRequestException)9 BaseQueryLogic (datawave.webservice.query.logic.BaseQueryLogic)8 QueryLogic (datawave.webservice.query.logic.QueryLogic)8