diff --git a/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 new file mode 100644 index 00000000..8473b794 --- /dev/null +++ b/de.wwu.md2.framework.tests/models/de/wwu/md2/framework/tests/dsl/controller/validator/EmptyProcessChain.md2 @@ -0,0 +1,15 @@ +package TestProject.controllers + +WorkflowElement Test { + defaultProcessChain TestChain + + onInit { + action CustomAction init { + + } + } + + processChain TestChain { + + } +} diff --git a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend index 82202df7..ee9040ac 100644 --- a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend +++ b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/dsl/controller/validator/ValidatorTests.xtend @@ -21,6 +21,9 @@ import de.wwu.md2.framework.mD2.Validator import java.util.List import de.wwu.md2.framework.mD2.CustomAction import de.wwu.md2.framework.mD2.ValidatorBindingTask +import de.wwu.md2.framework.mD2.MD2Package +import de.wwu.md2.framework.validation.ControllerValidator +import de.wwu.md2.framework.mD2.WorkflowElement @InjectWith(typeof(MD2InjectorProvider)) @RunWith(typeof(XtextRunner)) @@ -32,6 +35,7 @@ class ValidatorTests { MD2Model viewModel; MD2Model rootValidatorModel; MD2Model inputFieldValidatorModel; + MD2Model emptyProcessChainModel; ResourceSet rs; private EList elements; @@ -48,6 +52,7 @@ class ValidatorTests { mainModel = BASIC_CONTROLLER_M.load.parse(rs); rootValidatorModel = VALIDATOR_COMPONENT_C.load.parse(rs); inputFieldValidatorModel = INPUT_FIELD_VALIDATOR_COMPONENT_C.load.parse(rs); + emptyProcessChainModel = EMPTY_PROCESS_CHAIN_C.load.parse; elements = (rootValidatorModel.modelLayer as Controller).controllerElements; validators = elements.filter(typeof(Validator)).toList; @@ -101,7 +106,12 @@ class ValidatorTests { 1.assertEquals(tasks.get(1).validators.size); 1.assertEquals(tasks.get(2).validators.size); 1.assertEquals(tasks.get(3).validators.size); - } + } + + @Test + def checkForEmptyProcessChainsTest(){ + emptyProcessChainModel.assertWarning(MD2Package::eINSTANCE.processChain, ControllerValidator::EMPTYPROCESSCHAIN); + } } diff --git a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java index 2ac4597d..98696ab6 100644 --- a/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java +++ b/de.wwu.md2.framework.tests/src/de/wwu/md2/framework/tests/utils/ModelProvider.java @@ -51,6 +51,8 @@ public class ModelProvider { public static final String VALIDATOR_COMPONENT_C = "dsl/controller/validator/RootValidators.md2"; public static final String INPUT_FIELD_VALIDATOR_COMPONENT_C = "dsl/controller/validator/InputFieldValidators.md2"; + + public static final String EMPTY_PROCESS_CHAIN_C = "dsl/controller/validator/EmptyProcessChain.md2"; //********Validator*****// diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend index 58661230..9aea410b 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/ControllerValidator.xtend @@ -31,7 +31,9 @@ class ControllerValidator extends AbstractMD2JavaValidator { @Inject override register(EValidatorRegistrar registrar) { // nothing to do - } + } + + public static final String EMPTYPROCESSCHAIN = "emptyProcessChain"; ///////////////////////////////////////////////////////// /// Action Validators @@ -263,5 +265,18 @@ class ControllerValidator extends AbstractMD2JavaValidator { val error = '''No subsequent step! Cannot define 'proceed' operation on last processChain step.''' acceptError(error, next, null, -1, null); } - } + } + + /** + * Avoid empty processChains. + * @param processChain + */ + @Check + def checkForEmptyProcessChains(ProcessChain processChain) { + if(processChain.processChainSteps.empty) { + acceptWarning("No processChain steps are defined for this processChain. A processChain should have at least one step showing a view.", + processChain, null, -1, EMPTYPROCESSCHAIN); + } + } + } diff --git a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java index f0afbce6..2d6f32a9 100644 --- a/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java +++ b/de.wwu.md2.framework/src/de/wwu/md2/framework/validation/LegacyValidator.java @@ -450,18 +450,6 @@ public void checkAbstractViewGUIElementRef_Path(AbstractViewGUIElementRef abstra } } - /** - * Avoid empty processChains. - * @param processChain - */ - @Check - public void checkForEmptyProcessChains(ProcessChain processChain) { - if(processChain.getProcessChainSteps().isEmpty()) { - acceptWarning("No processChain steps are defined for this processChain. Such processChains have no effect and should be omitted.", - processChain, null, -1, null); - } - } - /** * This validator avoids the assignment of none-toMany content providers (providing X[]) to ContentProviderAddActions. * @param addAction