CE-781 - eliminate instance validation errors when using FilesystemImporterStep FIELD_IMPORT_SECURITY_VALUE_SUPPLIERs

This commit is contained in:
2024-01-23 19:12:41 -06:00
parent 7e0b7ddbf9
commit 0dd26b8f31
4 changed files with 72 additions and 5 deletions

View File

@ -64,7 +64,15 @@ public class FilesystemImporterProcessMetaDataBuilder extends AbstractProcessMet
.withField(new QFieldMetaData(FilesystemImporterStep.FIELD_ARCHIVE_PATH, QFieldType.STRING))
.withField(new QFieldMetaData(FilesystemImporterStep.FIELD_IMPORT_SECURITY_FIELD_NAME, QFieldType.STRING))
.withField(new QFieldMetaData(FilesystemImporterStep.FIELD_IMPORT_SECURITY_FIELD_VALUE, QFieldType.STRING))
.withField(new QFieldMetaData(FilesystemImporterStep.FIELD_IMPORT_SECURITY_VALUE_SUPPLIER, QFieldType.STRING)) // actually, QCodeReference, of type Function<QRecord, Serializable>
//////////////////////////////////////////////////////////////////////////////////////
// define a QCodeReference - expected to be of type Function<QRecord, Serializable> //
// make sure the QInstanceValidator knows that the QCodeReference should be a //
// Function (not a BackendStep, which is the default for process fields) //
//////////////////////////////////////////////////////////////////////////////////////
.withField(new QFieldMetaData(FilesystemImporterStep.FIELD_IMPORT_SECURITY_VALUE_SUPPLIER, QFieldType.STRING))
.withField(new QFieldMetaData(FilesystemImporterStep.FIELD_IMPORT_SECURITY_VALUE_SUPPLIER + "_expectedType", QFieldType.STRING)
.withDefaultValue(Function.class.getName()))
)));
}

View File

@ -31,6 +31,7 @@ import com.kingsrook.qqq.backend.core.actions.tables.CountAction;
import com.kingsrook.qqq.backend.core.actions.tables.GetAction;
import com.kingsrook.qqq.backend.core.context.QContext;
import com.kingsrook.qqq.backend.core.exceptions.QException;
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
import com.kingsrook.qqq.backend.core.model.actions.processes.RunProcessInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.count.CountInput;
import com.kingsrook.qqq.backend.core.model.actions.tables.get.GetInput;
@ -279,6 +280,12 @@ class FilesystemImporterStepTest extends FilesystemActionTest
process.getInputFields().stream().filter(f -> f.getName().equals(FilesystemImporterStep.FIELD_IMPORT_SECURITY_FIELD_NAME)).findFirst().get().setDefaultValue("customerId");
process.getInputFields().stream().filter(f -> f.getName().equals(FilesystemImporterStep.FIELD_IMPORT_SECURITY_VALUE_SUPPLIER)).findFirst().get().setDefaultValue(new QCodeReference(SecuritySupplier.class));
//////////////////////////////////////////////////////////////////////////////////////////////////////
// re-validate our instance now that we have that code-reference in place for the security supplier //
//////////////////////////////////////////////////////////////////////////////////////////////////////
QContext.getQInstance().setHasBeenValidated(null);
new QInstanceValidator().validate(QContext.getQInstance());
RunProcessInput runProcessInput = new RunProcessInput();
runProcessInput.setProcessName(TestUtils.LOCAL_PERSON_CSV_FILE_IMPORTER_PROCESS_NAME);
new RunProcessAction().execute(runProcessInput);