Skip to content
This repository was archived by the owner on Mar 2, 2020. It is now read-only.

Commit 10a301a

Browse files
authored
Improve test generation from processes (#480)
* wip * wip * wip * wip * start refactoring * reworked test generation from process models. Open: Create tests * working on test for generation from process models * add test * adapt integration test for generating from processes * remove warning * address review comments
1 parent a5091fa commit 10a301a

File tree

13 files changed

+552
-214
lines changed

13 files changed

+552
-214
lines changed

bundles/specmate-integration-test/src/com/specmate/test/integration/CrudTest.java

+5-7
Original file line numberDiff line numberDiff line change
@@ -530,14 +530,13 @@ public void testGenerateTestsFromProcess() {
530530
// Expect 2 tests should be generated
531531
Assert.assertEquals(2, testCases.size());
532532

533-
// Expect 4 children: two test cases and two test parameters
534-
Assert.assertEquals(4, retrievedTestChilds.length());
533+
// Expect 3 children: two test cases and one test parameter
534+
Assert.assertEquals(3, retrievedTestChilds.length());
535535
getResult.getResponse().close();
536536
}
537537

538-
539-
@Test
540-
public void testGenerateTestsWithMutExConstraint() {
538+
@Test
539+
public void testGenerateTestsWithMutExConstraint() {
541540

542541
JSONObject requirement = postRequirementToRoot();
543542
String requirementId = getId(requirement);
@@ -595,9 +594,8 @@ public void testGenerateTestsWithMutExConstraint() {
595594
numberOfInconsistentTests++;
596595
}
597596
}
598-
Assert.assertEquals(1, numberOfInconsistentTests);
597+
Assert.assertEquals(1, numberOfInconsistentTests);
599598
}
600-
601599

602600
/**
603601
* Generates a model with contradictory constraints and trys to generate test

bundles/specmate-integration-test/src/com/specmate/test/integration/ModelGenerationTestBase.java

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
import org.json.JSONArray;
1111
import org.json.JSONObject;
1212
import org.junit.Assert;
13-
import org.junit.Test;
1413

1514
import com.specmate.model.base.BasePackage;
1615
import com.specmate.model.requirements.CEGConnection;

bundles/specmate-model-support/src/com/specmate/model/support/util/SpecmateEcoreUtil.java

+8
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
import java.util.ArrayList;
44
import java.util.Collection;
55
import java.util.Collections;
6+
import java.util.HashSet;
67
import java.util.Iterator;
78
import java.util.List;
9+
import java.util.Set;
810

911
import org.eclipse.emf.cdo.CDOObject;
1012
import org.eclipse.emf.cdo.CDOState;
@@ -88,6 +90,12 @@ public static <T> List<T> getRootObjectsByType(Resource resource, Class<T> clazz
8890
return pickInstancesOf(resource.getContents(), clazz);
8991
}
9092

93+
public static <T> Set<T> uniqueInstancesOf(List<? extends EObject> contents, Class<T> clazz) {
94+
Set<T> result = new HashSet<>();
95+
result.addAll(pickInstancesOf(contents.iterator(), clazz));
96+
return result;
97+
}
98+
9199
public static <T> List<T> pickInstancesOf(List<? extends EObject> contents, Class<T> clazz) {
92100
return pickInstancesOf(contents.iterator(), clazz);
93101
}

bundles/specmate-persistency-cdo/src/com/specmate/persistency/validation/IDValidator.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ public void newObject(EObject object, String id, String className, Map<EStructur
4141

4242
private String validateID(EObject obj, Object objID) throws SpecmateValidationException {
4343
if (objID == null) {
44-
throw new SpecmateValidationException("Object does not have a valid Id.", getValidatorName(),
44+
throw new SpecmateValidationException(
45+
"Object of type " + obj.eClass().getName() + " does not have a valid Id.", getValidatorName(),
4546
getObjectName(obj));
4647
}
4748

0 commit comments

Comments
 (0)