// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);
resRelation = diffOper.getResultRelation();
assertEquals(new Column('C'), resRelation.getFirstCol());
assertEquals(1, resRelation.getCardinality());
caf = new CellAddressFactory(1);
in1 = caf.getSpaceForNewRelation(2);//(a,b)
in2 = caf.getSpaceForNewRelation(2);//(c,d)
diffOper = new DifferenceBagOperator(caf, in1, in2);
resultFormulas = diffOper.getFormulas();
expectedResult = new Formulas();
expectedResult.put(new Cell('E',1), "IF(COUNTIFS($C:$C,$A1,$D:$D,$B1)<COUNTIFS($A$1:$A1,$A1,$B$1:$B1,$B1),A1,NA())");
expectedResult.put(new Cell('F',1), "IF(ISNA($E1),NA(),B1)");
// System.out.println("expected:");
// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);
resRelation = diffOper.getResultRelation();
assertEquals(new Column('E'), resRelation.getFirstCol());
assertEquals(2, resRelation.getCardinality());
caf = new CellAddressFactory(1);
in1 = caf.getSpaceForNewRelation(3);//(a,b,c)
in2 = caf.getSpaceForNewRelation(3);//(d,e,f)
diffOper = new DifferenceBagOperator(caf, in1, in2);
resultFormulas = diffOper.getFormulas();
expectedResult = new Formulas();
expectedResult.put(new Cell('G',1), "IF(COUNTIFS($D:$D,$A1,$E:$E,$B1,$F:$F,$C1)<COUNTIFS($A$1:$A1,$A1,$B$1:$B1,$B1,$C$1:$C1,$C1),A1,NA())");
expectedResult.put(new Cell('H',1), "IF(ISNA($G1),NA(),B1)");
expectedResult.put(new Cell('I',1), "IF(ISNA($G1),NA(),C1)");
// System.out.println("expected:");
// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);
resRelation = diffOper.getResultRelation();
assertEquals(new Column('G'), resRelation.getFirstCol());
assertEquals(3, resRelation.getCardinality());
caf = new CellAddressFactory(2);//kolumny A jest poza naszym zakresem
caf.getSpaceForNewRelation(1);//i jeszcze mamy na początku jedną kolumne z innymi danymi
in1 = caf.getSpaceForNewRelation(2);//(c,d)
caf.getSpaceForNewRelation(1);//oraz dane pomiędzy wejściami
in2 = caf.getSpaceForNewRelation(2);//(f,g)
caf.getSpaceForNewRelation(1);//i dane po wejściach
diffOper = new DifferenceBagOperator(caf, in1, in2);
resultFormulas = diffOper.getFormulas();
expectedResult = new Formulas();
expectedResult.put(new Cell('I',1), "IF(COUNTIFS($F:$F,$C1,$G:$G,$D1)<COUNTIFS($C$1:$C1,$C1,$D$1:$D1,$D1),C1,NA())");
expectedResult.put(new Cell('J',1), "IF(ISNA($I1),NA(),D1)");
// System.out.println("expected:");
// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);
resRelation = diffOper.getResultRelation();
assertEquals(new Column('I'), resRelation.getFirstCol());
assertEquals(2, resRelation.getCardinality());
}