Permalink
Browse files

[#1027] Fixes to unit tests (#1034)

fixes #1027
  • Loading branch information...
0x002A authored and galpha committed Oct 13, 2018
1 parent 748f8c0 commit ae0ff4d5941844f8c8921d2a15d3bc352e40fc7d
Showing with 142 additions and 152 deletions.
  1. +7 −2 gradoop-common/src/test/java/org/gradoop/common/util/AsciiGraphLoaderTest.java
  2. +5 −1 gradoop-examples/src/main/java/org/gradoop/examples/aggregation/AggregationExample.java
  3. +0 −1 gradoop-examples/src/main/java/org/gradoop/examples/biiig/CategoryCharacteristicPatterns.java
  4. +5 −2 gradoop-examples/src/main/java/org/gradoop/examples/biiig/FrequentLossPatterns.java
  5. +5 −1 gradoop-examples/src/main/java/org/gradoop/examples/patternmatching/CypherExample.java
  6. +5 −8 gradoop-examples/src/main/java/org/gradoop/examples/subgraph/SubgraphExample.java
  7. +1 −1 ...c/main/java/org/gradoop/flink/model/impl/operators/tostring/functions/ConcatGraphHeadStrings.java
  8. +1 −3 gradoop-flink/src/test/java/org/gradoop/flink/algorithms/btgs/BusinessTransactionGraphsTest.java
  9. +4 −2 ...p-flink/src/test/java/org/gradoop/flink/datagen/transactions/foodbroker/FoodBrokerConfigTest.java
  10. +2 −3 gradoop-flink/src/test/java/org/gradoop/flink/datagen/transactions/foodbroker/FoodBrokerTest.java
  11. +2 −6 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/csv/CSVDataSinkTest.java
  12. +3 −10 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/csv/CSVDataSourceTest.java
  13. +1 −3 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/csv/conversion/LogicalGraphCSVToCSVTest.java
  14. +1 −3 ...flink/src/test/java/org/gradoop/flink/io/impl/csv/conversion/LogicalGraphIndexedCSVToCSVTest.java
  15. +2 −5 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/csv/indexed/IndexedCSVDataSinkTest.java
  16. +6 −19 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/csv/indexed/IndexedCSVDataSourceTest.java
  17. +3 −6 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/deprecated/json/JSONDataSourceTest.java
  18. +1 −1 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/dot/DOTDataSinkTest.java
  19. +2 −4 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/edgelist/EdgeListDataSourceTest.java
  20. +2 −4 ...p-flink/src/test/java/org/gradoop/flink/io/impl/edgelist/VertexLabeledEdgeListDataSourceTest.java
  21. +36 −40 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/tlf/TLFDataSinkTest.java
  22. +5 −10 gradoop-flink/src/test/java/org/gradoop/flink/io/impl/tlf/TLFDataSourceTest.java
  23. +14 −0 gradoop-flink/src/test/java/org/gradoop/flink/model/GradoopFlinkTestBase.java
  24. +7 −3 .../gradoop/flink/model/impl/operators/matching/common/statistics/GraphStatisticsHDFSReaderTest.java
  25. +6 −1 ...adoop/flink/model/impl/operators/matching/common/statistics/GraphStatisticsLocalFSReaderTest.java
  26. +1 −1 ...c/test/java/org/gradoop/flink/model/impl/operators/matching/single/cypher/QueryEngineITTests.java
  27. +6 −2 ...doop/flink/model/impl/operators/matching/single/cypher/planning/estimation/EstimatorTestBase.java
  28. +4 −8 ...est/java/org/gradoop/flink/model/impl/operators/tostring/CanonicalAdjacencyMatrixBuilderTest.java
  29. +5 −2 ...oop-store/gradoop-accumulo/src/test/java/org/gradoop/storage/impl/accumulo/AccumuloTestSuite.java
@@ -22,6 +22,8 @@
import org.gradoop.common.model.impl.pojo.Vertex;
import org.junit.Test;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.Collection;
import static org.junit.Assert.*;
@@ -42,7 +44,9 @@ public void testFromString() throws Exception {
@Test
public void testFromFile() throws Exception {
String file = getClass().getResource("/data/gdl/example.gdl").getFile();
String file = URLDecoder.decode(
getClass().getResource("/data/gdl/example.gdl").getFile(),
StandardCharsets.UTF_8.name());
AsciiGraphLoader<GraphHead, Vertex, Edge> asciiGraphLoader =
AsciiGraphLoader.fromFile(file, config);
@@ -59,7 +63,8 @@ public void testGetGraphHeads() throws Exception {
validateCaches(asciiGraphLoader, 0, 0, 0);
for (GraphHead graphHead : asciiGraphLoader.getGraphHeads()) {
assertEquals("Graph has wrong label",
assertEquals(
"Graph has wrong label",
GradoopConstants.DEFAULT_GRAPH_LABEL, graphHead.getLabel());
}
}
@@ -15,6 +15,9 @@
*/
package org.gradoop.examples.aggregation;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.gradoop.examples.aggregation.functions.AddPropertyMeanAgeToGraphHead;
import org.gradoop.examples.aggregation.functions.AggregateListOfNames;
@@ -75,7 +78,8 @@ public static void main(String[] args) throws Exception {
FlinkAsciiGraphLoader loader = new FlinkAsciiGraphLoader(GradoopFlinkConfig.createConfig(env));
// load data
loader.initDatabaseFromFile(EXAMPLE_DATA_FILE);
loader.initDatabaseFromFile(
URLDecoder.decode(EXAMPLE_DATA_FILE, StandardCharsets.UTF_8.name()));
// get LogicalGraph representation of the social network graph
LogicalGraph networkGraph = loader.getLogicalGraph();
@@ -35,7 +35,6 @@
import org.gradoop.flink.util.GradoopFlinkConfig;
import java.io.IOException;
import static org.gradoop.flink.algorithms.btgs.BusinessTransactionGraphs.SOURCEID_KEY;
import static org.gradoop.flink.algorithms.btgs.BusinessTransactionGraphs.SUPERCLASS_VALUE_MASTER;
import static org.gradoop.flink.algorithms.btgs.BusinessTransactionGraphs.SUPERCLASS_VALUE_TRANSACTIONAL;
@@ -35,6 +35,8 @@
import org.gradoop.flink.model.impl.operators.transformation.ApplyTransformation;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import static java.math.BigDecimal.ROUND_HALF_UP;
import static java.math.BigDecimal.ZERO;
@@ -150,8 +152,9 @@ public static void main(String[] args) throws Exception {
// (1) read data from source
String csvPath = FrequentLossPatterns.class
.getResource("/data/csv/foodbroker").getFile();
String csvPath = URLDecoder.decode(
FrequentLossPatterns.class.getResource("/data/csv/foodbroker").getFile(),
StandardCharsets.UTF_8.name());
LogicalGraph iig = readLogicalGraph(csvPath);
@@ -15,6 +15,9 @@
*/
package org.gradoop.examples.patternmatching;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import org.apache.flink.api.java.ExecutionEnvironment;
import org.gradoop.flink.io.impl.csv.CSVDataSource;
import org.gradoop.flink.model.api.epgm.GraphCollection;
@@ -51,7 +54,8 @@ public static void main(String[] args) throws Exception {
// create a Gradoop config
GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(env);
// create a datasource
CSVDataSource csvDataSource = new CSVDataSource(DATA_PATH, config);
CSVDataSource csvDataSource = new CSVDataSource(
URLDecoder.decode(DATA_PATH, StandardCharsets.UTF_8.name()), config);
// load graph statistics
GraphStatistics statistics = GraphStatisticsLocalFSReader.read(STATISTICS_PATH);
@@ -25,6 +25,8 @@
import org.gradoop.flink.model.impl.functions.epgm.ByLabel;
import org.gradoop.flink.model.impl.functions.epgm.ByProperty;
import org.gradoop.flink.util.GradoopFlinkConfig;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
/**
* An example for the subgraph operator using combined filter functions.
@@ -33,13 +35,6 @@
* @see org.gradoop.flink.model.impl.functions.filters.CombinableFilter
*/
public class SubgraphExample {
/**
* Path of the input graph.
*/
private static final String DATA_PATH =
SubgraphExample.class.getResource("/data/csv/sna").getFile();
/**
* Run an example subgraph operation on the example social media graph.
*
@@ -52,7 +47,9 @@ public static void main(String[] args) throws Exception {
// Create Gradoop config.
GradoopFlinkConfig config = GradoopFlinkConfig.createConfig(executionEnvironment);
// Read the input graph.
LogicalGraph inputGraph = new CSVDataSource(DATA_PATH, config).getLogicalGraph();
LogicalGraph inputGraph = new CSVDataSource(
URLDecoder.decode(SubgraphExample.class.getResource("/data/csv/sna").getFile(),
StandardCharsets.UTF_8.name()), config).getLogicalGraph();
// Create a filter for vertices accepting:
// 1. Vertices with label "Forum" and a property "title" set to "Graph Processing"
@@ -46,6 +46,6 @@ public void reduce(Iterable<GraphHeadString> graphHeadLabels,
Collections.sort(graphLabels);
collector.collect(StringUtils.join(graphLabels, "\n"));
collector.collect(StringUtils.join(graphLabels, System.lineSeparator()));
}
}
@@ -28,9 +28,7 @@ public void testExecute() throws Exception {
FlinkAsciiGraphLoader loader = new FlinkAsciiGraphLoader(getConfig());
loader.initDatabaseFromFile(
BusinessTransactionGraphsTest.class
.getResource("/data/gdl/iig_btgs.gdl").getFile());
loader.initDatabaseFromFile(getFilePath("/data/gdl/iig_btgs.gdl"));
LogicalGraph iig = loader.getLogicalGraphByVariable("iig");
@@ -22,7 +22,9 @@
import org.gradoop.flink.model.GradoopFlinkTestBase;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.List;
import org.junit.Test;
@@ -104,8 +106,8 @@ public void testGetDecimalVariationConfigurationValue()
assertEquals(-0.01f, result, 0.00001f);
}
private String getConfigPath() throws URISyntaxException {
return FoodBroker.class.getResource("/foodbroker/config.json").getFile();
private String getConfigPath() throws URISyntaxException, UnsupportedEncodingException {
return getFilePath("/foodbroker/config.json");
}
@Test
@@ -136,7 +136,7 @@ public void testMaxEdgeCount() throws IOException, JSONException {
@Test
public void testLargeSetStatistics() throws Exception {
String configPath = FoodBroker.class.getResource("/foodbroker/config.json").getFile();
String configPath = getFilePath("/foodbroker/config.json");
FoodBrokerConfig config = FoodBrokerConfig.fromFile(configPath);
@@ -248,8 +248,7 @@ public void testSchema() throws Exception {
private void generateCollection() throws IOException, JSONException {
if (cases == null) {
String configPath =
FoodBrokerTest.class.getResource("/foodbroker/config.json").getFile();
String configPath = getFilePath("/foodbroker/config.json");
FoodBrokerConfig config = FoodBrokerConfig.fromFile(configPath);
@@ -187,13 +187,9 @@ public void testWriteWithDelimiterCharacters() throws Exception {
public void testWriteWithExistingMetaData() throws Exception {
String tmpPath = temporaryFolder.getRoot().getPath();
String csvPath = CSVDataSinkTest.class
.getResource("/data/csv/input_graph_collection")
.getFile();
String csvPath = getFilePath("/data/csv/input_graph_collection");
String gdlPath = CSVDataSinkTest.class
.getResource("/data/csv/expected/expected_graph_collection.gdl")
.getFile();
String gdlPath = getFilePath("/data/csv/expected/expected_graph_collection.gdl");
LogicalGraph input = getLoaderFromFile(gdlPath).getLogicalGraphByVariable("expected");
@@ -16,7 +16,6 @@
package org.gradoop.flink.io.impl.csv;
import org.gradoop.flink.io.api.DataSource;
import org.gradoop.flink.io.impl.edgelist.VertexLabeledEdgeListDataSourceTest;
import org.gradoop.flink.model.api.epgm.GraphCollection;
import org.gradoop.flink.model.api.epgm.LogicalGraph;
import org.junit.Test;
@@ -25,13 +24,9 @@
@Test
public void testRead() throws Exception {
String csvPath = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/csv/input_graph_collection")
.getFile();
String csvPath = getFilePath("/data/csv/input_graph_collection");
String gdlPath = CSVDataSourceTest.class
.getResource("/data/csv/expected/expected_graph_collection.gdl")
.getFile();
String gdlPath = getFilePath("/data/csv/expected/expected_graph_collection.gdl");
DataSource dataSource = new CSVDataSource(csvPath, getConfig());
GraphCollection input = dataSource.getGraphCollection();
@@ -51,9 +46,7 @@ public void testRead() throws Exception {
public void testReadExtendedProperties() throws Exception {
LogicalGraph expected = getExtendedLogicalGraph();
String csvPath = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/csv/input_extended_properties")
.getFile();
String csvPath = getFilePath("/data/csv/input_extended_properties");
DataSource dataSource = new CSVDataSource(csvPath, getConfig());
LogicalGraph sourceLogicalGraph = dataSource.getLogicalGraph();
@@ -41,9 +41,7 @@
*/
@Test
public void testConversion() throws Exception {
String csvPath = LogicalGraphCSVToCSVTest.class
.getResource("/data/csv/input_deprecated")
.getFile();
String csvPath = getFilePath("/data/csv/input_deprecated");
DataSource logicalGraphCSVDataSource = new LogicalGraphCSVDataSource(csvPath, getConfig());
@@ -41,9 +41,7 @@
*/
@Test
public void testConversion() throws Exception {
String csvPath = LogicalGraphCSVToCSVTest.class
.getResource("/data/csv/input_indexed_deprecated")
.getFile();
String csvPath = getFilePath("/data/csv/input_indexed_deprecated");
DataSource lgIndexedCSVDataSource = new LogicalGraphIndexedCSVDataSource(csvPath, getConfig());
@@ -28,7 +28,6 @@
import org.gradoop.common.model.impl.properties.PropertyValue;
import org.gradoop.flink.io.api.DataSink;
import org.gradoop.flink.io.api.DataSource;
import org.gradoop.flink.io.impl.edgelist.VertexLabeledEdgeListDataSourceTest;
import org.gradoop.flink.model.GradoopFlinkTestBase;
import org.gradoop.flink.model.api.epgm.GraphCollection;
import org.gradoop.flink.model.api.epgm.LogicalGraph;
@@ -270,11 +269,9 @@ public void testWriteWithEmptyLabel() throws Exception {
public void testWriteWithExistingMetaData() throws Exception {
String tmpPath = temporaryFolder.getRoot().getPath();
String csvPath = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/csv/input_indexed").getFile();
String csvPath = getFilePath("/data/csv/input_indexed");
String gdlPath = IndexedCSVDataSourceTest.class
.getResource("/data/csv/expected/expected_graph_collection.gdl").getFile();
String gdlPath = getFilePath("/data/csv/expected/expected_graph_collection.gdl");
GraphCollection input = getLoaderFromFile(gdlPath).getGraphCollectionByVariables("expected1",
"expected2");
@@ -16,7 +16,6 @@
package org.gradoop.flink.io.impl.csv.indexed;
import org.gradoop.flink.io.api.DataSource;
import org.gradoop.flink.io.impl.edgelist.VertexLabeledEdgeListDataSourceTest;
import org.gradoop.flink.model.GradoopFlinkTestBase;
import org.gradoop.flink.model.api.epgm.GraphCollection;
import org.gradoop.flink.model.api.epgm.LogicalGraph;
@@ -35,13 +34,9 @@
*/
@Test
public void testRead() throws Exception {
String csvPath = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/csv/input_indexed")
.getFile();
String csvPath = getFilePath("/data/csv/input_indexed");
String gdlPath = IndexedCSVDataSourceTest.class
.getResource("/data/csv/expected/expected_graph_collection.gdl")
.getFile();
String gdlPath = getFilePath("/data/csv/expected/expected_graph_collection.gdl");
DataSource dataSource = new IndexedCSVDataSource(csvPath, getConfig());
GraphCollection input = dataSource.getGraphCollection();
@@ -59,13 +54,9 @@ public void testRead() throws Exception {
*/
@Test
public void testReadSingleGraph() throws Exception {
String csvPath = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/csv/input_indexed")
.getFile();
String csvPath = getFilePath("/data/csv/input_indexed");
String gdlPath = IndexedCSVDataSourceTest.class
.getResource("/data/csv/expected/expected_graph_collection.gdl")
.getFile();
String gdlPath = getFilePath("/data/csv/expected/expected_graph_collection.gdl");
DataSource dataSource = new IndexedCSVDataSource(csvPath, getConfig());
LogicalGraph input = dataSource.getLogicalGraph();
@@ -84,13 +75,9 @@ public void testReadSingleGraph() throws Exception {
*/
@Test
public void testEmptyEdgeRead() throws Exception {
String csvPath = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/csv/input_indexed_no_edges")
.getFile();
String csvPath = getFilePath("/data/csv/input_indexed_no_edges");
String gdlPath = IndexedCSVDataSourceTest.class
.getResource("/data/csv/expected/expected_no_edges.gdl")
.getFile();
String gdlPath = getFilePath("/data/csv/expected/expected_no_edges.gdl");
DataSource dataSource = new IndexedCSVDataSource(csvPath, getConfig());
GraphCollection input = dataSource.getGraphCollection();
@@ -33,12 +33,9 @@
@Test
public void testRead() throws Exception {
String graphFile =
JSONDataSourceTest.class.getResource("/data/json/sna/graphs.json").getFile();
String vertexFile =
JSONDataSourceTest.class.getResource("/data/json/sna/nodes.json").getFile();
String edgeFile =
JSONDataSourceTest.class.getResource("/data/json/sna/edges.json").getFile();
String graphFile = getFilePath("/data/json/sna/graphs.json");
String vertexFile = getFilePath("/data/json/sna/nodes.json");
String edgeFile = getFilePath("/data/json/sna/edges.json");
DataSource dataSource = new JSONDataSource(graphFile, vertexFile, edgeFile, getConfig());
@@ -36,7 +36,7 @@
@Test
public void testWrite() throws Exception {
String gdlFile = DOTDataSinkTest.class.getResource("/data/dot/input.gdl").getFile();
String gdlFile = getFilePath("/data/dot/input.gdl");
// load from gdl
FlinkAsciiGraphLoader loader = getLoaderFromFile(gdlFile);
@@ -25,10 +25,8 @@
@Test
public void testRead() throws Exception {
String edgeListFile = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/edgelist/basic/input").getFile();
String gdlFile = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/edgelist/basic/expected.gdl").getFile();
String edgeListFile = getFilePath("/data/edgelist/basic/input");
String gdlFile = getFilePath("/data/edgelist/basic/expected.gdl");
DataSource dataSource = new EdgeListDataSource(edgeListFile, ",", getConfig());
LogicalGraph result = dataSource.getLogicalGraph();
@@ -25,10 +25,8 @@
@Test
public void testRead() throws Exception {
String edgeListFile = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/edgelist/vertexlabeled/input").getFile();
String gdlFile = VertexLabeledEdgeListDataSourceTest.class
.getResource("/data/edgelist/vertexlabeled/expected.gdl").getFile();
String edgeListFile = getFilePath("/data/edgelist/vertexlabeled/input");
String gdlFile = getFilePath("/data/edgelist/vertexlabeled/expected.gdl");
DataSource dataSource = new VertexLabeledEdgeListDataSource(edgeListFile, " ", "lan", getConfig());
LogicalGraph result = dataSource.getLogicalGraph();
Oops, something went wrong.

0 comments on commit ae0ff4d

Please sign in to comment.