mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-19 05:30:43 +00:00
Add LoadViaInsertOrUpdateStep; make PVS field labels not have Id suffix; add populateFromQRecord
This commit is contained in:
@ -245,32 +245,32 @@ public class GenerateReportActionTest
|
||||
Map<String, String> row = iterator.next();
|
||||
assertEquals(6, list.size());
|
||||
|
||||
assertThat(row.get("Home State Id")).isEqualTo("IL");
|
||||
assertThat(row.get("Home State")).isEqualTo("IL");
|
||||
assertThat(row.get("Last Name")).isEqualTo("Jonson");
|
||||
assertThat(row.get("Quantity")).isNull();
|
||||
|
||||
row = iterator.next();
|
||||
assertThat(row.get("Home State Id")).isEqualTo("IL");
|
||||
assertThat(row.get("Home State")).isEqualTo("IL");
|
||||
assertThat(row.get("Last Name")).isEqualTo("Jones");
|
||||
assertThat(row.get("Quantity")).isEqualTo("3");
|
||||
|
||||
row = iterator.next();
|
||||
assertThat(row.get("Home State Id")).isEqualTo("IL");
|
||||
assertThat(row.get("Home State")).isEqualTo("IL");
|
||||
assertThat(row.get("Last Name")).isEqualTo("Kelly");
|
||||
assertThat(row.get("Quantity")).isEqualTo("4");
|
||||
|
||||
row = iterator.next();
|
||||
assertThat(row.get("Home State Id")).isEqualTo("IL");
|
||||
assertThat(row.get("Home State")).isEqualTo("IL");
|
||||
assertThat(row.get("Last Name")).isEqualTo("Keller");
|
||||
assertThat(row.get("Quantity")).isEqualTo("5");
|
||||
|
||||
row = iterator.next();
|
||||
assertThat(row.get("Home State Id")).isEqualTo("IL");
|
||||
assertThat(row.get("Home State")).isEqualTo("IL");
|
||||
assertThat(row.get("Last Name")).isEqualTo("Kelkhoff");
|
||||
assertThat(row.get("Quantity")).isEqualTo("6");
|
||||
|
||||
row = iterator.next();
|
||||
assertThat(row.get("Home State Id")).isEqualTo("MO");
|
||||
assertThat(row.get("Home State")).isEqualTo("MO");
|
||||
assertThat(row.get("Last Name")).isEqualTo("Kelkhoff");
|
||||
assertThat(row.get("Quantity")).isEqualTo("7");
|
||||
}
|
||||
@ -299,12 +299,12 @@ public class GenerateReportActionTest
|
||||
Iterator<Map<String, String>> iterator = list.iterator();
|
||||
Map<String, String> row = iterator.next();
|
||||
assertEquals(2, list.size());
|
||||
assertThat(row.get("Home State Id")).isEqualTo("MO");
|
||||
assertThat(row.get("Home State")).isEqualTo("MO");
|
||||
assertThat(row.get("Last Name")).isNull();
|
||||
assertThat(row.get("Quantity")).isEqualTo("7");
|
||||
|
||||
row = iterator.next();
|
||||
assertThat(row.get("Home State Id")).isEqualTo("IL");
|
||||
assertThat(row.get("Home State")).isEqualTo("IL");
|
||||
assertThat(row.get("Last Name")).isNull();
|
||||
assertThat(row.get("Quantity")).isEqualTo("18");
|
||||
}
|
||||
|
@ -108,6 +108,23 @@ class QInstanceEnricherTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Test that a field missing a label gets the default label applied (name w/ UC-first)
|
||||
** w/ Id stripped from the end, because it's a PVS
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
public void test_nullFieldLabelComesFromNameWithoutIdForPossibleValues()
|
||||
{
|
||||
QInstance qInstance = TestUtils.defineInstance();
|
||||
QFieldMetaData homeStateIdField = qInstance.getTable("person").getField("homeStateId");
|
||||
assertNull(homeStateIdField.getLabel());
|
||||
new QInstanceEnricher(qInstance).enrich();
|
||||
assertEquals("Home State", homeStateIdField.getLabel());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
** Test that a fieldSection missing a label gets the default label applied (name w/ UC-first).
|
||||
**
|
||||
|
@ -111,6 +111,45 @@ public class StreamedETLWithFrontendProcessTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Test
|
||||
void testLoadViaInsertOrUpdate() throws QException
|
||||
{
|
||||
QInstance instance = TestUtils.defineInstance();
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// define the process - an ELT from Shapes to Shapes - inserting 1, updating 2 //
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
QProcessMetaData process = StreamedETLWithFrontendProcess.defineProcessMetaData(
|
||||
TestUtils.TABLE_NAME_SHAPE,
|
||||
TestUtils.TABLE_NAME_SHAPE,
|
||||
ExtractViaQueryStep.class,
|
||||
TestTransformShapeToMaybeNewShape.class,
|
||||
LoadViaInsertOrUpdateStep.class);
|
||||
process.setName("test");
|
||||
process.setTableName(TestUtils.TABLE_NAME_SHAPE);
|
||||
instance.addProcess(process);
|
||||
|
||||
TestUtils.insertDefaultShapes(instance);
|
||||
|
||||
/////////////////////
|
||||
// run the process //
|
||||
/////////////////////
|
||||
runProcess(instance, process);
|
||||
|
||||
List<QRecord> postList = TestUtils.queryTable(instance, TestUtils.TABLE_NAME_SHAPE);
|
||||
assertEquals(4, postList.size());
|
||||
assertThat(postList)
|
||||
.as("Should have inserted a new Square").anyMatch(qr -> qr.getValue("name").equals("a new Square"))
|
||||
.as("Should have left old Square alone").anyMatch(qr -> qr.getValue("name").equals("Square"))
|
||||
.as("Should have updated Triangle").anyMatch(qr -> qr.getValue("name").equals("an updated Triangle"))
|
||||
.as("Should have updated Circle").anyMatch(qr -> qr.getValue("name").equals("an updated Circle"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -368,6 +407,49 @@ public class StreamedETLWithFrontendProcessTest
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
public static class TestTransformShapeToMaybeNewShape extends AbstractTransformStep
|
||||
{
|
||||
|
||||
/*******************************************************************************
|
||||
** Execute the backend step - using the request as input, and the result as output.
|
||||
**
|
||||
*******************************************************************************/
|
||||
@Override
|
||||
public void run(RunBackendStepInput runBackendStepInput, RunBackendStepOutput runBackendStepOutput) throws QException
|
||||
{
|
||||
for(QRecord qRecord : runBackendStepInput.getRecords())
|
||||
{
|
||||
String name = qRecord.getValueString("name");
|
||||
if(name.equals("Square"))
|
||||
{
|
||||
QRecord toInsertRecord = new QRecord();
|
||||
toInsertRecord.setValue("name", "a new Square");
|
||||
runBackendStepOutput.getRecords().add(toInsertRecord);
|
||||
}
|
||||
else
|
||||
{
|
||||
QRecord toUpdateRecord = new QRecord();
|
||||
toUpdateRecord.setValue("id", qRecord.getValueInteger("id"));
|
||||
toUpdateRecord.setValue("name", "an updated " + name);
|
||||
runBackendStepOutput.getRecords().add(toUpdateRecord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ArrayList<ProcessSummaryLineInterface> getProcessSummary(RunBackendStepOutput runBackendStepOutput, boolean isForResultScreen)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
*******************************************************************************/
|
||||
|
Reference in New Issue
Block a user