Skip to content

Commit

Permalink
Added the eu network as dataset for JUnit tests. Created a JUnit test…
Browse files Browse the repository at this point in the history
… for the DatasetCreator class. (#3)
  • Loading branch information
MichaelRoeder committed Jan 10, 2018
1 parent 9631e69 commit 29fd3c8
Show file tree
Hide file tree
Showing 4 changed files with 25,637 additions and 0 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,9 @@
# Lemming
LEMMING is an ExaMple MImickiNg graph Generator


### Used data and software

Internally, Lemming is using the [Grph library](http://www.i3s.unice.fr/~hogie/software/index.php).

For testing, we are using the [email-Eu-core network](https://snap.stanford.edu/data/email-Eu-core.html) published by the Stanford University. It has been transformed into a simple RDF file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package org.aksw.simba.lemming.creation;

import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import org.aksw.simba.lemming.ColouredGraph;
import org.aksw.simba.lemming.creation.GraphCreator;
import org.apache.commons.io.IOUtils;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

@RunWith(Parameterized.class)
public class GraphCreatorTest {

@Parameters
public static Collection<Object[]> data() {
List<Object[]> testConfigs = new ArrayList<Object[]>();
testConfigs.add(new Object[] { "graph1.n3", 5, 5 });
testConfigs.add(new Object[] { "graph_loop.n3", 3, 5 });
testConfigs.add(new Object[] { "email-Eu-core.n3", 1005, 25571 });

return testConfigs;
}

private String graphFile;
private int expectedVertices;
private int expectedEdges;

public GraphCreatorTest(String graphFile, int expectedVertices, int expectedEdges) {
super();
this.graphFile = graphFile;
this.expectedVertices = expectedVertices;
this.expectedEdges = expectedEdges;
}

@Test
public void test() {
Model model = ModelFactory.createDefaultModel();
InputStream is = this.getClass().getClassLoader().getResourceAsStream(graphFile);
model.read(is, null, "N3");
IOUtils.closeQuietly(is);

GraphCreator creator = new GraphCreator();
ColouredGraph graph = creator.processModel(model);
Assert.assertNotNull(graph);
Assert.assertEquals(expectedVertices, graph.getVertices().size());
Assert.assertEquals(expectedVertices, graph.getVertexColours().size());
Assert.assertEquals(expectedEdges, graph.getEdgeColours().size());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static Collection<Object[]> data() {
List<Object[]> testConfigs = new ArrayList<Object[]>();
testConfigs.add(new Object[] { "graph1.n3", 1 });
testConfigs.add(new Object[] { "graph_loop.n3", 2 });
testConfigs.add(new Object[] { "email-Eu-core.n3", 105461 });

return testConfigs;
}
Expand Down
Loading

0 comments on commit 29fd3c8

Please sign in to comment.