Search in sources :

Example 1 with TestMember

use of mondrian.olap.fun.TestMember in project mondrian by pentaho.

the class RolapAxisTest method testMemberArrayList.

public void testMemberArrayList() {
    TupleList list = TupleCollections.createList(3);
    list.add(Arrays.<Member>asList(new TestMember("a"), new TestMember("b"), new TestMember("c")));
    list.add(Arrays.<Member>asList(new TestMember("d"), new TestMember("e"), new TestMember("f")));
    list.add(Arrays.<Member>asList(new TestMember("g"), new TestMember("h"), new TestMember("i")));
    StringBuilder buf = new StringBuilder(100);
    RolapAxis axis = new RolapAxis(list);
    List<Position> positions = axis.getPositions();
    boolean firstTimeInner = true;
    for (Position position : positions) {
        if (!firstTimeInner) {
            buf.append(',');
        }
        buf.append(toString(position));
        firstTimeInner = false;
    }
    String s = buf.toString();
    String e = "{a,b,c},{d,e,f},{g,h,i}";
    // System.out.println("s=" +s);
    Assert.assertEquals(s, e);
    positions = axis.getPositions();
    int size = positions.size();
    // System.out.println("size=" +size);
    Assert.assertEquals(size, 3);
    buf.setLength(0);
    for (int i = 0; i < size; i++) {
        Position position = positions.get(i);
        if (i > 0) {
            buf.append(',');
        }
        buf.append(toString(position));
    }
    s = buf.toString();
    e = "{a,b,c},{d,e,f},{g,h,i}";
    // System.out.println("s=" +s);
    Assert.assertEquals(s, e);
}
Also used : TupleList(mondrian.calc.TupleList) Position(mondrian.olap.Position) TestMember(mondrian.olap.fun.TestMember)

Example 2 with TestMember

use of mondrian.olap.fun.TestMember in project mondrian by pentaho.

the class SqlConstraintUtilsTest method testGetSetFromCalculatedMember.

/**
 * calculation test for disjoint tuples
 */
public void testGetSetFromCalculatedMember() {
    List<Member> listColumn1 = new ArrayList<Member>();
    List<Member> listColumn2 = new ArrayList<Member>();
    listColumn1.add(new TestMember("elem1_col1"));
    listColumn1.add(new TestMember("elem2_col1"));
    listColumn2.add(new TestMember("elem1_col2"));
    listColumn2.add(new TestMember("elem2_col2"));
    final List<List<Member>> table = new ArrayList<List<Member>>();
    table.add(listColumn1);
    table.add(listColumn2);
    List<Member> arrayRes = getCalculatedMember(table, 1).getMembers();
    assertEquals(arrayRes.size(), 4);
    assertEquals(listColumn1.get(0), arrayRes.get(0));
    assertEquals(listColumn1.get(1), arrayRes.get(1));
    assertEquals(listColumn2.get(0), arrayRes.get(2));
    assertEquals(listColumn2.get(1), arrayRes.get(3));
}
Also used : TestMember(mondrian.olap.fun.TestMember) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) List(java.util.List) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember)

Example 3 with TestMember

use of mondrian.olap.fun.TestMember in project mondrian by pentaho.

the class SqlConstraintUtilsTest method testGetSetFromCalculatedMember_disjoint.

/**
 * calculation test for disjoint tuples
 */
public void testGetSetFromCalculatedMember_disjoint() {
    final int ARITY = 2;
    List<Member> listColumn1 = new ArrayList<Member>();
    List<Member> listColumn2 = new ArrayList<Member>();
    listColumn1.add(new TestMember("elem1_col1"));
    listColumn1.add(new TestMember("elem2_col1"));
    listColumn2.add(new TestMember("elem1_col2"));
    listColumn2.add(new TestMember("elem2_col2"));
    final List<List<Member>> table = new ArrayList<List<Member>>();
    table.add(listColumn1);
    table.add(listColumn2);
    TupleConstraintStruct res = getCalculatedMember(table, ARITY);
    TupleList tuple = res.getDisjoinedTupleLists().get(0);
    // should be empty
    assertTrue(res.getMembers().isEmpty());
    assertEquals(tuple.getArity(), ARITY);
    assertEquals(tuple.get(0).get(0), listColumn1.get(0));
    assertEquals(tuple.get(0).get(1), listColumn1.get(1));
    assertEquals(tuple.get(1).get(0), listColumn2.get(0));
    assertEquals(tuple.get(1).get(1), listColumn2.get(1));
}
Also used : UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) TestMember(mondrian.olap.fun.TestMember) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) UnaryTupleList(mondrian.calc.impl.UnaryTupleList) TupleList(mondrian.calc.TupleList) List(java.util.List) Member(mondrian.olap.Member) TestMember(mondrian.olap.fun.TestMember)

Aggregations

TupleList (mondrian.calc.TupleList)3 TestMember (mondrian.olap.fun.TestMember)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 UnaryTupleList (mondrian.calc.impl.UnaryTupleList)2 Member (mondrian.olap.Member)2 Position (mondrian.olap.Position)1