Skip to content

Commit

Permalink
Add test for empty processChain.
Browse files Browse the repository at this point in the history
Changed the warning message from "No processChain steps are defined for this processChain. Such processChains have no effect and should be omitted." to "No processChain steps are defined for this processChain. A processChain should have at least one step showing a view.".
  • Loading branch information
maltemoeser committed Dec 19, 2014
1 parent ed53ca4 commit 80869d1
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package TestProject.controllers

WorkflowElement Test {
defaultProcessChain TestChain

onInit {
action CustomAction init {

}
}

processChain TestChain {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -32,6 +35,7 @@ class ValidatorTests {
MD2Model viewModel;
MD2Model rootValidatorModel;
MD2Model inputFieldValidatorModel;
MD2Model emptyProcessChainModel;
ResourceSet rs;

private EList<ControllerElement> elements;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}


}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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*****//

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ class ControllerValidator extends AbstractMD2JavaValidator {
@Inject
override register(EValidatorRegistrar registrar) {
// nothing to do
}
}

public static final String EMPTYPROCESSCHAIN = "emptyProcessChain";

/////////////////////////////////////////////////////////
/// Action Validators
Expand Down Expand Up @@ -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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 80869d1

Please sign in to comment.