mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
Add validation of step name uniqueness.
This commit is contained in:
@ -1362,12 +1362,17 @@ public class QInstanceValidator
|
|||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
// validate steps in the process //
|
// validate steps in the process //
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
Set<String> usedStepNames = new HashSet<>();
|
||||||
if(assertCondition(CollectionUtils.nullSafeHasContents(process.getStepList()), "At least 1 step must be defined in process " + processName + "."))
|
if(assertCondition(CollectionUtils.nullSafeHasContents(process.getStepList()), "At least 1 step must be defined in process " + processName + "."))
|
||||||
{
|
{
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(QStepMetaData step : process.getStepList())
|
for(QStepMetaData step : process.getStepList())
|
||||||
{
|
{
|
||||||
assertCondition(StringUtils.hasContent(step.getName()), "Missing name for a step at index " + index + " in process " + processName);
|
if(assertCondition(StringUtils.hasContent(step.getName()), "Missing name for a step at index " + index + " in process " + processName))
|
||||||
|
{
|
||||||
|
assertCondition(!usedStepNames.contains(step.getName()), "Duplicate step name [" + step.getName() + "] in process " + processName);
|
||||||
|
usedStepNames.add(step.getName());
|
||||||
|
}
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
|
@ -269,6 +269,25 @@ public class QInstanceValidatorTest extends BaseTest
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** Test rules for process step names (must be set; must not be duplicated)
|
||||||
|
**
|
||||||
|
*******************************************************************************/
|
||||||
|
@Test
|
||||||
|
public void test_validateProcessStepNames()
|
||||||
|
{
|
||||||
|
assertValidationFailureReasons((qInstance) -> qInstance.getProcess(TestUtils.PROCESS_NAME_GREET_PEOPLE_INTERACTIVE).getStepList().get(0).setName(null),
|
||||||
|
"Missing name for a step at index");
|
||||||
|
|
||||||
|
assertValidationFailureReasons((qInstance) -> qInstance.getProcess(TestUtils.PROCESS_NAME_GREET_PEOPLE_INTERACTIVE).getStepList().get(0).setName(""),
|
||||||
|
"Missing name for a step at index");
|
||||||
|
|
||||||
|
assertValidationFailureReasons((qInstance) -> qInstance.getProcess(TestUtils.PROCESS_NAME_GREET_PEOPLE_INTERACTIVE).getStepList().forEach(s -> s.setName("myStep")),
|
||||||
|
"Duplicate step name [myStep]", "Duplicate step name [myStep]");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Test that a process with a step that is a private class fails
|
** Test that a process with a step that is a private class fails
|
||||||
**
|
**
|
||||||
|
Reference in New Issue
Block a user