Package core

Examples of core.CellAddressFactory


*/
public class StandarizationOperatorTest {

    @Test
    public void testConstructorOfStandarizationOperator() {
        CellAddressFactory caf;
        Relation input;
        StandarizationOperator standOper;
        Formulas expectedResult;
        Formulas resultFormulas;
        Relation resRelation;

        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)");
View Full Code Here


* @author jsroka
*/
public class SortingOperatorTest {
    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSortingOperatorFailAsc1() {
        CellAddressFactory caf;
        Relation input;

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        new SortingAscendingOperator(caf, input, 0);//nie można sortować po kolumnie z nieistniejącym indeksem
    }
View Full Code Here

        new SortingAscendingOperator(caf, input, 0);//nie można sortować po kolumnie z nieistniejącym indeksem
    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSortingOperatorFailDesc1() {
        CellAddressFactory caf;
        Relation input;

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        new SortingDescendingOperator(caf, input, 0);//nie można sortować po kolumnie z nieistniejącym indeksem
    }
View Full Code Here

        new SortingDescendingOperator(caf, input, 0);//nie można sortować po kolumnie z nieistniejącym indeksem
    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSortingOperatorFailAsc2() {
        CellAddressFactory caf;
        Relation input;

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        new SortingAscendingOperator(caf, input, 2);//nie można sortować po kolumnie z nieistniejącym indeksem
    }
View Full Code Here

        new SortingAscendingOperator(caf, input, 2);//nie można sortować po kolumnie z nieistniejącym indeksem
    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSortingOperatorFailDesc2() {
        CellAddressFactory caf;
        Relation input;

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(1);//(a)
        new SortingDescendingOperator(caf, input, 2);//nie można sortować po kolumnie z nieistniejącym indeksem
    }
View Full Code Here

        new SortingDescendingOperator(caf, input, 2);//nie można sortować po kolumnie z nieistniejącym indeksem
    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSortingOperatorFailAsc3() {
        CellAddressFactory caf;
        Relation input;
        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(2);//(a,b)
        new SortingAscendingOperator(caf, input, 3);//nie można sortować po kolumnie z nieistniejącym indeksem
    }
View Full Code Here

        new SortingAscendingOperator(caf, input, 3);//nie można sortować po kolumnie z nieistniejącym indeksem
    }

    @Test(expectedExceptions = IllegalArgumentException.class)
    public void testSortingOperatorFailDesc3() {
        CellAddressFactory caf;
        Relation input;

        caf = new CellAddressFactory(1);
        input = caf.getSpaceForNewRelation(2);//(a,b)
        new SortingDescendingOperator(caf, input, 3);//nie można sortować po kolumnie z nieistniejącym indeksem
    }
View Full Code Here

//G1  =INDEX(B:B,$E1)
//D2  =IF(ISNA($A2),$C$1+1,IF(ISERR($A2),1+$C$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,"<"&$A2)+COUNTIF($A$1:$A2,$A2)))
//E2  =MATCH(ROW(),$D:$D,0)
//F2  =INDEX(A:A,$E2)
//G2  =INDEX(B:B,$E2)
        CellAddressFactory caf;
        Relation inputRelation;
        SortingAscendingOperator sortAscOper;
        SortingDescendingOperator sortDescOper;
        Formulas expectedResult;
        Formulas resultFormulas;
        Relation resRelation;

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(1);//(a)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 1);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),$B$1+1,IF(ISERR($A1),1+$B$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\"<\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        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('C',2), "IF(ISNA($A2),$B$1+1,IF(ISERR($A2),1+$B$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\"<\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('D',2), "MATCH(ROW(),$C:$C,0)");
        expectedResult.put(new Cell('E',2), "INDEX(A:A,$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 = sortAscOper.getResultRelation();
        assertEquals(new Column('E'), resRelation.getFirstCol());
        assertEquals(1, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(1);//(a)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 1);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('B',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('C',1), "IF(ISNA($A1),$B$1+1,IF(ISERR($A1),1+$B$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\">\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
View Full Code Here

        assertEquals(1, resRelation.getCardinality());
    }

    @Test()
    public void testSortingOperatorTwoRowsOnFirst() {
        CellAddressFactory caf;
        Relation inputRelation;
        SortingAscendingOperator sortAscOper;
        SortingDescendingOperator sortDescOper;
        Formulas expectedResult;
        Formulas resultFormulas;
        Relation resRelation;

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 1);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($A1),$C$1+1,IF(ISERR($A1),1+$C$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\"<\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
        expectedResult.put(new Cell('E',1), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',1), "INDEX(A:A,$E1)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$E1)");
        expectedResult.put(new Cell('D',2), "IF(ISNA($A2),$C$1+1,IF(ISERR($A2),1+$C$1-COUNTIF($A:$A,$A2),COUNTIF($A:$A,\"<\"&$A2)+COUNTIF($A$1:$A2,$A2)))");
        expectedResult.put(new Cell('E',2), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',2), "INDEX(A:A,$E2)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$E2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('F'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 1);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($A:$A)-COUNTIF($A:$A,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($A1),$C$1+1,IF(ISERR($A1),1+$C$1-COUNTIF($A:$A,$A1),COUNTIF($A:$A,\">\"&$A1)+COUNTIF($A$1:$A1,$A1)))");
View Full Code Here

        assertEquals(2, resRelation.getCardinality());
    }

    @Test()
    public void testSortingOperatorTwoRowsOnSecond() {
        CellAddressFactory caf;
        Relation inputRelation;
        SortingAscendingOperator sortAscOper;
        SortingDescendingOperator sortDescOper;
        Formulas expectedResult;
        Formulas resultFormulas;
        Relation resRelation;

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortAscOper = new SortingAscendingOperator(caf, inputRelation, 2);
        resultFormulas = sortAscOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($B:$B)-COUNTIF($B:$B,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($B1),$C$1+1,IF(ISERR($B1),1+$C$1-COUNTIF($B:$B,$B1),COUNTIF($B:$B,\"<\"&$B1)+COUNTIF($B$1:$B1,$B1)))");
        expectedResult.put(new Cell('E',1), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',1), "INDEX(A:A,$E1)");
        expectedResult.put(new Cell('G',1), "INDEX(B:B,$E1)");
        expectedResult.put(new Cell('D',2), "IF(ISNA($B2),$C$1+1,IF(ISERR($B2),1+$C$1-COUNTIF($B:$B,$B2),COUNTIF($B:$B,\"<\"&$B2)+COUNTIF($B$1:$B2,$B2)))");
        expectedResult.put(new Cell('E',2), "MATCH(ROW(),$D:$D,0)");
        expectedResult.put(new Cell('F',2), "INDEX(A:A,$E2)");
        expectedResult.put(new Cell('G',2), "INDEX(B:B,$E2)");
//        System.out.println("expected:");
//        System.out.println(expectedResult.toString(caf));
//        System.out.println("real");
//        System.out.println(resultFormulas.toString(caf));
        assertEquals(expectedResult, resultFormulas);
        resRelation = sortAscOper.getResultRelation();
        assertEquals(new Column('F'), resRelation.getFirstCol());
        assertEquals(2, resRelation.getCardinality());

        caf = new CellAddressFactory(1);
        inputRelation = caf.getSpaceForNewRelation(2);//(a,b)
        sortDescOper = new SortingDescendingOperator(caf, inputRelation, 2);
        resultFormulas = sortDescOper.getFormulas();
        expectedResult = new Formulas();
        expectedResult.put(new Cell('C',1), "COUNTA($B:$B)-COUNTIF($B:$B,NA())");
        expectedResult.put(new Cell('D',1), "IF(ISNA($B1),$C$1+1,IF(ISERR($B1),1+$C$1-COUNTIF($B:$B,$B1),COUNTIF($B:$B,\">\"&$B1)+COUNTIF($B$1:$B1,$B1)))");
View Full Code Here

TOP

Related Classes of core.CellAddressFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.