mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 05:01:07 +00:00
Merge pull request #76 from Kingsrook/feature/q-instance-validator-plugins
Add plugin support in QInstanceValidator, with first implementation b…
This commit is contained in:
@ -24,8 +24,10 @@ package com.kingsrook.qqq.backend.core.instances;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Modifier;
|
import java.lang.reflect.Modifier;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -43,6 +45,7 @@ import com.kingsrook.qqq.backend.core.actions.processes.BackendStep;
|
|||||||
import com.kingsrook.qqq.backend.core.actions.scripts.TestScriptActionInterface;
|
import com.kingsrook.qqq.backend.core.actions.scripts.TestScriptActionInterface;
|
||||||
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.QInstanceValidationException;
|
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.validation.plugins.QInstanceValidatorPluginInterface;
|
||||||
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
import com.kingsrook.qqq.backend.core.logging.QLogger;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.tables.query.QFilterCriteria;
|
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.QFilterOrderBy;
|
||||||
@ -52,9 +55,11 @@ import com.kingsrook.qqq.backend.core.model.metadata.QBackendMetaData;
|
|||||||
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.QSupplementalInstanceMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.QSupplementalInstanceMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.authentication.QAuthenticationMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.authentication.QAuthenticationMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.automation.QAutomationProviderMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeType;
|
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeType;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.ParentWidgetMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.ParentWidgetMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.dashboard.QWidgetMetaDataInterface;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.AdornmentType;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.FieldAdornment;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||||
@ -64,16 +69,21 @@ import com.kingsrook.qqq.backend.core.model.metadata.joins.QJoinMetaData;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppChildMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppChildMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppSection;
|
import com.kingsrook.qqq.backend.core.model.metadata.layout.QAppSection;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.possiblevalues.QPossibleValueSource;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QBackendStepMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QStepMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QStepMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.processes.QSupplementalProcessMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QSupplementalProcessMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.queues.QQueueMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.queues.QQueueProviderMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.queues.SQSQueueProviderMetaData;
|
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.QReportDataSource;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportField;
|
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.reporting.QReportView;
|
import com.kingsrook.qqq.backend.core.model.metadata.reporting.QReportView;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.scheduleing.QScheduleMetaData;
|
import com.kingsrook.qqq.backend.core.model.metadata.scheduleing.QScheduleMetaData;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.security.FieldSecurityLock;
|
import com.kingsrook.qqq.backend.core.model.metadata.security.FieldSecurityLock;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.security.QSecurityKeyType;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.security.RecordSecurityLock;
|
import com.kingsrook.qqq.backend.core.model.metadata.security.RecordSecurityLock;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.AssociatedScript;
|
||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.Association;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.Association;
|
||||||
@ -90,6 +100,7 @@ import com.kingsrook.qqq.backend.core.model.metadata.tables.cache.CacheOf;
|
|||||||
import com.kingsrook.qqq.backend.core.model.metadata.tables.cache.CacheUseCase;
|
import com.kingsrook.qqq.backend.core.model.metadata.tables.cache.CacheUseCase;
|
||||||
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleCustomizerInterface;
|
import com.kingsrook.qqq.backend.core.modules.authentication.QAuthenticationModuleCustomizerInterface;
|
||||||
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
import com.kingsrook.qqq.backend.core.utils.CollectionUtils;
|
||||||
|
import com.kingsrook.qqq.backend.core.utils.ListingHash;
|
||||||
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
import com.kingsrook.qqq.backend.core.utils.StringUtils;
|
||||||
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
import com.kingsrook.qqq.backend.core.utils.ValueUtils;
|
||||||
import com.kingsrook.qqq.backend.core.utils.lambdas.UnsafeLambda;
|
import com.kingsrook.qqq.backend.core.utils.lambdas.UnsafeLambda;
|
||||||
@ -111,6 +122,8 @@ public class QInstanceValidator
|
|||||||
|
|
||||||
private boolean printWarnings = false;
|
private boolean printWarnings = false;
|
||||||
|
|
||||||
|
private static ListingHash<Class<?>, QInstanceValidatorPluginInterface<?>> validatorPlugins = new ListingHash<>();
|
||||||
|
|
||||||
private List<String> errors = new ArrayList<>();
|
private List<String> errors = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
@ -171,6 +184,8 @@ public class QInstanceValidator
|
|||||||
validateSupplementalMetaData(qInstance);
|
validateSupplementalMetaData(qInstance);
|
||||||
|
|
||||||
validateUniqueTopLevelNames(qInstance);
|
validateUniqueTopLevelNames(qInstance);
|
||||||
|
|
||||||
|
runPlugins(QInstance.class, qInstance, qInstance);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
@ -189,6 +204,57 @@ public class QInstanceValidator
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static void addValidatorPlugin(QInstanceValidatorPluginInterface<?> plugin)
|
||||||
|
{
|
||||||
|
Optional<Method> validateMethod = Arrays.stream(plugin.getClass().getDeclaredMethods())
|
||||||
|
.filter(m -> m.getName().equals("validate")
|
||||||
|
&& m.getParameterCount() == 3
|
||||||
|
&& !m.getParameterTypes()[0].equals(Object.class)
|
||||||
|
&& m.getParameterTypes()[1].equals(QInstance.class)
|
||||||
|
&& m.getParameterTypes()[2].equals(QInstanceValidator.class)
|
||||||
|
).findFirst();
|
||||||
|
|
||||||
|
if(validateMethod.isPresent())
|
||||||
|
{
|
||||||
|
Class<?> parameterType = validateMethod.get().getParameterTypes()[0];
|
||||||
|
validatorPlugins.add(parameterType, plugin);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG.warn("Could not find validate method on validator plugin [" + plugin.getClass().getName() + "] (to infer type being validated) - this plugin will not be used.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static void removeAllValidatorPlugins()
|
||||||
|
{
|
||||||
|
validatorPlugins.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
private <T> void runPlugins(Class<T> c, T t, QInstance qInstance)
|
||||||
|
{
|
||||||
|
for(QInstanceValidatorPluginInterface<?> plugin : CollectionUtils.nonNullList(validatorPlugins.get(c)))
|
||||||
|
{
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
QInstanceValidatorPluginInterface<T> processPlugin = (QInstanceValidatorPluginInterface<T>) plugin;
|
||||||
|
processPlugin.validate(t, qInstance, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
@ -197,6 +263,8 @@ public class QInstanceValidator
|
|||||||
for(QSupplementalInstanceMetaData supplementalInstanceMetaData : CollectionUtils.nonNullMap(qInstance.getSupplementalMetaData()).values())
|
for(QSupplementalInstanceMetaData supplementalInstanceMetaData : CollectionUtils.nonNullMap(qInstance.getSupplementalMetaData()).values())
|
||||||
{
|
{
|
||||||
supplementalInstanceMetaData.validate(qInstance, this);
|
supplementalInstanceMetaData.validate(qInstance, this);
|
||||||
|
|
||||||
|
runPlugins(QSupplementalInstanceMetaData.class, supplementalInstanceMetaData, qInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,6 +302,8 @@ public class QInstanceValidator
|
|||||||
{
|
{
|
||||||
assertCondition(qInstance.getPossibleValueSource(securityKeyType.getPossibleValueSourceName()) != null, "Unrecognized possibleValueSourceName in securityKeyType: " + name);
|
assertCondition(qInstance.getPossibleValueSource(securityKeyType.getPossibleValueSourceName()) != null, "Unrecognized possibleValueSourceName in securityKeyType: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QSecurityKeyType.class, securityKeyType, qInstance);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -280,6 +350,8 @@ public class QInstanceValidator
|
|||||||
assertNoException(() -> qInstance.getTable(join.getRightTable()).getField(orderBy.getFieldName()), "Field name " + orderBy.getFieldName() + " in orderBy for join " + joinName + " is not a defined field in the right-table " + join.getRightTable());
|
assertNoException(() -> qInstance.getTable(join.getRightTable()).getField(orderBy.getFieldName()), "Field name " + orderBy.getFieldName() + " in orderBy for join " + joinName + " is not a defined field in the right-table " + join.getRightTable());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QJoinMetaData.class, join, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -343,6 +415,8 @@ public class QInstanceValidator
|
|||||||
assertCondition(StringUtils.hasContent(sqsQueueProvider.getBaseURL()), "Missing baseURL for SQSQueueProvider: " + name);
|
assertCondition(StringUtils.hasContent(sqsQueueProvider.getBaseURL()), "Missing baseURL for SQSQueueProvider: " + name);
|
||||||
assertCondition(StringUtils.hasContent(sqsQueueProvider.getRegion()), "Missing region for SQSQueueProvider: " + name);
|
assertCondition(StringUtils.hasContent(sqsQueueProvider.getRegion()), "Missing region for SQSQueueProvider: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QQueueProviderMetaData.class, queueProvider, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -357,6 +431,8 @@ public class QInstanceValidator
|
|||||||
{
|
{
|
||||||
assertCondition(qInstance.getProcesses() != null && qInstance.getProcess(queue.getProcessName()) != null, "Unrecognized processName for queue: " + name);
|
assertCondition(qInstance.getProcesses() != null && qInstance.getProcess(queue.getProcessName()) != null, "Unrecognized processName for queue: " + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QQueueMetaData.class, queue, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -375,6 +451,8 @@ public class QInstanceValidator
|
|||||||
assertCondition(Objects.equals(backendName, backend.getName()), "Inconsistent naming for backend: " + backendName + "/" + backend.getName() + ".");
|
assertCondition(Objects.equals(backendName, backend.getName()), "Inconsistent naming for backend: " + backendName + "/" + backend.getName() + ".");
|
||||||
|
|
||||||
backend.performValidation(this);
|
backend.performValidation(this);
|
||||||
|
|
||||||
|
runPlugins(QBackendMetaData.class, backend, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,6 +470,8 @@ public class QInstanceValidator
|
|||||||
{
|
{
|
||||||
assertCondition(Objects.equals(name, automationProvider.getName()), "Inconsistent naming for automationProvider: " + name + "/" + automationProvider.getName() + ".");
|
assertCondition(Objects.equals(name, automationProvider.getName()), "Inconsistent naming for automationProvider: " + name + "/" + automationProvider.getName() + ".");
|
||||||
assertCondition(automationProvider.getType() != null, "Missing type for automationProvider: " + name);
|
assertCondition(automationProvider.getType() != null, "Missing type for automationProvider: " + name);
|
||||||
|
|
||||||
|
runPlugins(QAutomationProviderMetaData.class, automationProvider, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,6 +490,8 @@ public class QInstanceValidator
|
|||||||
{
|
{
|
||||||
validateSimpleCodeReference("Instance Authentication meta data customizer ", authentication.getCustomizer(), QAuthenticationModuleCustomizerInterface.class);
|
validateSimpleCodeReference("Instance Authentication meta data customizer ", authentication.getCustomizer(), QAuthenticationModuleCustomizerInterface.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QAuthenticationMetaData.class, authentication, qInstance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,6 +614,8 @@ public class QInstanceValidator
|
|||||||
{
|
{
|
||||||
supplementalTableMetaData.validate(qInstance, table, this);
|
supplementalTableMetaData.validate(qInstance, table, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QTableMetaData.class, table, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1330,6 +1414,7 @@ public class QInstanceValidator
|
|||||||
supplementalProcessMetaData.validate(qInstance, process, this);
|
supplementalProcessMetaData.validate(qInstance, process, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QProcessMetaData.class, process, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1436,6 +1521,8 @@ public class QInstanceValidator
|
|||||||
// view.getTitleFormat(); view.getTitleFields(); // validate these match?
|
// view.getTitleFormat(); view.getTitleFields(); // validate these match?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QReportMetaData.class, report, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1556,9 +1643,9 @@ public class QInstanceValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
// validate field sections in the table //
|
// validate field sections in the app //
|
||||||
//////////////////////////////////////////
|
////////////////////////////////////////
|
||||||
Set<String> childNamesInSections = new HashSet<>();
|
Set<String> childNamesInSections = new HashSet<>();
|
||||||
if(app.getSections() != null)
|
if(app.getSections() != null)
|
||||||
{
|
{
|
||||||
@ -1586,6 +1673,8 @@ public class QInstanceValidator
|
|||||||
{
|
{
|
||||||
assertCondition(qInstance.getWidget(widgetName) != null, "App " + appName + " widget " + widgetName + " is not a recognized widget.");
|
assertCondition(qInstance.getWidget(widgetName) != null, "App " + appName + " widget " + widgetName + " is not a recognized widget.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QAppMetaData.class, app, qInstance);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1618,6 +1707,8 @@ public class QInstanceValidator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QWidgetMetaDataInterface.class, widget, qInstance);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -1703,6 +1794,8 @@ public class QInstanceValidator
|
|||||||
}
|
}
|
||||||
default -> errors.add("Unexpected possibleValueSource type: " + possibleValueSource.getType());
|
default -> errors.add("Unexpected possibleValueSource type: " + possibleValueSource.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPlugins(QPossibleValueSource.class, possibleValueSource, qInstance);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.backend.core.instances.validation.plugins;
|
||||||
|
|
||||||
|
|
||||||
|
import com.kingsrook.qqq.backend.core.actions.customizers.QCodeLoader;
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.code.QCodeReference;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.fields.QFieldMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.basepull.BasepullExtractStepInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** instance validator plugin, to ensure that a process which is a basepull uses
|
||||||
|
** an extract step marked for basepulls.
|
||||||
|
*******************************************************************************/
|
||||||
|
public class BasepullExtractStepValidator implements QInstanceValidatorPluginInterface<QProcessMetaData>
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public void validate(QProcessMetaData process, QInstance qInstance, QInstanceValidator qInstanceValidator)
|
||||||
|
{
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
// if there's no basepull config on the process, don't do any validation //
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
if(process.getBasepullConfiguration() == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// try to find an input field in the process, w/ a defaultValue that's a QCodeReference //
|
||||||
|
// and is an instance of BasepullExtractStepInterface //
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
boolean foundBasepullExtractStep = false;
|
||||||
|
for(QFieldMetaData field : process.getInputFields())
|
||||||
|
{
|
||||||
|
if(field.getDefaultValue() != null && field.getDefaultValue() instanceof QCodeReference codeReference)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
BasepullExtractStepInterface extractStep = QCodeLoader.getAdHoc(BasepullExtractStepInterface.class, codeReference);
|
||||||
|
if(extractStep != null)
|
||||||
|
{
|
||||||
|
foundBasepullExtractStep = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
// ok, just means we haven't found our extract step //
|
||||||
|
//////////////////////////////////////////////////////
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
// validate we could find a BasepullExtractStepInterface //
|
||||||
|
///////////////////////////////////////////////////////////
|
||||||
|
qInstanceValidator.assertCondition(foundBasepullExtractStep, "Process [" + process.getName() + "] has a basepullConfiguration, but does not have a field with a default value that is a BasepullExtractStepInterface CodeReference");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.backend.core.instances.validation.plugins;
|
||||||
|
|
||||||
|
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Interface for additional / optional q instance validators. Some will be
|
||||||
|
** provided by QQQ - others can be defined by applications.
|
||||||
|
*******************************************************************************/
|
||||||
|
public interface QInstanceValidatorPluginInterface<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
void validate(T object, QInstance qInstance, QInstanceValidator qInstanceValidator);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.backend.core.processes.implementations.basepull;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** marker - used to indicate that a step is meant to be used for basepull extracts.
|
||||||
|
*******************************************************************************/
|
||||||
|
public interface BasepullExtractStepInterface
|
||||||
|
{
|
||||||
|
}
|
@ -38,7 +38,7 @@ import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwith
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Version of ExtractViaQueryStep that knows how to set up a basepull query.
|
** Version of ExtractViaQueryStep that knows how to set up a basepull query.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public class ExtractViaBasepullQueryStep extends ExtractViaQueryStep
|
public class ExtractViaBasepullQueryStep extends ExtractViaQueryStep implements BasepullExtractStepInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* QQQ - Low-code Application Framework for Engineers.
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
* Copyright (C) 2021-2022. Kingsrook, LLC
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
* contact@kingsrook.com
|
* contact@kingsrook.com
|
||||||
* https://github.com/Kingsrook/
|
* https://github.com/Kingsrook/
|
||||||
@ -38,6 +38,7 @@ import com.kingsrook.qqq.backend.core.actions.processes.BackendStep;
|
|||||||
import com.kingsrook.qqq.backend.core.context.QContext;
|
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
import com.kingsrook.qqq.backend.core.exceptions.QException;
|
||||||
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
|
import com.kingsrook.qqq.backend.core.exceptions.QInstanceValidationException;
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.validation.plugins.AlwaysFailsProcessValidatorPlugin;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.processes.ProcessSummaryLineInterface;
|
import com.kingsrook.qqq.backend.core.model.actions.processes.ProcessSummaryLineInterface;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepInput;
|
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepInput;
|
||||||
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepOutput;
|
import com.kingsrook.qqq.backend.core.model.actions.processes.RunBackendStepOutput;
|
||||||
@ -97,7 +98,7 @@ import static org.junit.jupiter.api.Assertions.fail;
|
|||||||
** Unit test for QInstanceValidator.
|
** Unit test for QInstanceValidator.
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
class QInstanceValidatorTest extends BaseTest
|
public class QInstanceValidatorTest extends BaseTest
|
||||||
{
|
{
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -367,6 +368,35 @@ class QInstanceValidatorTest extends BaseTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void test_validatorPlugins()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
QInstanceValidator.addValidatorPlugin(new AlwaysFailsProcessValidatorPlugin());
|
||||||
|
|
||||||
|
////////////////////////////////////////
|
||||||
|
// make sure our always failer fails. //
|
||||||
|
////////////////////////////////////////
|
||||||
|
assertValidationFailureReasonsAllowingExtraReasons((qInstance) -> {
|
||||||
|
}, "always fail");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
QInstanceValidator.removeAllValidatorPlugins();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
// make sure if remove all plugins, we don't fail //
|
||||||
|
////////////////////////////////////////////////////
|
||||||
|
assertValidationSuccess((qInstance) -> {});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Test that a table with no fields fails.
|
** Test that a table with no fields fails.
|
||||||
**
|
**
|
||||||
@ -1949,9 +1979,9 @@ class QInstanceValidatorTest extends BaseTest
|
|||||||
** failed validation with reasons that match the supplied vararg-reasons (but allow
|
** failed validation with reasons that match the supplied vararg-reasons (but allow
|
||||||
** more reasons - e.g., helpful when one thing we're testing causes other errors).
|
** more reasons - e.g., helpful when one thing we're testing causes other errors).
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private void assertValidationFailureReasonsAllowingExtraReasons(Consumer<QInstance> setup, String... reasons)
|
public static void assertValidationFailureReasonsAllowingExtraReasons(Consumer<QInstance> setup, String... expectedReasons)
|
||||||
{
|
{
|
||||||
assertValidationFailureReasons(setup, true, reasons);
|
assertValidationFailureReasons(setup, true, expectedReasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1961,9 +1991,9 @@ class QInstanceValidatorTest extends BaseTest
|
|||||||
** failed validation with reasons that match the supplied vararg-reasons (and
|
** failed validation with reasons that match the supplied vararg-reasons (and
|
||||||
** require that exact # of reasons).
|
** require that exact # of reasons).
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private void assertValidationFailureReasons(Consumer<QInstance> setup, String... reasons)
|
public static void assertValidationFailureReasons(Consumer<QInstance> setup, String... expectedReasons)
|
||||||
{
|
{
|
||||||
assertValidationFailureReasons(setup, false, reasons);
|
assertValidationFailureReasons(setup, false, expectedReasons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1971,7 +2001,7 @@ class QInstanceValidatorTest extends BaseTest
|
|||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Implementation for the overloads of this name.
|
** Implementation for the overloads of this name.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private void assertValidationFailureReasons(Consumer<QInstance> setup, boolean allowExtraReasons, String... reasons)
|
public static void assertValidationFailureReasons(Consumer<QInstance> setup, boolean allowExtraReasons, String... expectedReasons)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -1982,17 +2012,27 @@ class QInstanceValidatorTest extends BaseTest
|
|||||||
}
|
}
|
||||||
catch(QInstanceValidationException e)
|
catch(QInstanceValidationException e)
|
||||||
{
|
{
|
||||||
if(!allowExtraReasons)
|
assertValidationFailureReasons(allowExtraReasons, e.getReasons(), expectedReasons);
|
||||||
{
|
}
|
||||||
int noOfReasons = e.getReasons() == null ? 0 : e.getReasons().size();
|
}
|
||||||
assertEquals(reasons.length, noOfReasons, "Expected number of validation failure reasons.\nExpected reasons: " + String.join(",", reasons)
|
|
||||||
+ "\nActual reasons: " + (noOfReasons > 0 ? String.join("\n", e.getReasons()) : "--"));
|
|
||||||
}
|
|
||||||
|
|
||||||
for(String reason : reasons)
|
|
||||||
{
|
|
||||||
assertReason(reason, e);
|
/*******************************************************************************
|
||||||
}
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
public static void assertValidationFailureReasons(boolean allowExtraReasons, List<String> actualReasons, String... expectedReasons)
|
||||||
|
{
|
||||||
|
if(!allowExtraReasons)
|
||||||
|
{
|
||||||
|
int noOfReasons = actualReasons == null ? 0 : actualReasons.size();
|
||||||
|
assertEquals(expectedReasons.length, noOfReasons, "Expected number of validation failure reasons.\nExpected reasons: " + String.join(",", expectedReasons)
|
||||||
|
+ "\nActual reasons: " + (noOfReasons > 0 ? String.join("\n", actualReasons) : "--"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for(String reason : expectedReasons)
|
||||||
|
{
|
||||||
|
assertReason(reason, actualReasons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2022,11 +2062,11 @@ class QInstanceValidatorTest extends BaseTest
|
|||||||
** the list of reasons in the QInstanceValidationException.
|
** the list of reasons in the QInstanceValidationException.
|
||||||
**
|
**
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
private void assertReason(String reason, QInstanceValidationException e)
|
public static void assertReason(String reason, List<String> actualReasons)
|
||||||
{
|
{
|
||||||
assertNotNull(e.getReasons(), "Expected there to be a reason for the failure (but there was not)");
|
assertNotNull(actualReasons, "Expected there to be a reason for the failure (but there was not)");
|
||||||
assertThat(e.getReasons())
|
assertThat(actualReasons)
|
||||||
.withFailMessage("Expected any of:\n%s\nTo match: [%s]", e.getReasons(), reason)
|
.withFailMessage("Expected any of:\n%s\nTo match: [%s]", actualReasons, reason)
|
||||||
.anyMatch(s -> s.contains(reason));
|
.anyMatch(s -> s.contains(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.backend.core.instances.validation.plugins;
|
||||||
|
|
||||||
|
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.processes.QProcessMetaData;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** test instance of a validator plugin, that always adds an error
|
||||||
|
*******************************************************************************/
|
||||||
|
public class AlwaysFailsProcessValidatorPlugin implements QInstanceValidatorPluginInterface<QProcessMetaData>
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Override
|
||||||
|
public void validate(QProcessMetaData object, QInstance qInstance, QInstanceValidator qInstanceValidator)
|
||||||
|
{
|
||||||
|
qInstanceValidator.getErrors().add("I always fail.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,109 @@
|
|||||||
|
/*
|
||||||
|
* QQQ - Low-code Application Framework for Engineers.
|
||||||
|
* Copyright (C) 2021-2024. Kingsrook, LLC
|
||||||
|
* 651 N Broad St Ste 205 # 6917 | Middletown DE 19709 | United States
|
||||||
|
* contact@kingsrook.com
|
||||||
|
* https://github.com/Kingsrook/
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.kingsrook.qqq.backend.core.instances.validation.plugins;
|
||||||
|
|
||||||
|
|
||||||
|
import com.kingsrook.qqq.backend.core.BaseTest;
|
||||||
|
import com.kingsrook.qqq.backend.core.context.QContext;
|
||||||
|
import com.kingsrook.qqq.backend.core.instances.QInstanceValidator;
|
||||||
|
import com.kingsrook.qqq.backend.core.model.metadata.QInstance;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.basepull.BasepullConfiguration;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.basepull.ExtractViaBasepullQueryStep;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.ExtractViaQueryStep;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.LoadViaInsertStep;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.StreamedETLWithFrontendProcess;
|
||||||
|
import com.kingsrook.qqq.backend.core.processes.implementations.etl.streamedwithfrontend.StreamedETLWithFrontendProcessTest;
|
||||||
|
import com.kingsrook.qqq.backend.core.utils.TestUtils;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import static com.kingsrook.qqq.backend.core.instances.QInstanceValidatorTest.assertValidationFailureReasons;
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Unit test for BasepullExtractStepValidator
|
||||||
|
*******************************************************************************/
|
||||||
|
class BasepullExtractStepValidatorTest extends BaseTest
|
||||||
|
{
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testNoExtractStepAtAllFails()
|
||||||
|
{
|
||||||
|
QInstance qInstance = QContext.getQInstance();
|
||||||
|
QInstanceValidator validator = new QInstanceValidator();
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// turns out, our "basepullTestProcess" doesn't have an extract step, so that makes this condition fire. //
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
new BasepullExtractStepValidator().validate(qInstance.getProcess(TestUtils.PROCESS_NAME_BASEPULL), qInstance, validator);
|
||||||
|
assertValidationFailureReasons(false, validator.getErrors(), "does not have a field with a default value that is a BasepullExtractStepInterface CodeReference");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testExtractViaQueryNotBasePull()
|
||||||
|
{
|
||||||
|
QInstance qInstance = QContext.getQInstance();
|
||||||
|
QInstanceValidator validator = new QInstanceValidator();
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// set up a streamed-etl process, but with an ExtractViaQueryStep instead of a basepull - it should fail! //
|
||||||
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
new BasepullExtractStepValidator().validate(StreamedETLWithFrontendProcess.defineProcessMetaData(
|
||||||
|
TestUtils.TABLE_NAME_SHAPE,
|
||||||
|
TestUtils.TABLE_NAME_PERSON_MEMORY,
|
||||||
|
ExtractViaQueryStep.class,
|
||||||
|
StreamedETLWithFrontendProcessTest.TestTransformShapeToPersonStep.class,
|
||||||
|
LoadViaInsertStep.class).withBasepullConfiguration(new BasepullConfiguration()), qInstance, validator);
|
||||||
|
assertValidationFailureReasons(false, validator.getErrors(), "does not have a field with a default value that is a BasepullExtractStepInterface CodeReference");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
void testExtractViaBasepullQueryPasses()
|
||||||
|
{
|
||||||
|
QInstance qInstance = QContext.getQInstance();
|
||||||
|
QInstanceValidator validator = new QInstanceValidator();
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// set up a streamed-etl process, with an ExtractViaBasepullQueryStep as expected - should pass //
|
||||||
|
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
new BasepullExtractStepValidator().validate(StreamedETLWithFrontendProcess.defineProcessMetaData(
|
||||||
|
TestUtils.TABLE_NAME_SHAPE,
|
||||||
|
TestUtils.TABLE_NAME_PERSON_MEMORY,
|
||||||
|
ExtractViaBasepullQueryStep.class,
|
||||||
|
StreamedETLWithFrontendProcessTest.TestTransformShapeToPersonStep.class,
|
||||||
|
LoadViaInsertStep.class).withBasepullConfiguration(new BasepullConfiguration()), qInstance, validator);
|
||||||
|
assertThat(validator.getErrors()).isNullOrEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Reference in New Issue
Block a user