@Test public void testOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col02 = loader.getGraphCollectionByVariables("g0", "g2"); GraphCollection col12 = loader.getGraphCollectionByVariables("g1", "g2"); GraphCollection result = col02.union(col12); GraphCollection expectation = loader .getGraphCollectionByVariables("g0", "g1", "g2"); checkAssertions(expectation, result, ""); }
@Test public void testNonOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col01 = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection col23 = loader.getGraphCollectionByVariables("g2", "g3"); GraphCollection result = col01.union(col23); GraphCollection expectation = loader .getGraphCollectionByVariables("g0", "g1", "g2", "g3"); checkAssertions(expectation, result, "non"); }
@Test public void testOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col02 = loader.getGraphCollectionByVariables("g0", "g2"); GraphCollection col12 = loader.getGraphCollectionByVariables("g1", "g2"); GraphCollection expectation = loader.getGraphCollectionByVariables("g0"); GraphCollection result = col02.difference(col12); checkAssertions(expectation, result, ""); result = col02.differenceWithSmallResult(col12); checkAssertions(expectation, result, "small"); }
@Test public void testOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col02 = loader.getGraphCollectionByVariables("g0", "g2"); GraphCollection col12 = loader.getGraphCollectionByVariables("g1", "g2"); GraphCollection expectation = loader.getGraphCollectionByVariables("g2"); GraphCollection result = col02.intersect(col12); checkAssertions(expectation, result, ""); result = col02.intersectWithSmallResult(col12); checkAssertions(expectation, result, "small"); }
@Test public void testNonOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col01 = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection col23 = loader.getGraphCollectionByVariables("g2", "g3"); GraphCollection result = col01.difference(col23); checkAssertions(col01, result, "non"); result = col01.differenceWithSmallResult(col23); checkAssertions(col01, result, "small non"); }
@Test public void testVertexOnlyTransformation() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString(testGraphString); GraphCollection inputCollection = loader .getGraphCollectionByVariables("g0", "g1"); GraphCollection expectedCollection = loader .getGraphCollectionByVariables("g03", "g13"); GraphCollection outputCollection = inputCollection .apply(new ApplyTransformation(null, TransformationTest::transformVertex, null)); collectAndAssertTrue( outputCollection.equalsByGraphData(expectedCollection)); }
@Test public void testGraphElementEquality() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString(asciiGraphs); GraphCollection searchSpace = loader.getGraphCollectionByVariables(searchSpaceVariables); GraphCollection expectation = loader.getGraphCollectionByVariables(expectedResultVariables); GraphCollection result = getImplementation().execute(searchSpace); collectAndAssertTrue(result.equalsByGraphElementData(expectation)); } }
@Test public void testGraphHeadOnlyTransformation() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString(testGraphString); GraphCollection inputCollection = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection expectedCollection = loader.getGraphCollectionByVariables("g02", "g12"); GraphCollection outputCollection = inputCollection .apply(new ApplyTransformation(TransformationTest::transformGraphHead, null, null)); collectAndAssertTrue( outputCollection.equalsByGraphData(expectedCollection)); }
@Test public void testNonOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col01 = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection col23 = loader.getGraphCollectionByVariables("g2", "g3"); GraphCollection expectation = getConfig().getGraphCollectionFactory().createEmptyCollection(); GraphCollection result = col01.intersect(col23); checkAssertions(expectation, result, "non"); result = col01.intersectWithSmallResult(col23); checkAssertions(expectation, result, "small non"); }
@Test public void testSameCollection() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); int limit = 2; GraphCollection input = loader.getGraphCollectionByVariables("g0", "g1"); collectAndAssertTrue(input.equalsByGraphElementData(input.limit(limit))); }
@Test public void testFromGraphMethod() throws Exception { GraphCollection expected = loader.getGraphCollectionByVariables("g0"); GraphCollection result = factory.fromGraph(loader.getLogicalGraphByVariable("g0")); collectAndAssertTrue(expected.equalsByGraphElementData(result)); }
@Test public void testSingleFromGraphsMethod() throws Exception { GraphCollection expected = loader.getGraphCollectionByVariables("g0"); GraphCollection result = factory.fromGraphs(loader.getLogicalGraphByVariable("g0")); collectAndAssertTrue(result.equalsByGraphElementData(expected)); }
@Test public void testTotalOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection expectation = loader .getGraphCollectionByVariables("g0", "g1"); GraphCollection result = expectation.intersect(expectation); checkAssertions(expectation, result, "total"); result = expectation.intersectWithSmallResult(expectation); checkAssertions(expectation, result, "small total"); } }
@Test public void testInBound() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); int limit = 2; GraphCollection inputCollection = loader.getGraphCollectionByVariables("g0", "g1", "g2", "g3"); GraphCollection outputCollection = inputCollection.limit(limit); assertEquals(limit, outputCollection.getGraphHeads().count()); }
@Test public void testOutOfBound() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection inputCollection = loader.getGraphCollectionByVariables("g0", "g1"); int limit = 4; int expectedCount = 2; GraphCollection outputCollection = inputCollection.limit(limit); assertEquals(expectedCount, outputCollection.getGraphHeads().count()); }
@Test public void testFromGraphsMethod() throws Exception { LogicalGraph graph1 = loader.getLogicalGraphByVariable("g1"); LogicalGraph graph2 = loader.getLogicalGraphByVariable("g2"); GraphCollection expected = loader.getGraphCollectionByVariables("g1", "g2"); GraphCollection result = factory.fromGraphs(graph1, graph2); collectAndAssertTrue(result.equalsByGraphElementData(expected)); } }
@Test public void testGraphElementIdEquality() throws Exception { FlinkAsciiGraphLoader loader = getLoaderFromString(dataGraph); // initialize with data graph LogicalGraph db = loader.getLogicalGraphByVariable(TestData.DATA_GRAPH_VARIABLE); // append the expected result loader.appendToDatabaseFromString(expectedCollection); // execute and validate GraphCollection result = getImplementation(queryGraph, false).execute(db); GraphCollection expected = loader.getGraphCollectionByVariables(expectedGraphVariables); collectAndAssertTrue(result.equalsByGraphElementIds(expected)); }
@Test public void testTotalOverlappingCollections() throws Exception { FlinkAsciiGraphLoader loader = getSocialNetworkLoader(); GraphCollection col01 = loader.getGraphCollectionByVariables("g0", "g1"); GraphCollection expectation = getConfig().getGraphCollectionFactory().createEmptyCollection(); GraphCollection result = col01.difference(col01); checkAssertions(expectation, result, "total"); result = col01.differenceWithSmallResult(col01); checkAssertions(expectation, result, "small total"); } }
@Test public void testRead() throws Exception { String csvPath = getFilePath("/data/csv/input_graph_collection"); String gdlPath = getFilePath("/data/csv/expected/expected_graph_collection.gdl"); DataSource dataSource = new CSVDataSource(csvPath, getConfig()); GraphCollection input = dataSource.getGraphCollection(); GraphCollection expected = getLoaderFromFile(gdlPath) .getGraphCollectionByVariables("expected1", "expected2"); collectAndAssertTrue(input.equalsByGraphElementData(expected)); }
@Test public void testExecute() throws Exception { FlinkAsciiGraphLoader loader = new FlinkAsciiGraphLoader(getConfig()); loader.initDatabaseFromFile(getFilePath("/data/gdl/iig_btgs.gdl")); LogicalGraph iig = loader.getLogicalGraphByVariable("iig"); GraphCollection expectation = loader .getGraphCollectionByVariables("btg1", "btg2", "btg3", "btg4"); GraphCollection result = iig .callForCollection(new BusinessTransactionGraphs()); collectAndAssertTrue(expectation.equalsByGraphElementData(result)); } }