mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Implementation of QContext everywhere, instead of passing QInstance and QSession in all ActionInputs
This commit is contained in:
@ -133,7 +133,7 @@ public class RDBMSQueryAction extends AbstractRDBMSAction implements QueryInterf
|
||||
// execute the query - iterate over results //
|
||||
//////////////////////////////////////////////
|
||||
QueryOutput queryOutput = new QueryOutput(queryInput);
|
||||
// System.out.println(sql);
|
||||
System.out.println(sql);
|
||||
PreparedStatement statement = createStatement(connection, sql.toString(), queryInput);
|
||||
QueryManager.executeStatement(statement, ((ResultSet resultSet) ->
|
||||
{
|
||||
|
@ -40,10 +40,9 @@ import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
|
||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||
import com.kingsrook.qqq.backend.core.utils.ListingHash;
|
||||
import com.kingsrook.qqq.backend.core.utils.QLogger;
|
||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.QueryManager;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -56,7 +55,7 @@ import org.apache.logging.log4j.Logger;
|
||||
*******************************************************************************/
|
||||
public class RDBMSUpdateAction extends AbstractRDBMSAction implements UpdateInterface
|
||||
{
|
||||
private static final Logger LOG = LogManager.getLogger(RDBMSUpdateAction.class);
|
||||
private static final QLogger LOG = QLogger.getLogger(RDBMSUpdateAction.class);
|
||||
|
||||
private int statusCounter = 0;
|
||||
|
||||
|
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright © 2022-2023. Nutrifresh Services <contact@nutrifreshservices.com>. All Rights Reserved.
|
||||
*/
|
||||
|
||||
package com.kingsrook.qqq.backend.module.rdbms;
|
||||
|
||||
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.model.session.QSession;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public class BaseTest
|
||||
{
|
||||
private static final Logger LOG = LogManager.getLogger(BaseTest.class);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@BeforeEach
|
||||
void baseBeforeEach()
|
||||
{
|
||||
QContext.init(TestUtils.defineInstance(), new QSession());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@AfterEach
|
||||
void baseAfterEach()
|
||||
{
|
||||
QContext.clear();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
protected static void reInitInstanceInContext(QInstance qInstance)
|
||||
{
|
||||
if(qInstance.equals(QContext.getQInstance()))
|
||||
{
|
||||
LOG.warn("Unexpected condition - the same qInstance that is already in the QContext was passed into reInit. You probably want a new QInstance object instance.");
|
||||
}
|
||||
QContext.init(qInstance, new QSession());
|
||||
}
|
||||
|
||||
}
|
@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.module.rdbms.actions;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.BaseTest;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.TestUtils;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.QueryManager;
|
||||
@ -32,7 +33,7 @@ import org.junit.jupiter.api.AfterEach;
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public class RDBMSActionTest
|
||||
public class RDBMSActionTest extends BaseTest
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
@ -58,7 +59,6 @@ public class RDBMSActionTest
|
||||
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
@ -26,6 +26,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.aggregate.Aggregate;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.aggregate.AggregateInput;
|
||||
@ -310,9 +311,8 @@ public class RDBMSAggregateActionTest extends RDBMSActionTest
|
||||
@Test
|
||||
void testOmsJoinAggregate() throws Exception
|
||||
{
|
||||
AggregateInput aggregateInput = new AggregateInput(TestUtils.defineInstance());
|
||||
AggregateInput aggregateInput = new AggregateInput();
|
||||
Aggregate sumOfQuantity = new Aggregate(TestUtils.TABLE_NAME_ORDER_LINE + ".quantity", AggregateOperator.SUM);
|
||||
aggregateInput.setSession(new QSession());
|
||||
aggregateInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
aggregateInput.withAggregate(sumOfQuantity);
|
||||
aggregateInput.withQueryJoin(new QueryJoin(TestUtils.TABLE_NAME_ORDER, TestUtils.TABLE_NAME_ORDER_LINE));
|
||||
@ -321,12 +321,12 @@ public class RDBMSAggregateActionTest extends RDBMSActionTest
|
||||
AggregateResult aggregateResult = aggregateOutput.getResults().get(0);
|
||||
assertNull(aggregateResult.getAggregateValue(sumOfQuantity));
|
||||
|
||||
aggregateInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
aggregateOutput = new RDBMSAggregateAction().execute(aggregateInput);
|
||||
aggregateResult = aggregateOutput.getResults().get(0);
|
||||
Assertions.assertEquals(43, aggregateResult.getAggregateValue(sumOfQuantity));
|
||||
|
||||
aggregateInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
aggregateOutput = new RDBMSAggregateAction().execute(aggregateInput);
|
||||
aggregateResult = aggregateOutput.getResults().get(0);
|
||||
// note - this would be 33, except for that one order line that has a contradictory store id...
|
||||
@ -343,9 +343,8 @@ public class RDBMSAggregateActionTest extends RDBMSActionTest
|
||||
{
|
||||
GroupBy groupBy = new GroupBy(QFieldType.STRING, TestUtils.TABLE_NAME_ORDER_LINE + ".sku", null);
|
||||
|
||||
AggregateInput aggregateInput = new AggregateInput(TestUtils.defineInstance());
|
||||
AggregateInput aggregateInput = new AggregateInput();
|
||||
Aggregate sumOfQuantity = new Aggregate(TestUtils.TABLE_NAME_ORDER_LINE + ".quantity", AggregateOperator.SUM);
|
||||
aggregateInput.setSession(new QSession());
|
||||
aggregateInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
aggregateInput.withAggregate(sumOfQuantity);
|
||||
aggregateInput.withGroupBy(groupBy);
|
||||
@ -354,7 +353,7 @@ public class RDBMSAggregateActionTest extends RDBMSActionTest
|
||||
AggregateOutput aggregateOutput = new RDBMSAggregateAction().execute(aggregateInput);
|
||||
assertEquals(0, aggregateOutput.getResults().size());
|
||||
|
||||
aggregateInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
aggregateOutput = new RDBMSAggregateAction().execute(aggregateInput);
|
||||
assertSkuQuantity("QM-1", 30, aggregateOutput.getResults(), groupBy);
|
||||
assertSkuQuantity("QM-2", 1, aggregateOutput.getResults(), groupBy);
|
||||
@ -390,8 +389,7 @@ public class RDBMSAggregateActionTest extends RDBMSActionTest
|
||||
*******************************************************************************/
|
||||
private static void insertExtraPersonRecords() throws QException
|
||||
{
|
||||
InsertInput insertInput = new InsertInput(TestUtils.defineInstance());
|
||||
insertInput.setSession(new QSession());
|
||||
InsertInput insertInput = new InsertInput();
|
||||
insertInput.setTableName(TestUtils.defineTablePerson().getName());
|
||||
insertInput.setRecords(List.of(
|
||||
new QRecord().withValue("lastName", "Kelkhoff").withValue("firstName", "Trevor").withValue("email", "tk@kr.com").withValue("daysWorked", 1024),
|
||||
@ -410,7 +408,6 @@ public class RDBMSAggregateActionTest extends RDBMSActionTest
|
||||
private AggregateInput initAggregateRequest()
|
||||
{
|
||||
AggregateInput aggregateInput = new AggregateInput();
|
||||
aggregateInput.setInstance(TestUtils.defineInstance());
|
||||
aggregateInput.setTableName(TestUtils.defineTablePerson().getName());
|
||||
return aggregateInput;
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ package com.kingsrook.qqq.backend.module.rdbms.actions;
|
||||
|
||||
import java.util.List;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountOutput;
|
||||
@ -117,8 +118,6 @@ public class RDBMSCountActionTest extends RDBMSActionTest
|
||||
private CountInput initCountRequest()
|
||||
{
|
||||
CountInput countInput = new CountInput();
|
||||
countInput.setInstance(TestUtils.defineInstance());
|
||||
countInput.setSession(new QSession());
|
||||
countInput.setTableName(TestUtils.defineTablePerson().getName());
|
||||
return countInput;
|
||||
}
|
||||
@ -189,16 +188,15 @@ public class RDBMSCountActionTest extends RDBMSActionTest
|
||||
void testRecordSecurity() throws QException
|
||||
{
|
||||
CountInput countInput = new CountInput();
|
||||
countInput.setInstance(TestUtils.defineInstance());
|
||||
countInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
countInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new CountAction().execute(countInput).getCount()).isEqualTo(0);
|
||||
|
||||
countInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new CountAction().execute(countInput).getCount()).isEqualTo(8);
|
||||
|
||||
countInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(2, 3)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(2, 3)));
|
||||
assertThat(new CountAction().execute(countInput).getCount()).isEqualTo(5);
|
||||
}
|
||||
|
||||
|
@ -138,7 +138,6 @@ public class RDBMSDeleteActionTest extends RDBMSActionTest
|
||||
private DeleteInput initStandardPersonDeleteRequest()
|
||||
{
|
||||
DeleteInput deleteInput = new DeleteInput();
|
||||
deleteInput.setInstance(TestUtils.defineInstance());
|
||||
deleteInput.setTableName(TestUtils.defineTablePerson().getName());
|
||||
return deleteInput;
|
||||
}
|
||||
@ -319,9 +318,11 @@ public class RDBMSDeleteActionTest extends RDBMSActionTest
|
||||
.withBackendDetails(new RDBMSTableBackendDetails()
|
||||
.withTableName("parent_table")));
|
||||
|
||||
reInitInstanceInContext(qInstance);
|
||||
|
||||
DeleteInput deleteInput = new DeleteInput();
|
||||
deleteInput.setInstance(qInstance);
|
||||
deleteInput.setTableName(childTableName);
|
||||
|
||||
return deleteInput;
|
||||
}
|
||||
}
|
@ -164,7 +164,6 @@ public class RDBMSInsertActionTest extends RDBMSActionTest
|
||||
private InsertInput initInsertRequest()
|
||||
{
|
||||
InsertInput insertInput = new InsertInput();
|
||||
insertInput.setInstance(TestUtils.defineInstance());
|
||||
insertInput.setTableName(TestUtils.defineTablePerson().getName());
|
||||
return insertInput;
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import java.util.function.Predicate;
|
||||
import com.kingsrook.qqq.backend.core.actions.QBackendTransaction;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.insert.InsertInput;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QCriteriaOperator;
|
||||
@ -451,9 +452,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
private QueryInput initQueryRequest()
|
||||
{
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setInstance(TestUtils.defineInstance());
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_PERSON);
|
||||
queryInput.setSession(new QSession());
|
||||
return queryInput;
|
||||
}
|
||||
|
||||
@ -488,8 +487,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
@Test
|
||||
void testLookInsideTransaction() throws QException
|
||||
{
|
||||
InsertInput insertInput = new InsertInput(TestUtils.defineInstance());
|
||||
insertInput.setSession(new QSession());
|
||||
InsertInput insertInput = new InsertInput();
|
||||
insertInput.setTableName(TestUtils.TABLE_NAME_PERSON);
|
||||
|
||||
InsertAction insertAction = new InsertAction();
|
||||
@ -748,7 +746,8 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
@Test
|
||||
void testFiveTableOmsJoinFindMismatchedStoreId() throws Exception
|
||||
{
|
||||
QueryInput queryInput = new QueryInput(TestUtils.defineInstance(), new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QueryInput queryInput = new QueryInput();
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
queryInput.withQueryJoin(new QueryJoin(TestUtils.TABLE_NAME_ORDER, TestUtils.TABLE_NAME_STORE).withAlias("orderStore").withSelect(true));
|
||||
queryInput.withQueryJoin(new QueryJoin(TestUtils.TABLE_NAME_ORDER, TestUtils.TABLE_NAME_ORDER_LINE).withSelect(true));
|
||||
@ -790,7 +789,8 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
orderLineCount.set(rs.getInt(1));
|
||||
});
|
||||
|
||||
QueryInput queryInput = new QueryInput(TestUtils.defineInstance(), new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QueryInput queryInput = new QueryInput();
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER_LINE);
|
||||
queryInput.withQueryJoin(new QueryJoin(TestUtils.TABLE_NAME_ORDER).withSelect(true));
|
||||
|
||||
@ -811,7 +811,8 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testOmsQueryByPersons() throws Exception
|
||||
{
|
||||
QInstance instance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(instance, new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QueryInput queryInput = new QueryInput();
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
@ -913,7 +914,8 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testOmsQueryByPersonsExtraKelkhoffOrder() throws Exception
|
||||
{
|
||||
QInstance instance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(instance, new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QueryInput queryInput = new QueryInput();
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -967,7 +969,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testDuplicateAliases()
|
||||
{
|
||||
QInstance instance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(instance, new QSession());
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
queryInput.withQueryJoins(List.of(
|
||||
@ -998,35 +1000,35 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testRecordSecurityPrimaryKeyFieldNoFilters() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_STORE);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).hasSize(3);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(1)
|
||||
.anyMatch(r -> r.getValueInteger("id").equals(1));
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 2));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 2));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(1)
|
||||
.anyMatch(r -> r.getValueInteger("id").equals(2));
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, null));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, null));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, Collections.emptyList()));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, Collections.emptyList()));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(2)
|
||||
.anyMatch(r -> r.getValueInteger("id").equals(1))
|
||||
@ -1043,35 +1045,35 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testRecordSecurityForeignKeyFieldNoFilters() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).hasSize(8);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(3)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1));
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 2));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 2));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(2)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(2));
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, null));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, null));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, Collections.emptyList()));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, Collections.emptyList()));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(6)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1) || r.getValueInteger("storeId").equals(3));
|
||||
@ -1086,29 +1088,29 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testRecordSecurityWithFilters() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).hasSize(6);
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(2)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1));
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("storeId", QCriteriaOperator.IN, List.of(1, 2))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(3)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1));
|
||||
@ -1123,14 +1125,14 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testRecordSecurityWithOrQueries() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(
|
||||
new QFilterCriteria("billToPersonId", QCriteriaOperator.EQUALS, List.of(1)),
|
||||
new QFilterCriteria("shipToPersonId", QCriteriaOperator.EQUALS, List.of(5))
|
||||
).withBooleanOperator(QQueryFilter.BooleanOperator.OR));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(5)
|
||||
.allMatch(r -> Objects.equals(r.getValueInteger("billToPersonId"), 1) || Objects.equals(r.getValueInteger("shipToPersonId"), 5));
|
||||
@ -1139,7 +1141,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
new QFilterCriteria("billToPersonId", QCriteriaOperator.EQUALS, List.of(1)),
|
||||
new QFilterCriteria("shipToPersonId", QCriteriaOperator.EQUALS, List.of(5))
|
||||
).withBooleanOperator(QQueryFilter.BooleanOperator.OR));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 2));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 2));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(1)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(2))
|
||||
@ -1155,7 +1157,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testRecordSecurityWithSubFilters() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
queryInput.setFilter(new QQueryFilter()
|
||||
@ -1166,24 +1168,24 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
)));
|
||||
Predicate<QRecord> p = r -> r.getValueInteger("billToPersonId") == null || r.getValueInteger("shipToPersonId") == null || (r.getValueInteger("id") >= 2 && r.getValueInteger("billToPersonId") == 1);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(4)
|
||||
.allMatch(p);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(1)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1))
|
||||
.allMatch(p);
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 3));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 3));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(3)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(3))
|
||||
.allMatch(p);
|
||||
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
}
|
||||
|
||||
@ -1199,15 +1201,16 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
runTestSql("INSERT INTO `order` (id, store_id, bill_to_person_id, ship_to_person_id) VALUES (10, NULL, 6, 5)", null);
|
||||
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
reInitInstanceInContext(qInstance);
|
||||
|
||||
Predicate<QRecord> hasNullStoreId = r -> r.getValueInteger("storeId") == null;
|
||||
|
||||
////////////////////////////////////////////
|
||||
// all-access user should get all 10 rows //
|
||||
////////////////////////////////////////////
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(10)
|
||||
.anyMatch(hasNullStoreId);
|
||||
@ -1215,13 +1218,13 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// no-values user should get 0 rows (given that default null-behavior on this key type is DENY) //
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// user with list of all ids shouldn't see the nulls (given that default null-behavior on this key type is DENY) //
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 2, 3, 4, 5)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 2, 3, 4, 5)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(8)
|
||||
.noneMatch(hasNullStoreId);
|
||||
@ -1231,10 +1234,10 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
qInstance.getTable(TestUtils.TABLE_NAME_ORDER).getRecordSecurityLocks().get(0).setNullValueBehavior(RecordSecurityLock.NullValueBehavior.DENY);
|
||||
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 2, 3, 4, 5)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 2, 3, 4, 5)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(8)
|
||||
.noneMatch(hasNullStoreId);
|
||||
@ -1247,7 +1250,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
/////////////////////////////////////////////
|
||||
// all-access user should still get all 10 //
|
||||
/////////////////////////////////////////////
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(10)
|
||||
.anyMatch(hasNullStoreId);
|
||||
@ -1255,7 +1258,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
/////////////////////////////////////////////////////
|
||||
// no-values user should only get the rows w/ null //
|
||||
/////////////////////////////////////////////////////
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(2)
|
||||
.allMatch(hasNullStoreId);
|
||||
@ -1263,7 +1266,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
////////////////////////////////////////////////////
|
||||
// user with list of all ids should see the nulls //
|
||||
////////////////////////////////////////////////////
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 2, 3, 4, 5)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 2, 3, 4, 5)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(10)
|
||||
.anyMatch(hasNullStoreId);
|
||||
@ -1278,7 +1281,7 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
void testRecordSecurityWithLockFromJoinTable() throws QException
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QueryInput queryInput = new QueryInput(qInstance);
|
||||
QueryInput queryInput = new QueryInput();
|
||||
queryInput.setTableName(TestUtils.TABLE_NAME_ORDER);
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -1291,25 +1294,25 @@ public class RDBMSQueryActionTest extends RDBMSActionTest
|
||||
.withFieldName("store.id"));
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).hasSize(6);
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 1));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(2)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1));
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.TABLE_NAME_STORE, 5));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("id", QCriteriaOperator.BETWEEN, List.of(2, 7))));
|
||||
queryInput.setSession(new QSession());
|
||||
QContext.setQSession(new QSession());
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords()).isEmpty();
|
||||
|
||||
queryInput.setFilter(new QQueryFilter(new QFilterCriteria("storeId", QCriteriaOperator.IN, List.of(1, 2))));
|
||||
queryInput.setSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
QContext.setQSession(new QSession().withSecurityKeyValues(TestUtils.TABLE_NAME_STORE, List.of(1, 3)));
|
||||
assertThat(new QueryAction().execute(queryInput).getRecords())
|
||||
.hasSize(3)
|
||||
.allMatch(r -> r.getValueInteger("storeId").equals(1));
|
||||
|
@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.module.rdbms.actions;
|
||||
|
||||
|
||||
import java.sql.Connection;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.BaseTest;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.TestUtils;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.ConnectionManager;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.jdbc.QueryManager;
|
||||
@ -34,7 +35,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
/*******************************************************************************
|
||||
** Unit test for RDBMSTransaction
|
||||
*******************************************************************************/
|
||||
class RDBMSTransactionTest
|
||||
class RDBMSTransactionTest extends BaseTest
|
||||
{
|
||||
private final String testToken = getClass().getName();
|
||||
|
||||
|
@ -369,7 +369,6 @@ public class RDBMSUpdateActionTest extends RDBMSActionTest
|
||||
private UpdateInput initUpdateRequest()
|
||||
{
|
||||
UpdateInput updateInput = new UpdateInput();
|
||||
updateInput.setInstance(TestUtils.defineInstance());
|
||||
updateInput.setTableName(TestUtils.defineTablePerson().getName());
|
||||
return updateInput;
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collections;
|
||||
import com.kingsrook.qqq.backend.core.instances.QMetaDataVariableInterpreter;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.BaseTest;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.model.metadata.RDBMSBackendMetaData;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@ -36,7 +37,7 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
** Unit test for ConnectionManager
|
||||
*******************************************************************************/
|
||||
@Disabled("This was okay for POC, but shouldn't run in CI")
|
||||
class ConnectionManagerTest
|
||||
class ConnectionManagerTest extends BaseTest
|
||||
{
|
||||
@Test
|
||||
public void test() throws SQLException
|
||||
@ -102,13 +103,13 @@ class ConnectionManagerTest
|
||||
|
||||
private RDBMSBackendMetaData getAuroraBacked()
|
||||
{
|
||||
QMetaDataVariableInterpreter interpreter = new QMetaDataVariableInterpreter();
|
||||
String vendor = interpreter.interpret("${env.RDBMS_VENDOR}");
|
||||
String hostname = interpreter.interpret("${env.RDBMS_HOSTNAME}");
|
||||
Integer port = Integer.valueOf(interpreter.interpret("${env.RDBMS_PORT}"));
|
||||
String databaseName = interpreter.interpret("${env.RDBMS_DATABASE_NAME}");
|
||||
String username = interpreter.interpret("${env.RDBMS_USERNAME}");
|
||||
String password= interpreter.interpret("${env.RDBMS_PASSWORD}");
|
||||
QMetaDataVariableInterpreter interpreter = new QMetaDataVariableInterpreter();
|
||||
String vendor = interpreter.interpret("${env.RDBMS_VENDOR}");
|
||||
String hostname = interpreter.interpret("${env.RDBMS_HOSTNAME}");
|
||||
Integer port = Integer.valueOf(interpreter.interpret("${env.RDBMS_PORT}"));
|
||||
String databaseName = interpreter.interpret("${env.RDBMS_DATABASE_NAME}");
|
||||
String username = interpreter.interpret("${env.RDBMS_USERNAME}");
|
||||
String password = interpreter.interpret("${env.RDBMS_PASSWORD}");
|
||||
|
||||
return new RDBMSBackendMetaData()
|
||||
.withName("aurora-test")
|
||||
|
@ -38,6 +38,7 @@ import java.time.OffsetDateTime;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.BaseTest;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.TestUtils;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@ -52,7 +53,7 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
class QueryManagerTest
|
||||
class QueryManagerTest extends BaseTest
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -26,6 +26,7 @@ import java.io.IOException;
|
||||
import com.kingsrook.qqq.backend.core.adapters.QInstanceAdapter;
|
||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||
import com.kingsrook.qqq.backend.core.utils.JsonUtils;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.BaseTest;
|
||||
import com.kingsrook.qqq.backend.module.rdbms.TestUtils;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
|
||||
@ -35,7 +36,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
/*******************************************************************************
|
||||
** Unit test for RDBMSBackendMetaData
|
||||
*******************************************************************************/
|
||||
class RDBMSBackendMetaDataTest
|
||||
class RDBMSBackendMetaDataTest extends BaseTest
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -24,6 +24,7 @@ package com.kingsrook.qqq.backend.module.rdbms.reporting;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import com.kingsrook.qqq.backend.core.actions.reporting.GenerateReportAction;
|
||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.reporting.ReportFormat;
|
||||
import com.kingsrook.qqq.backend.core.model.actions.reporting.ReportInput;
|
||||
@ -94,6 +95,7 @@ public class GenerateReportActionRDBMSTest extends RDBMSActionTest
|
||||
.withColumn(new QReportField("shipToPersonName").withShowPossibleValueLabel(true).withSourceFieldName("billToPersonId"))
|
||||
);
|
||||
qInstance.addReport(report);
|
||||
reInitInstanceInContext(qInstance);
|
||||
|
||||
String csv = runReport(qInstance);
|
||||
// System.out.println(csv);
|
||||
@ -135,6 +137,7 @@ public class GenerateReportActionRDBMSTest extends RDBMSActionTest
|
||||
.withColumn(new QReportField("order.storeName").withShowPossibleValueLabel(true).withSourceFieldName("order.storeId").withLabel("Order Store Name"))
|
||||
);
|
||||
qInstance.addReport(report);
|
||||
reInitInstanceInContext(qInstance);
|
||||
|
||||
String csv = runReport(qInstance);
|
||||
// System.out.println(csv);
|
||||
@ -168,6 +171,7 @@ public class GenerateReportActionRDBMSTest extends RDBMSActionTest
|
||||
.withColumn(new QReportField("i.storeName").withShowPossibleValueLabel(true).withSourceFieldName("i.storeId").withLabel("Item Store Name"))
|
||||
);
|
||||
qInstance.addReport(report);
|
||||
reInitInstanceInContext(qInstance);
|
||||
|
||||
String csv = runReport(qInstance);
|
||||
System.out.println(csv);
|
||||
@ -195,8 +199,8 @@ public class GenerateReportActionRDBMSTest extends RDBMSActionTest
|
||||
*******************************************************************************/
|
||||
private String runReport(QInstance qInstance) throws QException
|
||||
{
|
||||
ReportInput reportInput = new ReportInput(qInstance);
|
||||
reportInput.setSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
ReportInput reportInput = new ReportInput();
|
||||
QContext.setQSession(new QSession().withSecurityKeyValue(TestUtils.SECURITY_KEY_STORE_ALL_ACCESS, true));
|
||||
reportInput.setReportName(TEST_REPORT);
|
||||
reportInput.setReportFormat(ReportFormat.CSV);
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
|
Reference in New Issue
Block a user