@Test public final void testGetHierarchyRootMembers() throws SaikuOlapException { List<SaikuMember> rootMembers = olapMetaExplorer.getHierarchyRootMembers( olapMetaExplorer.getAllCubes().get(0), "Department"); assertNotNull(rootMembers); }
/** * Test to make sure you can get a single dimension in a cube. * * @throws SaikuOlapException */ @Test public final void testGetDimensionNull() throws SaikuOlapException { List<SaikuCube> cubes = olapMetaExplorer.getAllCubes(); SaikuDimension dim = olapMetaExplorer.getDimension(cubes.get(0), "No dimension"); assertNull(dim); }
@Test public final void testGetMember() throws SaikuOlapException { SaikuMember member = olapMetaExplorer.getMember( olapMetaExplorer.getAllCubes().get(0), "[Department].[All Departments]"); assertNotNull(member); assertEquals("[Department].[Department].[All Departments]", member.getUniqueName()); }
@Test public final void testGetAllMeasures() throws SaikuOlapException { List<SaikuMember> members = olapMetaExplorer.getAllMeasures(olapMetaExplorer.getAllCubes().get(0)); assertNotNull(members); assertEquals(5, members.size()); }
@Test public final void testGetHierarchy() throws SaikuOlapException { SaikuHierarchy hier = olapMetaExplorer.getHierarchy(olapMetaExplorer.getAllCubes().get(0), "Department"); assertNotNull(hier); assertEquals("Department", hier.getName()); }
/** * Test to make sure you can get all the dimensions in a cube. * * @throws SaikuOlapException */ @Test public final void testGetAllDimensions() throws SaikuOlapException { List<SaikuCube> cubes = olapMetaExplorer.getAllCubes(); List<SaikuDimension> dims = olapMetaExplorer.getAllDimensions(cubes.get(0)); assertNotNull(dims); assertEquals(4, dims.size()); }
@Test public final void testGetAllMembers() throws SaikuOlapException { List<SimpleCubeElement> members = olapMetaExplorer.getAllMembers( olapMetaExplorer.getAllCubes().get(0), "Department", "Department Description"); assertNotNull(members); assertEquals(12, members.size()); }
@Test public final void testGetAllHierarchies() throws SaikuOlapException { List<SaikuHierarchy> hier = olapMetaExplorer.getAllHierarchies(olapMetaExplorer.getAllCubes().get(0)); assertNotNull(hier); assertEquals(21, hier.size()); }
@Test public final void testGetAllLevelsUniqueNameHierarchy() throws SaikuOlapException { List<SaikuLevel> levels = olapMetaExplorer.getAllLevels( olapMetaExplorer.getAllCubes().get(0), "Department", "[Department].[Department]"); assertNotNull(levels); assertEquals(2, levels.size()); }
/** * Test to make sure you can get a single dimension in a cube. * * @throws SaikuOlapException */ @Test public final void testGetDimension() throws SaikuOlapException { List<SaikuCube> cubes = olapMetaExplorer.getAllCubes(); SaikuDimension dim = olapMetaExplorer.getDimension(cubes.get(0), "Department"); assertNotNull(dim); assertEquals("Department", dim.getName()); }
@Test public final void testGetMemberChildren() throws SaikuOlapException { List<SaikuMember> members = olapMetaExplorer.getMemberChildren( olapMetaExplorer.getAllCubes().get(0), "[Department].[All Departments]"); assertNotNull(members); assertEquals(12, members.size()); }
@Test public final void testGetAllMembersUniqueNameLevel() throws SaikuOlapException { List<SimpleCubeElement> members = olapMetaExplorer.getAllMembers( olapMetaExplorer.getAllCubes().get(0), "Department", "[Department].[Department].[(All)]"); assertNotNull(members); assertEquals(1, members.size()); }
/** * Test that you can get a single connection. * * @throws SaikuOlapException */ @Test public final void testGetConnectionSuccess() throws SaikuOlapException { SaikuConnection output = olapMetaExplorer.getConnection("test"); assertNotNull(output); assertEquals("test", output.getName()); }
/** Make sure you can grab a cube from a specified connection. */ @Test public final void testGetCubesSingleConnection() throws SaikuOlapException { List<SaikuCube> output = olapMetaExplorer.getCubes("test"); assertNotNull(output); assertEquals("HR", output.get(0).getName()); }
/** * Test that you can fetch all available connections. * * @throws SaikuOlapException */ @Test public final void testGetAllConnections() throws SaikuOlapException { List<SaikuConnection> output = olapMetaExplorer.getAllConnections(); assertNotNull(output); assertEquals(1, output.size()); assertEquals("test", output.get(0).getName()); }
/** Make sure you can grab a cube from a specified connection. */ @Test public final void testGetCubesMultipleConnections() throws SaikuOlapException { List<String> cubes = new ArrayList<>(); cubes.add("test"); List<SaikuCube> output = olapMetaExplorer.getCubes(cubes); assertNotNull(output); assertEquals("HR", output.get(0).getName()); }
@Test public final void testGetConnections() throws SaikuOlapException { List<String> list = new ArrayList<>(); list.add("test"); List<SaikuConnection> connections = olapMetaExplorer.getConnections(list); assertNotNull(connections); assertEquals("test", connections.get(0).getName()); }
/** * Test what happens when you call an non existant connection. * * @throws SaikuOlapException */ @Test public final void testGetConnectionFailure() throws SaikuOlapException { SaikuConnection output = null; try { output = olapMetaExplorer.getConnection("noname"); } catch (Exception e) { // Connection Failure shouldn't throw an NPE it should throw a nicer error. assertEquals("Cannot find connection: (noname)", e.getMessage()); } assertNull(output); }
/** Test to make sure that the cubes are returned in the same order. */ @Test public final void testCubeReturnOrder() throws SaikuOlapException { List<SaikuCube> output = olapMetaExplorer.getAllCubes(); assertNotNull(output); List<String> names = Arrays.asList("HR", "Sales", "Sales 2", "Store", "Warehouse", "Warehouse and Sales"); List<String> actual = new ArrayList<>(); for (SaikuCube cube : output) { actual.add(cube.getName()); } assertEquals(names, actual); }
/** Test to make sure you can retrieve all the cubes from a schema. */ @Test public final void testGetAllCubes() throws SaikuOlapException { List<SaikuCube> output = olapMetaExplorer.getAllCubes(); assertNotNull(output); assertEquals(6, output.size()); for (SaikuCube anOutput : output) { assertEquals("FoodMart", anOutput.getCatalog()); anOutput.getName(); assertEquals("test", anOutput.getConnection()); assertEquals("FoodMart", anOutput.getSchema()); assertThat(anOutput.getUniqueName(), startsWith("[test].[FoodMart].[FoodMart].")); } }
@Test public void testQuery() { List<SaikuCube> cubes = olapMetaExplorer.getAllCubes(); SaikuCube salesCube = null; for (SaikuCube cube : cubes) { if (cube.getCubeName().equals("[TF_CUBE]")) { salesCube = cube; } } Assert.assertNotNull(salesCube); final UUID query = UUID.randomUUID(); olapQueryService.createNewOlapQuery(query.toString(), salesCube); // final String mdx = "SELECT {Hierarchize({[Measures].[Show Cnt]})} ON COLUMNS, " + // "CrossJoin([Time].[Year].Members, " + // "CrossJoin([Regions].[Region].Members, " + // "[WInfo].[Account].Members)) ON ROWS " + // "FROM [TF_CUBE]"; final String mdx = "SELECT {Hierarchize({[Measures].[Show Cnt]})} ON COLUMNS," + "Hierarchize(Union(CrossJoin({[Time].[2011]}, CrossJoin([Regions].[Region].Members, " + "{[WInfo].[张三的帐户].[张三的计划A].[张三的单元A].[张三买的关键词A2]})), CrossJoin({[Time].[2011]}, " + "CrossJoin([Regions].[Region].Members, {[WInfo].[张三的帐户].[张三的计划A].[张三的单元B].[张三买的关键词B1]})))) ON ROWS " + "FROM [TF_CUBE]"; CellDataSet cds = olapQueryService.executeMdx(query.toString(), mdx); LOGGER.info("Execute MDX[" + mdx + "] result : " + ToStringBuilder.reflectionToString(cds)); sleep(2000L); cds = olapQueryService.executeMdx(query.toString(), mdx); LOGGER.info("Execute MDX[" + mdx + "] result : " + ToStringBuilder.reflectionToString(cds)); final String mdx2 = "SELECT {Hierarchize({[Measures].[Show Cnt]})} ON COLUMNS," + "Hierarchize(CrossJoin({[Time].[2011]}, CrossJoin([Regions].[东北], " + "{[WInfo].[张三的帐户].[张三的计划A].[张三的单元A].[张三买的关键词A2]}))) ON ROWS " + "FROM [TF_CUBE]"; cds = olapQueryService.executeMdx(query.toString(), mdx2); LOGGER.info("Execute MDX[" + mdx2 + "] result : " + ToStringBuilder.reflectionToString(cds)); sleep(2000L); cds = olapQueryService.executeMdx(query.toString(), mdx2); LOGGER.info("Execute MDX[" + mdx2 + "] result : " + ToStringBuilder.reflectionToString(cds)); // sleep(2000L); // // // Concurrent execute // int threadPoolSize = 10; // ScheduledExecutorService ses = Executors.newScheduledThreadPool(threadPoolSize); // for (int i = 0; i < threadPoolSize; i++) { // ses.scheduleAtFixedRate(new Runnable() { // // @Override // public void run() { // CellDataSet scheduleCds = olapQueryService.executeMdx(query.toString(), mdx); // LOGGER.info("Schedule execute MDX[" + mdx + "] result : " + // ToStringBuilder.reflectionToString(scheduleCds)); // } // // }, 1000, executeCostTime + 1000, TimeUnit.MILLISECONDS); // } // // sleep(10000L); // ses.shutdown(); }
@Test public final void testGetNativeConnection() throws SaikuOlapException { OlapConnection output = olapMetaExplorer.getNativeConnection("test"); assertNotNull(output); }