mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Improving query test coverage
This commit is contained in:
@ -22,6 +22,8 @@
|
|||||||
package com.kingsrook.qqq.backend.core.actions.tables;
|
package com.kingsrook.qqq.backend.core.actions.tables;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import com.kingsrook.qqq.backend.core.actions.reporting.RecordPipe;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
|
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
|
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
|
||||||
@ -76,4 +78,50 @@ class QueryActionTest
|
|||||||
assertThat(record.getDisplayValues()).isNotEmpty();
|
assertThat(record.getDisplayValues()).isNotEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Test running with a recordPipe - using the shape table, which uses the memory
|
||||||
|
** backend, which is known to do an addAll to the query output.
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
public void testRecordPipeShapeTable() throws QException
|
||||||
|
{
|
||||||
|
TestUtils.insertDefaultShapes(TestUtils.defineInstance());
|
||||||
|
|
||||||
|
RecordPipe pipe = new RecordPipe();
|
||||||
|
QueryInput queryInput = new QueryInput(TestUtils.defineInstance());
|
||||||
|
queryInput.setSession(TestUtils.getMockSession());
|
||||||
|
queryInput.setTableName(TestUtils.TABLE_NAME_SHAPE);
|
||||||
|
queryInput.setRecordPipe(pipe);
|
||||||
|
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||||
|
assertNotNull(queryOutput);
|
||||||
|
|
||||||
|
List<QRecord> records = pipe.consumeAvailableRecords();
|
||||||
|
assertThat(records).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Test running with a recordPipe - using the person table, which uses the mock
|
||||||
|
** backend, which is known to do a single-add (not addAll) to the query output.
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
public void testRecordPipePersonTable() throws QException
|
||||||
|
{
|
||||||
|
RecordPipe pipe = new RecordPipe();
|
||||||
|
QueryInput queryInput = new QueryInput(TestUtils.defineInstance());
|
||||||
|
queryInput.setSession(TestUtils.getMockSession());
|
||||||
|
queryInput.setTableName(TestUtils.TABLE_NAME_PERSON);
|
||||||
|
queryInput.setRecordPipe(pipe);
|
||||||
|
QueryOutput queryOutput = new QueryAction().execute(queryInput);
|
||||||
|
assertNotNull(queryOutput);
|
||||||
|
|
||||||
|
List<QRecord> records = pipe.consumeAvailableRecords();
|
||||||
|
assertThat(records).isNotEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,9 +25,7 @@ package com.kingsrook.qqq.backend.core.actions.values;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
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.data.QRecord;
|
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||||
@ -135,16 +133,7 @@ public class QPossibleValueTranslatorTest
|
|||||||
QFieldMetaData shapeField = qInstance.getTable(TestUtils.TABLE_NAME_PERSON).getField("favoriteShapeId");
|
QFieldMetaData shapeField = qInstance.getTable(TestUtils.TABLE_NAME_PERSON).getField("favoriteShapeId");
|
||||||
QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(shapeField.getPossibleValueSourceName());
|
QPossibleValueSource possibleValueSource = qInstance.getPossibleValueSource(shapeField.getPossibleValueSourceName());
|
||||||
|
|
||||||
List<QRecord> shapeRecords = List.of(
|
TestUtils.insertDefaultShapes(qInstance);
|
||||||
new QRecord().withTableName(shapeTable.getName()).withValue("id", 1).withValue("name", "Triangle"),
|
|
||||||
new QRecord().withTableName(shapeTable.getName()).withValue("id", 2).withValue("name", "Square"),
|
|
||||||
new QRecord().withTableName(shapeTable.getName()).withValue("id", 3).withValue("name", "Circle"));
|
|
||||||
|
|
||||||
InsertInput insertInput = new InsertInput(qInstance);
|
|
||||||
insertInput.setSession(new QSession());
|
|
||||||
insertInput.setTableName(shapeTable.getName());
|
|
||||||
insertInput.setRecords(shapeRecords);
|
|
||||||
new InsertAction().execute(insertInput);
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
// assert the default formatting for a not-found value is a null string //
|
// assert the default formatting for a not-found value is a null string //
|
||||||
@ -235,18 +224,7 @@ public class QPossibleValueTranslatorTest
|
|||||||
.withPossibleValueSourceName("shapeV2")
|
.withPossibleValueSourceName("shapeV2")
|
||||||
);
|
);
|
||||||
|
|
||||||
///////////////////////////////
|
TestUtils.insertDefaultShapes(qInstance);
|
||||||
// insert the list of shapes //
|
|
||||||
///////////////////////////////
|
|
||||||
List<QRecord> shapeRecords = List.of(
|
|
||||||
new QRecord().withTableName(shapeTable.getName()).withValue("id", 1).withValue("name", "Triangle"),
|
|
||||||
new QRecord().withTableName(shapeTable.getName()).withValue("id", 2).withValue("name", "Square"),
|
|
||||||
new QRecord().withTableName(shapeTable.getName()).withValue("id", 3).withValue("name", "Circle"));
|
|
||||||
InsertInput insertInput = new InsertInput(qInstance);
|
|
||||||
insertInput.setSession(new QSession());
|
|
||||||
insertInput.setTableName(shapeTable.getName());
|
|
||||||
insertInput.setRecords(shapeRecords);
|
|
||||||
new InsertAction().execute(insertInput);
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////
|
||||||
// define a list of persons pointing at those shapes //
|
// define a list of persons pointing at those shapes //
|
||||||
|
@ -26,9 +26,11 @@ import java.io.Serializable;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.kingsrook.qqq.backend.core.actions.processes.person.addtopeoplesage.AddAge;
|
import com.kingsrook.qqq.backend.core.actions.processes.person.addtopeoplesage.AddAge;
|
||||||
import com.kingsrook.qqq.backend.core.actions.processes.person.addtopeoplesage.GetAgeStatistics;
|
import com.kingsrook.qqq.backend.core.actions.processes.person.addtopeoplesage.GetAgeStatistics;
|
||||||
|
import com.kingsrook.qqq.backend.core.actions.tables.InsertAction;
|
||||||
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
import com.kingsrook.qqq.backend.core.actions.tables.QueryAction;
|
||||||
import com.kingsrook.qqq.backend.core.actions.values.QCustomPossibleValueProvider;
|
import com.kingsrook.qqq.backend.core.actions.values.QCustomPossibleValueProvider;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
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.QueryInput;
|
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
|
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
|
||||||
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
import com.kingsrook.qqq.backend.core.model.data.QRecord;
|
||||||
@ -447,6 +449,25 @@ public class TestUtils
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static void insertDefaultShapes(QInstance qInstance) throws QException
|
||||||
|
{
|
||||||
|
List<QRecord> shapeRecords = List.of(
|
||||||
|
new QRecord().withTableName(TABLE_NAME_SHAPE).withValue("id", 1).withValue("name", "Triangle"),
|
||||||
|
new QRecord().withTableName(TABLE_NAME_SHAPE).withValue("id", 2).withValue("name", "Square"),
|
||||||
|
new QRecord().withTableName(TABLE_NAME_SHAPE).withValue("id", 3).withValue("name", "Circle"));
|
||||||
|
|
||||||
|
InsertInput insertInput = new InsertInput(qInstance);
|
||||||
|
insertInput.setSession(new QSession());
|
||||||
|
insertInput.setTableName(TABLE_NAME_SHAPE);
|
||||||
|
insertInput.setRecords(shapeRecords);
|
||||||
|
new InsertAction().execute(insertInput);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
Reference in New Issue
Block a user