Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to generate test data using the OCL operation allInstances() #4

Open
killxin opened this issue Dec 24, 2018 · 0 comments
Open

How to generate test data using the OCL operation allInstances() #4

killxin opened this issue Dec 24, 2018 · 0 comments

Comments

@killxin
Copy link

killxin commented Dec 24, 2018

I have a problem when generating test data using the following model and OCL, which means "there are two instances c1, c2 of MyCollection, and the number of objects in c1 equals to that of c2 plus 1".
mytest2

context MyCollection inv initial:
    MyCollection.allInstances()->collect(x|x.id)->includesAll(Set{1,2}) 
    and MyCollection.allInstances()->any(x|x.id=1).myobject->size() = 
        MyCollection.allInstances()->any(x|x.id=2).myobject->size() + 1 

Here is my code,

String UMLModelPath = "../EsOCLUsage/MyTest2.uml";
String constraint = "context MyCollection inv initial:"
	+ "MyCollection.allInstances()->collect(x|x.id)->includesAll(Set{1,2})"
 	+ " and MyCollection.allInstances()->any(x|x.id=1).myobject->size() = MyCollection.allInstances()->any(x|x.id=2).myobject->size() + 1"
        ;
OCLSolver oclSolver = new OCLSolver();
Result result = oclSolver.solveConstraint(UMLModelPath, constraint, new int[]{OCLSolver.OpOEA}, 5000);
oclSolver.printResults(result);

It fails to generate the target model and prints the error information:
no.simula.esocl.ocl.distance.FitnessCalculator ERROR: Instance not interpreted
If I use the simplified OCL as follows, it also returns false.

context MyCollection inv initial:
    MyCollection.allInstances()->collect(x|x.id)->includesAll(Set{1,2}) 

Since the OCL is very similar to

let c = Set{-1,87,19,88} in X.allInstances()->collect(b|b.y)->includesAll(c)

, A11 of TABLE 21 in the paper "Generating Test Data from OCL Constraints with Search Techniques"(TSE'2013), maybe there are some suggestions to solve the problem?

Thanks for your help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant