summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpshi2011-11-17 01:50:20 (EST)
committer mwu2011-11-17 01:50:20 (EST)
commit5b0fc2804ef719bf96797229233bac7b0e20fdb3 (patch)
treebb3f7d10f2a06708acaabacba5bd0fc0017476b3
parent2d39ab8255db92bd27901a879b77d051bc63f984 (diff)
downloadorg.eclipse.birt-5b0fc2804ef719bf96797229233bac7b0e20fdb3.zip
org.eclipse.birt-5b0fc2804ef719bf96797229233bac7b0e20fdb3.tar.gz
org.eclipse.birt-5b0fc2804ef719bf96797229233bac7b0e20fdb3.tar.bz2
add unittest for 1371 project
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeFeaturesTest.java87
-rw-r--r--data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeFeaturesTest.testRelativeTimePeriod19.txt9
2 files changed, 96 insertions, 0 deletions
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeFeaturesTest.java b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeFeaturesTest.java
index 0c8c5e0..b139041 100644
--- a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeFeaturesTest.java
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/CubeFeaturesTest.java
@@ -8263,6 +8263,93 @@ public class CubeFeaturesTest extends BaseTestCase
}
/**
+ * add two time functions, one use fixed date, one use last member
+ * @throws Exception
+ */
+ public void testRelativeTimePeriod19() throws Exception
+ {
+
+ ICubeQueryDefinition cqd = new CubeQueryDefinition(DateCube.cubeName);
+
+ IEdgeDefinition rowEdge = cqd
+ .createEdge(ICubeQueryDefinition.COLUMN_EDGE);
+ IDimensionDefinition productLineDim1 = rowEdge
+ .createDimension("dimension2");
+ IHierarchyDefinition porductLineHie1 = productLineDim1
+ .createHierarchy("dimension2");
+ porductLineHie1.createLevel("level21");
+
+ IEdgeDefinition columnEdge = cqd
+ .createEdge(ICubeQueryDefinition.ROW_EDGE);
+ IDimensionDefinition dateDim = columnEdge.createDimension("dimension1");
+ IHierarchyDefinition dateHier = dateDim.createHierarchy("dimension1");
+
+ dateHier.createLevel("level11");
+ dateHier.createLevel("level12");
+ dateHier.createLevel("level13");
+ dateHier.createLevel("level14");
+ cqd.createMeasure("measure1");
+
+ TimeFunction timeFunction = new TimeFunction();
+ TimePeriod timePeriod = new TimePeriod(0, TimePeriodType.YEAR);
+ timeFunction.setReferenceDate(null);
+ timeFunction.setBaseTimePeriod(timePeriod);
+ timeFunction.setTimeDimension("dimension1");
+
+ IBinding binding2 = new Binding("measure1");
+ binding2.setExpression(new ScriptExpression("measure[\"measure1\"]"));
+
+ binding2.setTimeFunction(timeFunction);
+ binding2.setAggrFunction(IBuildInAggregation.TOTAL_SUM_FUNC);
+ binding2.addAggregateOn("dimension[\"dimension1\"][\"level11\"]");
+ binding2.addAggregateOn("dimension[\"dimension1\"][\"level12\"]");
+
+ cqd.addBinding(binding2);
+
+
+ timeFunction = new TimeFunction();
+ timePeriod = new TimePeriod(-2, TimePeriodType.QUARTER);
+ ReferenceDate referenceDate = new ReferenceDate(new GregorianCalendar(
+ 1998, 10, 20).getTime());
+ timeFunction.setReferenceDate(referenceDate);
+ timeFunction.setBaseTimePeriod(timePeriod);
+ timeFunction.setTimeDimension("dimension1");
+
+ Binding binding3 = new Binding("measure2");
+ binding3.setTimeFunction(timeFunction);
+ binding3.setAggrFunction(IBuildInAggregation.TOTAL_SUM_FUNC);
+ binding3.addAggregateOn("dimension[\"dimension1\"][\"level11\"]");
+ binding3.addAggregateOn("dimension[\"dimension1\"][\"level12\"]");
+ binding3.setExpression(new ScriptExpression("measure[\"measure1\"]"));
+
+ cqd.addBinding(binding3);
+
+ DateCube util = new DateCube();
+ DataEngineImpl engine = (DataEngineImpl) DataEngine
+ .newDataEngine(createPresentationContext());
+ util.createCube(engine);
+
+ ICube cube = util.getCube(DateCube.cubeName, engine);
+ BirtCubeView cubeView = new BirtCubeView(new CubeQueryExecutor(null,
+ cqd, engine.getSession(), new ImporterTopLevel(),
+ engine.getContext()), cube, null, null);
+
+ CubeCursor cursor = cubeView.getCubeCursor(new StopSign(), cube);
+
+ List columnEdgeBindingNames = new ArrayList();
+
+ List rowEdgeBindingNames = new ArrayList();
+
+ List measureNameList = new ArrayList<String>();
+ measureNameList.add( "measure1" );
+ measureNameList.add( "measure2" );
+ this.printCube1(cursor, columnEdgeBindingNames, rowEdgeBindingNames,
+ measureNameList );
+ engine.shutdown();
+ }
+
+
+ /**
* test previous N period function
*
* @throws Exception
diff --git a/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeFeaturesTest.testRelativeTimePeriod19.txt b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeFeaturesTest.testRelativeTimePeriod19.txt
new file mode 100644
index 0000000..e028c53
--- /dev/null
+++ b/data/org.eclipse.birt.data.tests/test/org/eclipse/birt/data/engine/olap/api/golden/CubeFeaturesTest.testRelativeTimePeriod19.txt
@@ -0,0 +1,9 @@
+
+39.0 1.0 39.0 1.0
+39.0 1.0 39.0 1.0
+13.0 13.0 13.0 13.0
+13.0 13.0 13.0 13.0
+88.0 65.0 88.0 65.0
+88.0 65.0 88.0 65.0
+88.0 65.0 88.0 65.0
+39.0 null 39.0 null \ No newline at end of file