@Test
public void testJoinTwoElementTuples()
{
Rule rule = RuleModelFactory.eINSTANCE.createRule();
BaseCondition bc1 = RuleModelFactory.eINSTANCE.createBaseCondition();
BaseCondition bc2 = RuleModelFactory.eINSTANCE.createBaseCondition();
List<BaseCondition> conditions = new ArrayList<BaseCondition>();
conditions.add(bc1);
conditions.add(bc2);
ElementDefinition e1 = RuleModelFactory.eINSTANCE.createElementDefinition();
ElementDefinition e2 = RuleModelFactory.eINSTANCE.createElementDefinition();
ElementDefinition e3 = RuleModelFactory.eINSTANCE.createElementDefinition();
rule.getElements().add(e1);
rule.getElements().add(e2);
rule.getElements().add(e3);
// set all the attributes:
e1.setAlias("e1");
e2.setAlias("e2");
e3.setAlias("e3");
List<EObject[]> finalTuples = new ArrayList<EObject[]>();
List<EObject[]> currentTuples = new ArrayList<EObject[]>();
Concern c1 = URNModelFactory.eINSTANCE.createConcern();
Concern c2 = URNModelFactory.eINSTANCE.createConcern();
Concern c3 = URNModelFactory.eINSTANCE.createConcern();
// test the case that the final tuple list is empty:
bc1.setSource("e1");
bc1.setTarget("e2");
bc2.setSource("e2");
bc2.setTarget("e3");
currentTuples.add(new EObject[2]);
currentTuples.get(0)[0] = c1;
currentTuples.get(0)[1] = c2;
assertTrue(finalTuples.isEmpty());
joinProcessor.joinFirstTupleList(finalTuples, currentTuples, conditions, 0, rule);
joinProcessor.joinTwoElementTuples(finalTuples, currentTuples, 0, conditions, rule);
assertEquals(1, finalTuples.size());
assertEquals(finalTuples.get(0)[0], c1);
assertEquals(finalTuples.get(0)[1], c2);
assertEquals(finalTuples.get(0)[2], null);
// test the case that both conditions cover the same elements:
bc1.setSource("e1");
bc1.setTarget("e2");
bc2.setSource("e1");
bc2.setTarget("e2");
currentTuples.add(new EObject[2]);
currentTuples.get(1)[0] = c1;
currentTuples.get(1)[1] = c2;
assertEquals(1, finalTuples.size());
joinProcessor.joinTwoElementTuples(finalTuples, currentTuples, 1, conditions, rule);
assertEquals(1, finalTuples.size());
currentTuples.get(1)[0] = c1;
currentTuples.get(1)[1] = c3;
joinProcessor.joinTwoElementTuples(finalTuples, currentTuples, 1, conditions, rule);
assertEquals(1, finalTuples.size());
// test the case that both conditions are transitively related:
bc1.setSource("e1");
bc1.setTarget("e2");
bc2.setSource("e2");
bc2.setTarget("e3");
finalTuples.clear();
finalTuples.add(new EObject[3]);
finalTuples.get(0)[0] = c1;
finalTuples.get(0)[1] = c2;