Skip to content

Commit c462cef

Browse files
committed
added unit test for ticket 12931
1 parent 94a4d03 commit c462cef

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

src/main/java/n10s/mapping/MappingUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ public Stream<MappingDesc> add(@Name("elementUri") String rdfVocElement,
6565
+ "DETACH DELETE oldmd";
6666

6767
String cleanOrphansIfAny = "MATCH (oldns:`_MapNs`)\n"
68-
+ "WITH DISTINCT oldns WHERE size((oldns)<-[:_IN]-())=0\n"
69-
+ "DELETE oldns";
68+
+ " WHERE size((oldns)<-[:_IN]-())=0\n"
69+
+ " DELETE oldns";
7070

7171
String createNewMapping = "MERGE (newmns:`_MapNs` { _ns: $namespace, _prefix: $prefix }) \n"
7272
+ "MERGE (newmd:`_MapDef` { _key: $graphElement, _local: $local})\n"

src/test/java/n10s/mapping/MappingUtilsTest.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,8 @@
99
import n10s.nsprefixes.NsPrefixDefProcedures;
1010
import org.junit.Rule;
1111
import org.junit.Test;
12-
import org.neo4j.driver.Config;
13-
import org.neo4j.driver.Driver;
14-
import org.neo4j.driver.GraphDatabase;
12+
import org.neo4j.driver.*;
1513
import org.neo4j.driver.Record;
16-
import org.neo4j.driver.Result;
17-
import org.neo4j.driver.Session;
1814
import org.neo4j.harness.junit.rule.Neo4jRule;
1915

2016
public class MappingUtilsTest {
@@ -197,4 +193,26 @@ public void testDropMappingsAndSchemas() throws Exception {
197193
}
198194
}
199195

196+
@Test
197+
public void testBug12931() throws Exception {
198+
try (Driver driver = GraphDatabase.driver(neo4j.boltURI(),
199+
Config.builder().withoutEncryption().build()); Session session = driver.session();) {
200+
String step1 = "CALL n10s.nsprefixes.add(\"a\",\"neo4j://vocs/a/\")";
201+
String step2 = "CALL n10s.mapping.add(\"neo4j://vocs/a/something\",\"something\")";
202+
String step3 = "CALL n10s.mapping.add(\"neo4j://vocs/a/other\",\"other\")";
203+
String step4 = "CALL n10s.mapping.add(\"neo4j://vocs/a/something\",\"somethingElse\")";
204+
205+
session.run(step1);
206+
session.run(step2);
207+
session.run(step3);
208+
session.run(step4);
209+
210+
assertEquals(2L,session.run("call n10s.mapping.list() yield schemaElement\n" +
211+
"return count(*) as mappingcount").next().get("mappingcount").asLong());
212+
assertEquals(1L,session.run("call n10s.nsprefixes.list() yield namespace\n" +
213+
"return count(*) as namespacecount").next().get("namespacecount").asLong());
214+
215+
}
216+
217+
}
200218
}

0 commit comments

Comments
 (0)