caf = new CellAddressFactory(1);
input = caf.getSpaceForNewRelation(1);//(a)
standOper = new StandarizationOperator(caf, input);
resultFormulas = standOper.getFormulas();
expectedResult = new Formulas();
expectedResult.put(new Cell('B',1), "IF(ISNA($A1),0,1)");
expectedResult.put(new Cell('C',1), "MATCH(ROW(),$B:$B,0)");
expectedResult.put(new Cell('D',1), "INDEX(A:A,$C1)");
expectedResult.put(new Cell('B',2), "IF(ISNA($A2),B1,B1+1)");
expectedResult.put(new Cell('C',2), "MATCH(ROW(),$B:$B,0)");
expectedResult.put(new Cell('D',2), "INDEX(A:A,$C2)");
// System.out.println("expected:");
// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);
resRelation = standOper.getResultRelation();
assertEquals(new Column('D'), resRelation.getFirstCol());
assertEquals(1, resRelation.getCardinality());
caf = new CellAddressFactory(1);
input = caf.getSpaceForNewRelation(2);//(a,b)
standOper = new StandarizationOperator(caf, input);
resultFormulas = standOper.getFormulas();
expectedResult = new Formulas();
expectedResult.put(new Cell('C',1), "IF(ISNA($A1),0,1)");
expectedResult.put(new Cell('D',1), "MATCH(ROW(),$C:$C,0)");
expectedResult.put(new Cell('E',1), "INDEX(A:A,$D1)");
expectedResult.put(new Cell('F',1), "INDEX(B:B,$D1)");
expectedResult.put(new Cell('C',2), "IF(ISNA($A2),C1,C1+1)");
expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
expectedResult.put(new Cell('E',2), "INDEX(A:A,$D2)");
expectedResult.put(new Cell('F',2), "INDEX(B:B,$D2)");
// System.out.println("expected:");
// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);
resRelation = standOper.getResultRelation();
assertEquals(new Column('E'), resRelation.getFirstCol());
assertEquals(2, resRelation.getCardinality());
caf = new CellAddressFactory(2);//zaczynamy od B
input = caf.getSpaceForNewRelation(3);//(b,c,d)
standOper = new StandarizationOperator(caf, input);
resultFormulas = standOper.getFormulas();
expectedResult = new Formulas();
expectedResult.put(new Cell('E',1), "IF(ISNA($B1),0,1)");
expectedResult.put(new Cell('F',1), "MATCH(ROW(),$E:$E,0)");
expectedResult.put(new Cell('G',1), "INDEX(B:B,$F1)");
expectedResult.put(new Cell('H',1), "INDEX(C:C,$F1)");
expectedResult.put(new Cell('I',1), "INDEX(D:D,$F1)");
expectedResult.put(new Cell('E',2), "IF(ISNA($B2),E1,E1+1)");
expectedResult.put(new Cell('F',2), "MATCH(ROW(),$E:$E,0)");
expectedResult.put(new Cell('G',2), "INDEX(B:B,$F2)");
expectedResult.put(new Cell('H',2), "INDEX(C:C,$F2)");
expectedResult.put(new Cell('I',2), "INDEX(D:D,$F2)");
// System.out.println("expected:");
// System.out.println(expectedResult.toString(caf));
// System.out.println("real");
// System.out.println(resultFormulas.toString(caf));
assertEquals(expectedResult, resultFormulas);