Skip to content

Commit

Permalink
Add tests for project validator
Browse files Browse the repository at this point in the history
  • Loading branch information
maltemoeser committed Dec 15, 2014
1 parent fe2de09 commit cf2ce90
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package TestProject.controllers

remoteConnection testConnection {
uri "test"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package TestProject.workflows

remoteConnection testConnection {
uri "test"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package TestProject.workflows

entity Test {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package TestProject.models

FlowLayoutPane MediaCapturingView2 (vertical) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package TestProject.models

WorkflowElement LocationDetection
fires LocationDetectionEvent {
start LocationDetection
}

App CurrentStateProjectApp {
WorkflowElements {
LocationDetection (startable: "Start Controller 1")
}
appName "functionTestApp"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package de.wwu.md2.framework.tests.dsl.project.validator

import org.eclipse.xtext.junit4.InjectWith
import de.wwu.md2.framework.MD2InjectorProvider
import org.junit.runner.RunWith
import org.eclipse.xtext.junit4.XtextRunner
import javax.inject.Inject
import org.eclipse.xtext.junit4.util.ParseHelper
import de.wwu.md2.framework.mD2.MD2Model
import org.junit.Before
import static extension de.wwu.md2.framework.tests.utils.ModelProvider.*

import org.junit.Test
import org.eclipse.xtext.junit4.validation.ValidationTestHelper

import de.wwu.md2.framework.mD2.MD2Package
import de.wwu.md2.framework.validation.ProjectValidator

@InjectWith(typeof(MD2InjectorProvider))
@RunWith(typeof(XtextRunner))

class ModelElementPackageCongruenceTest {
@Inject extension ParseHelper<MD2Model>
@Inject extension ValidationTestHelper

MD2Model controllerModel;
MD2Model modelModel;
MD2Model viewModel;
MD2Model workflowModel
MD2Model testModel

@Before
def void setUp() {
controllerModel = PROJECT_VALIDATOR_MEC_CIW.load.parse
modelModel = PROJECT_VALIDATOR_MEC_MIW.load.parse
viewModel = PROJECT_VALIDATOR_MEC_VIM.load.parse
workflowModel = PROJECT_VALIDATOR_MEC_WIM.load.parse
testModel = PROJECT_VALIDATOR_MEC_CIC.load.parse
}

/**
* Test whether the correct error is thrown when model elements are declared in the wrong file.
*/
@Test
def checkModelElementCompliesWithPackageTest() {
controllerModel.assertError(MD2Package::eINSTANCE.MD2Model, ProjectValidator::MODELELEMENT_PACKAGE)
modelModel.assertError(MD2Package::eINSTANCE.MD2Model, ProjectValidator::MODELELEMENT_PACKAGE)
viewModel.assertError(MD2Package::eINSTANCE.MD2Model, ProjectValidator::MODELELEMENT_PACKAGE)
workflowModel.assertError(MD2Package::eINSTANCE.MD2Model, ProjectValidator::MODELELEMENT_PACKAGE)
}

@Test
def checkNoErrorForCorrectPackage(){
testModel.assertNoError(ProjectValidator::MODELELEMENT_PACKAGE)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,28 @@ public class ModelProvider {

public static String VALIDATOR_MODEL_M = "dsl/model/validator/Model.md2";


//***Project***//

public static String PROJECT_VALIDATOR_MEC_CIW = "dsl/project/validator/modelElementPackageCongruence/controllerInWorkflow.md2";
public static String PROJECT_VALIDATOR_MEC_MIW = "dsl/project/validator/modelElementPackageCongruence/modelInWorkflow.md2";
public static String PROJECT_VALIDATOR_MEC_VIM = "dsl/project/validator/modelElementPackageCongruence/viewInModel.md2";
public static String PROJECT_VALIDATOR_MEC_WIM = "dsl/project/validator/modelElementPackageCongruence/workflowInModel.md2";
public static String PROJECT_VALIDATOR_MEC_CIC = "dsl/project/validator/modelElementPackageCongruence/controllerInController.md2";


//***Workflow***//

public static String WORKFLOW_FUNCTION_W = "dsl/workflow/functionTest/workflow.md2";
public static String WORKFLOW_FUNCTION_C = "dsl/workflow/functionTest/controller.md2";
public static String WORKFLOW_FUNCTION_V = "dsl/workflow/functionTest/view.md2";
public static String WORKFLOW_FUNCTION_M = "dsl/workflow/functionTest/model.md2";

public static String WORKFLOW_VALIDATOR_W = "dsl/workflow/validator/workflow.md2";
public static String WORKFLOW_VALIDATOR_C = "dsl/workflow/validator/controller.md2";
public static String WORKFLOW_VALIDATOR_V = "dsl/workflow/validator/view.md2";
public static String WORKFLOW_VALIDATOR_M = "dsl/workflow/validator/model.md2";


//***Controller***//

Expand Down

0 comments on commit cf2ce90

Please sign in to comment.