// search for 2 Loads at the same time
OperatorPlan pattern = new SillyPlan();
pattern.add(new OP_Load("mmm1", pattern));
pattern.add(new OP_Load("mmm2", pattern));
Rule r = new SillyRule("basic", pattern);
List<OperatorPlan> l = r.match(plan);
assertEquals(l.size(), 1);
assertEquals(l.get(0).getSources().size(), 2);
assertEquals(l.get(0).getSinks().size(), 2);
assertEquals(l.get(0).size(), 2);
Operator m1 = l.get(0).getSources().get(0);
assertTrue(m1.getName().equals("p1") || m1.getName().equals("p2"));
Operator m2 = l.get(0).getSources().get(1);
assertTrue(m2.getName().equals("p1") || m2.getName().equals("p2"));
assertNotSame(m1.getName(), m2.getName());
// search for join then filter
pattern = new SillyPlan();
Operator s1 = new OP_Join("mmm1", pattern);
Operator s2 = new OP_Filter("mmm2", pattern);
pattern.add(s1);
pattern.add(s2);
pattern.connect(s1, s2);
r = new SillyRule("basic", pattern);
l = r.match(plan);
assertEquals(l.size(), 1);
assertEquals(l.get(0).getSources().size(), 1);
assertEquals(l.get(0).getSinks().size(), 1);
assertEquals(l.get(0).size(), 2);
m1 = l.get(0).getSources().get(0);
assertTrue(m1.getName().equals("j1"));
m2 = l.get(0).getSinks().get(0);
assertTrue(m2.getName().equals("f1"));
// search for filter, then store
pattern = new SillyPlan();
s1 = new OP_Filter("mmm1", pattern);
s2 = new OP_Store("mmm2", pattern);
pattern.add(s1);
pattern.add(s2);
pattern.connect(s1, s2);
r = new SillyRule("basic", pattern);
l = r.match(plan);
assertEquals(2, l.size());
assertEquals(l.get(0).getSources().size(), 1);
assertEquals(l.get(0).getSinks().size(), 1);
// search for 2 loads, then join
pattern = new SillyPlan();
s1 = new OP_Load("mmm1", pattern);
s2 = new OP_Load("mmm2", pattern);
Operator s3 = new OP_Join("jjj", pattern);
pattern.add(s1);
pattern.add(s2);
pattern.add(s3);
pattern.connect(s1, s3);
pattern.connect(s2, s3);
r = new SillyRule("basic", pattern);
l = r.match(plan);
assertEquals(l.size(), 1);
// search for split then 2 filters
pattern = new SillyPlan();
s1 = new OP_Split("mmm1", pattern);
s2 = new OP_Filter("mmm2", pattern);
s3 = new OP_Filter("mmm3", pattern);
pattern.add(s1);
pattern.add(s2);
pattern.add(s3);
pattern.connect(s1, s2);
pattern.connect(s1, s3);
r = new SillyRule("basic", pattern);
l = r.match(plan);
assertEquals(1, l.size());
assertEquals(l.get(0).getSources().size(), 1);
assertEquals(l.get(0).getSinks().size(), 2);
assertEquals(l.get(0).size(), 3);