Checkpoint on report and export changes, possible value translating

This commit is contained in:
2022-12-21 11:37:16 -06:00
parent 19d88910b5
commit 799b695e14
18 changed files with 773 additions and 91 deletions

View File

@ -188,7 +188,7 @@ public class QPossibleValueTranslatorTest
);
QTableMetaData personTable = qInstance.getTable(TestUtils.TABLE_NAME_PERSON);
MemoryRecordStore.resetStatistics();
possibleValueTranslator.primePvsCache(personTable, personRecords);
possibleValueTranslator.primePvsCache(personTable, personRecords, null); // todo - test non-null queryJoins
assertEquals(1, MemoryRecordStore.getStatistics().get(MemoryRecordStore.STAT_QUERIES_RAN), "Should only run 1 query");
possibleValueTranslator.translatePossibleValue(shapeField, 1);
possibleValueTranslator.translatePossibleValue(shapeField, 2);

View File

@ -55,6 +55,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleVal
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.queues.SQSQueueProviderMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportDataSource;
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportField;
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportMetaData;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QFieldSection;
import com.kingsrook.qqq.backend.core.model.metadata.tables.QTableMetaData;
@ -1436,6 +1437,69 @@ class QInstanceValidatorTest
dataSource.setStaticDataSupplier(new QCodeReference(ArrayList.class, null));
},
"is not of the expected type");
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testReportViewBasics()
{
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).setViews(null),
"At least 1 view must be defined in report");
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).setViews(new ArrayList<>()),
"At least 1 view must be defined in report");
/////////////////////////////////////////////////////////////////////////
// meh, enricher sets a default name, so, can't easily catch this one. //
/////////////////////////////////////////////////////////////////////////
// assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setName(null),
// "Missing name for a view");
// assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setName(""),
// "Missing name for a view");
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setType(null),
"missing its type");
/////////////////////////////////////////////////////////////////////////
// meh, enricher sets a default name, so, can't easily catch this one. //
/////////////////////////////////////////////////////////////////////////
// assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setDataSourceName(null),
// "missing a dataSourceName");
// assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setDataSourceName(""),
// "missing a dataSourceName");
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setDataSourceName("notADataSource"),
"has an unrecognized dataSourceName");
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testReportViewColumns()
{
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).setColumns(null),
"does not have any columns or a view customizer");
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).getColumns().get(0).setName(null),
"has a column with no name");
assertValidationFailureReasons((qInstance) -> qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).getColumns().get(0).setName(""),
"has a column with no name");
assertValidationFailureReasons((qInstance) ->
{
List<QReportField> columns = qInstance.getReport(TestUtils.REPORT_NAME_SHAPES_PERSON).getViews().get(0).getColumns();
columns.get(0).setName("id");
columns.get(1).setName("id");
},
"has multiple columns named: id");
}

View File

@ -182,6 +182,7 @@ class StringUtilsTest
}
/*******************************************************************************
**
*******************************************************************************/
@ -246,4 +247,41 @@ class StringUtilsTest
assertEquals("", StringUtils.plural(1, "", "es"));
assertEquals("es", StringUtils.plural(2, "", "es"));
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testLcFirst()
{
assertNull(StringUtils.lcFirst(null));
assertEquals("", StringUtils.lcFirst(""));
assertEquals(" ", StringUtils.lcFirst(" "));
assertEquals("a", StringUtils.lcFirst("A"));
assertEquals("1", StringUtils.lcFirst("1"));
assertEquals("a", StringUtils.lcFirst("a"));
assertEquals("aB", StringUtils.lcFirst("AB"));
assertEquals("aBc", StringUtils.lcFirst("ABc"));
}
/*******************************************************************************
**
*******************************************************************************/
@Test
void testUcFirst()
{
assertNull(StringUtils.ucFirst(null));
assertEquals("", StringUtils.ucFirst(""));
assertEquals(" ", StringUtils.ucFirst(" "));
assertEquals("A", StringUtils.ucFirst("A"));
assertEquals("1", StringUtils.ucFirst("1"));
assertEquals("A", StringUtils.ucFirst("a"));
assertEquals("Ab", StringUtils.ucFirst("ab"));
assertEquals("Abc", StringUtils.ucFirst("abc"));
}
}

View File

@ -47,6 +47,7 @@ import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterOrderBy;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QQueryFilter;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryJoin;
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QueryOutput;
import com.kingsrook.qqq.backend.core.model.actions.tables.update.UpdateInput;
import com.kingsrook.qqq.backend.core.model.automation.RecordAutomationInput;
@ -140,6 +141,7 @@ public class TestUtils
public static final String TABLE_NAME_ID_AND_NAME_ONLY = "idAndNameOnly";
public static final String TABLE_NAME_BASEPULL = "basepullTest";
public static final String REPORT_NAME_SHAPES_PERSON = "shapesPersonReport";
public static final String REPORT_NAME_PERSON_JOIN_SHAPE = "simplePersonReport";
public static final String POSSIBLE_VALUE_SOURCE_STATE = "state"; // enum-type
public static final String POSSIBLE_VALUE_SOURCE_SHAPE = "shape"; // table-type
@ -192,6 +194,7 @@ public class TestUtils
qInstance.addReport(defineShapesPersonsReport());
qInstance.addProcess(defineShapesPersonReportProcess());
qInstance.addReport(definePersonJoinShapeReport());
qInstance.addAutomationProvider(definePollingAutomationProvider());
@ -1108,4 +1111,26 @@ public class TestUtils
.getProcessMetaData();
}
/*******************************************************************************
**
*******************************************************************************/
private static QReportMetaData definePersonJoinShapeReport()
{
return new QReportMetaData()
.withName(REPORT_NAME_PERSON_JOIN_SHAPE)
.withDataSource(
new QReportDataSource()
.withSourceTable(TestUtils.TABLE_NAME_PERSON_MEMORY)
)
.withView(new QReportView()
.withType(ReportType.TABLE)
.withColumns(List.of(
new QReportField("id"),
new QReportField("firstName"),
new QReportField("lastName")
))
);
}
}