Skip to content

Commit

Permalink
Make unit tests delete graphs when done
Browse files Browse the repository at this point in the history
  • Loading branch information
weisenje committed Feb 27, 2023
1 parent a51a067 commit 7bf08cb
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@
import java.math.BigInteger;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.UUID;

Expand Down Expand Up @@ -80,6 +79,7 @@ public static void setup() throws Exception {

@AfterClass
public static void teardown() throws Exception {
IntegrationTestUtility.clearGraph(resultSei);
// delete stored nodegroup when done with all tests
nodeGroupStoreClient.deleteStoredNodeGroupIfExists(ID);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package com.ge.research.semtk.fdccache.test;

import static org.junit.Assert.*;
import static org.junit.Assume.assumeTrue;

import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

Expand All @@ -28,13 +28,15 @@
import com.ge.research.semtk.load.utility.SparqlGraphJson;
import com.ge.research.semtk.resultSet.Table;
import com.ge.research.semtk.sparqlX.SparqlConnection;
import com.ge.research.semtk.sparqlX.SparqlEndpointInterface;
import com.ge.research.semtk.test.IntegrationTestUtility;
import com.ge.research.semtk.test.TestGraph;
import com.ge.research.semtk.utility.Utility;

public class FdcCacheSpecRunnerTest_IT {
private final static String CREATOR = "Junit CacheSpecRunnerTest_IT.java";
private static SparqlConnection cacheConn = null;
private static SparqlEndpointInterface cacheSei;

@BeforeClass
public static void setup() throws Exception {
Expand All @@ -56,10 +58,16 @@ public static void setup() throws Exception {
// create a connection for caching: TestGraph stuff and model in model[0]. Cache in data[0].
cacheConn = SparqlConnection.deepCopy(TestGraph.getSparqlConn());
cacheConn.clearDataInterfaces();
cacheConn.addDataInterface(TestGraph.getSei(TestGraph.generateGraphName("cache")));
cacheSei = TestGraph.getSei(TestGraph.generateGraphName("cache"));
cacheConn.addDataInterface(cacheSei);
cacheConn.getDataInterface(0).clearGraph();
}

@AfterClass
public static void cleanup() throws Exception {
IntegrationTestUtility.clearGraph(cacheSei);
}

@Test
public void testSimple() throws Exception {
cacheConn.getDataInterface(0).clearGraph();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.file.Paths;

import org.json.simple.*;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;

Expand All @@ -32,13 +33,11 @@
import com.ge.research.semtk.load.utility.SparqlGraphJson;
import com.ge.research.semtk.test.IntegrationTestUtility;
import com.ge.research.semtk.test.TestGraph;
import com.ge.research.semtk.utility.Utility;
import com.ge.research.semtk.resultSet.Table;
import com.ge.research.semtk.sparqlX.SparqlConnection;
import com.ge.research.semtk.sparqlX.SparqlEndpointInterface;
import com.ge.research.semtk.sparqlX.SparqlResultTypes;
import com.ge.research.semtk.sparqlX.SparqlToXUtils;
import com.ge.research.semtk.sparqlX.VirtuosoSparqlEndpointInterface;
import com.ge.research.semtk.resultSet.TableResultSet;


Expand All @@ -49,6 +48,8 @@ public class IngestorRestClientTest_IT {

private static SparqlGraphJson sgJson_TestGraph;
private static String sgJsonString_TestGraph;

private static String otherDataset;

@BeforeClass
public static void setup() throws Exception {
Expand All @@ -61,6 +62,11 @@ public static void setup() throws Exception {
sgJson_TestGraph = TestGraph.getSparqlGraphJsonFromFile("src/test/resources/testTransforms.json");
sgJsonString_TestGraph = sgJson_TestGraph.getJson().toJSONString(); // template as a string
}

@AfterClass
public static void cleanup() throws Exception {
IntegrationTestUtility.clearGraph(TestGraph.getSei(otherDataset));
}


/**
Expand Down Expand Up @@ -92,7 +98,7 @@ public void testIngestWithConnectionOverride() throws Exception{
JSONObject sparqlConnJson = sgJson_TestGraph.getSparqlConn().toJson(); // original TestGraph sparql conn

SparqlConnection sparqlConnectionOverride = new SparqlConnection(sparqlConnJson.toJSONString()); // get the connection object
String otherDataset = sparqlConnectionOverride.getDefaultQueryInterface().getGraph() + "OTHER";
otherDataset = sparqlConnectionOverride.getDefaultQueryInterface().getGraph() + "OTHER";
sparqlConnectionOverride.getDataInterface(0).setGraph(otherDataset);
sparqlConnectionOverride.getModelInterface(0).setGraph(otherDataset);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import java.util.Hashtable;
import java.util.List;

import com.ge.research.semtk.api.nodeGroupExecution.client.NodeGroupExecutionClient;
import com.ge.research.semtk.belmont.AutoGeneratedQueryTypes;
import com.ge.research.semtk.belmont.Node;
import com.ge.research.semtk.belmont.NodeGroup;
Expand All @@ -52,12 +51,10 @@
import com.ge.research.semtk.load.utility.SparqlGraphJson;
import com.ge.research.semtk.load.utility.UriResolver;
import com.ge.research.semtk.ontologyTools.OntologyInfo;
import com.ge.research.semtk.ontologyTools.PredicateStats;
import com.ge.research.semtk.resultSet.SimpleResultSet;
import com.ge.research.semtk.resultSet.Table;
import com.ge.research.semtk.sparqlX.SparqlConnection;
import com.ge.research.semtk.sparqlX.SparqlEndpointInterface;
import com.ge.research.semtk.sparqlX.client.SparqlQueryClient;
import com.ge.research.semtk.sparqlX.dispatch.client.DispatchRestClient;
import com.ge.research.semtk.test.IntegrationTestUtility;
import com.ge.research.semtk.test.TestGraph;
Expand Down Expand Up @@ -86,6 +83,7 @@ public static void shutdown() throws Exception {
System.out.println(s);
}
}

@Test
public void testOriginal() throws Exception {
Dataset ds = new CSVDataset("src/test/resources/testTransforms.csv", false);
Expand Down Expand Up @@ -1398,6 +1396,7 @@ public void testLoadLookXNodesTwoConn() throws Exception {
doLoadLookXNodesTwoConn(true);
doLoadLookXNodesTwoConn(false);
}

public void doLoadLookXNodesTwoConn(boolean cacheFlag) throws Exception {
// Repeat testLoadLookXNodes() with an extra data connection graph
// ingest into a different graph
Expand Down Expand Up @@ -1443,6 +1442,9 @@ public void doLoadLookXNodesTwoConn(boolean cacheFlag) throws Exception {
sgJson.setSparqlConn(TestGraph.getSparqlConn());
query = TestGraph.getNodeGroupWithOInfo(sgJson).generateSparqlSelect();
IntegrationTestUtility.querySeiAndCheckResults(query, seiBoth, this, "/loadTestDuraBatteryFirst4Results.csv");

IntegrationTestUtility.clearGraph(seiBoth);
IntegrationTestUtility.clearGraph(seiData0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,9 @@

import com.ge.research.semtk.belmont.Node;
import com.ge.research.semtk.belmont.NodeGroup;
import com.ge.research.semtk.ontologyTools.ClassInstance;
import com.ge.research.semtk.ontologyTools.OntologyInfo;
import com.ge.research.semtk.ontologyTools.PathExplorer;
import com.ge.research.semtk.ontologyTools.PathItemRequest;
import com.ge.research.semtk.ontologyTools.ReturnRequest;
import com.ge.research.semtk.resultSet.Table;
import com.ge.research.semtk.sparqlX.SparqlConnection;
import com.ge.research.semtk.sparqlX.SparqlEndpointInterface;
Expand All @@ -42,7 +40,8 @@ public class PathExplorerTest_IT {
private static SparqlConnection conn = null;
private static OntologyInfo oInfo = null;
private static PathExplorer explorer = null;

private static SparqlEndpointInterface cacheSei;

@BeforeClass
public static void setup() throws Exception {

Expand All @@ -53,13 +52,17 @@ public static void setup() throws Exception {

// create a nodegroup cache graph based on the jUnit test graph name
String cacheName = TestGraph.generateGraphName("ngCache");
SparqlEndpointInterface cacheSei = TestGraph.getSei(cacheName);
cacheSei = TestGraph.getSei(cacheName);
cacheSei.clearGraph();

explorer = new PathExplorer(oInfo, conn, IntegrationTestUtility.getNodeGroupExecutionRestClient(), cacheSei);

}

@AfterClass
public static void cleanup() throws Exception {
IntegrationTestUtility.clearGraph(cacheSei);
}

@Test
public void addClassAirportToAircraft() throws Exception {
Expand Down

0 comments on commit 7bf08cb

Please sign in to comment.