Skip to content

Commit

Permalink
fix test with two hosted on one
Browse files Browse the repository at this point in the history
  • Loading branch information
lharzenetter committed Sep 1, 2020
1 parent 845ad91 commit 78e9502
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,22 @@ void checkMutabilityOfPrmWithTwoPatternsHostedOnOne() {
PermutationGenerator permutationGenerator = new PermutationGenerator();
assertTrue(permutationGenerator.checkMutability(refinementModel));

// assertEquals(7, refinementModel.getPermutationMappings().size());
List<OTPermutationMapping> permutationMappings = refinementModel.getPermutationMappings();
assertEquals(7, permutationMappings.size());

assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("1")
&& mapping.getRefinementElement().getId().equals("11")));
assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("3")
&& mapping.getRefinementElement().getId().equals("12")));
assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("2")
&& mapping.getRefinementElement().getId().equals("13")));
assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("2")
&& mapping.getRefinementElement().getId().equals("14")));
assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("1--3")
&& mapping.getRefinementElement().getId().equals("12")));
assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("1--2")
&& mapping.getRefinementElement().getId().equals("13")));
assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("3--2")
&& mapping.getRefinementElement().getId().equals("13")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,64 @@ void prmWithTwoHostedOnOneTest() throws Exception {

assertEquals(6, permutations.size());

// todo: relation between pattern1 and 12 is missing after mutating the prm
OTTopologyFragmentRefinementModel permutation_1 = permutations.get("PrmWithComplexRelationMappings_permutation-1-w1-wip1");
assertNotNull(permutation_1);
assertEquals(3, permutation_1.getDetector().getNodeTemplates().size());
assertEquals(3, permutation_1.getDetector().getRelationshipTemplates().size());
assertTrue(permutation_1.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("11") && relation.getTargetElement().getRef().getId().equals("2")));
assertTrue(permutation_1.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("11") && relation.getTargetElement().getRef().getId().equals("3")));

OTTopologyFragmentRefinementModel permutation_2 = permutations.get("PrmWithComplexRelationMappings_permutation-2-w1-wip1");
assertNotNull(permutation_2);
assertEquals(4, permutation_2.getDetector().getNodeTemplates().size());
assertEquals(4, permutation_2.getDetector().getRelationshipTemplates().size());
assertTrue(permutation_2.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("1") && relation.getTargetElement().getRef().getId().equals("13")));
assertTrue(permutation_2.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("3") && relation.getTargetElement().getRef().getId().equals("13")));

OTTopologyFragmentRefinementModel permutation_3 = permutations.get("PrmWithComplexRelationMappings_permutation-3-w1-wip1");
assertNotNull(permutation_3);
assertEquals(3, permutation_3.getDetector().getNodeTemplates().size());
assertEquals(3, permutation_3.getDetector().getRelationshipTemplates().size());
assertTrue(permutation_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("12") && relation.getTargetElement().getRef().getId().equals("2")));
assertTrue(permutation_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("1") && relation.getTargetElement().getRef().getId().equals("12")));

OTTopologyFragmentRefinementModel permutation_1_2 = permutations.get("PrmWithComplexRelationMappings_permutation-1-2-w1-wip1");
assertNotNull(permutation_1_2);
assertEquals(4, permutation_1_2.getDetector().getNodeTemplates().size());
assertEquals(4, permutation_1_2.getDetector().getRelationshipTemplates().size());
assertTrue(permutation_1_2.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("11") && relation.getTargetElement().getRef().getId().equals("13")));
assertTrue(permutation_1_2.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("11") && relation.getTargetElement().getRef().getId().equals("3")));
assertTrue(permutation_1_2.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("3") && relation.getTargetElement().getRef().getId().equals("13")));

OTTopologyFragmentRefinementModel permutation_1_3 = permutations.get("PrmWithComplexRelationMappings_permutation-1-3-w1-wip1");
assertNotNull(permutation_1_3);
assertEquals(3, permutation_1_3.getDetector().getNodeTemplates().size());
assertEquals(3, permutation_1_3.getDetector().getRelationshipTemplates().size());
assertTrue(permutation_1_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("11") && relation.getTargetElement().getRef().getId().equals("2")));
assertTrue(permutation_1_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("11") && relation.getTargetElement().getRef().getId().equals("12")));
assertTrue(permutation_1_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("12") && relation.getTargetElement().getRef().getId().equals("2")));

OTTopologyFragmentRefinementModel permutation_2_3 = permutations.get("PrmWithComplexRelationMappings_permutation-2-3-w1-wip1");
assertNotNull(permutation_2_3);
assertEquals(4, permutation_2_3.getDetector().getNodeTemplates().size());
assertEquals(4, permutation_2_3.getDetector().getRelationshipTemplates().size());
assertTrue(permutation_2_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("1") && relation.getTargetElement().getRef().getId().equals("12")));
assertTrue(permutation_2_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("1") && relation.getTargetElement().getRef().getId().equals("13")));
assertTrue(permutation_2_3.getDetector().getRelationshipTemplates().removeIf(relation ->
relation.getSourceElement().getRef().getId().equals("12") && relation.getTargetElement().getRef().getId().equals("13")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,6 @@ static OTPatternRefinementModel generatePrmWithComplexRelationMaps() {
}

static OTPatternRefinementModel generatePrmWithTwoPatternsHostedOnAThird() {

/* +----------------------------------+
+---------------(------------------+ |
| | \/ \/
Expand Down Expand Up @@ -670,11 +669,14 @@ private static TTopologyTemplate generateDetectorWithTwoPatternsHostedOnOne() {
pattern_3.setType("{http://ex.org/patterns}pattern_3");
pattern_3.setId("3");

TRelationshipTemplate pattern3_hostedOn_pattern1 = ModelUtilities.createRelationshipTemplate(
TRelationshipTemplate pattern3_hostedOn_pattern2 = ModelUtilities.createRelationshipTemplate(
pattern_3, detector.getNodeTemplate("2"), QName.valueOf("{http://ex.org}relType_hostedOn"));
TRelationshipTemplate pattern1_connectsTo_pattern3 = ModelUtilities.createRelationshipTemplate(
detector.getNodeTemplate("1"), pattern_3, QName.valueOf("{http://ex.org}relType_connectsTo"));

detector.addNodeTemplate(pattern_3);
detector.addRelationshipTemplate(pattern3_hostedOn_pattern1);
detector.addRelationshipTemplate(pattern3_hostedOn_pattern2);
detector.addRelationshipTemplate(pattern1_connectsTo_pattern3);

return detector;
}
Expand Down

0 comments on commit 78e9502

Please sign in to comment.