Skip to content

Commit

Permalink
Missed CREATE CONSTRAINT ON ... ASSERT ... cases
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunterness committed Dec 6, 2021
1 parent 46683b6 commit 2192047
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions core/src/test/java/apoc/schema/SchemasTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public void testRetainIndexWhenNotUsingDropExisting() throws Exception {

@Test
public void testDropSchemaWhenUsingDropExisting() throws Exception {
db.executeTransactionally("CREATE CONSTRAINT ON (f:Foo) ASSERT f.bar IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (f:Foo) REQUIRE f.bar IS UNIQUE");
testCall(db, "CALL apoc.schema.assert(null,null)", (r) -> {
assertEquals("Foo", r.get("label"));
assertEquals("bar", r.get("key"));
Expand All @@ -209,7 +209,7 @@ public void testDropSchemaWhenUsingDropExisting() throws Exception {

@Test
public void testDropSchemaAndCreateSchemaWhenUsingDropExisting() throws Exception {
db.executeTransactionally("CREATE CONSTRAINT ON (f:Foo) ASSERT f.bar IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (f:Foo) REQUIRE f.bar IS UNIQUE");
testResult(db, "CALL apoc.schema.assert(null, {Bar:['foo']})", (result) -> {
Map<String, Object> r = result.next();
assertEquals("Foo", r.get("label"));
Expand All @@ -231,7 +231,7 @@ public void testDropSchemaAndCreateSchemaWhenUsingDropExisting() throws Exceptio

@Test
public void testRetainSchemaWhenNotUsingDropExisting() throws Exception {
db.executeTransactionally("CREATE CONSTRAINT ON (f:Foo) ASSERT f.bar IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (f:Foo) REQUIRE f.bar IS UNIQUE");
testResult(db, "CALL apoc.schema.assert(null, {Bar:['foo', 'bar']}, false)", (result) -> {
Map<String, Object> r = result.next();
assertEquals("Foo", r.get("label"));
Expand Down Expand Up @@ -282,7 +282,7 @@ public void testKeepIndex() throws Exception {

@Test
public void testKeepSchema() throws Exception {
db.executeTransactionally("CREATE CONSTRAINT ON (f:Foo) ASSERT f.bar IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (f:Foo) REQUIRE f.bar IS UNIQUE");
testResult(db, "CALL apoc.schema.assert(null,{Foo:['bar', 'foo']})", (result) -> {
Map<String, Object> r = result.next();
assertEquals("Foo", r.get("label"));
Expand Down Expand Up @@ -347,7 +347,7 @@ public void testIndexNotExists() {

@Test
public void testUniquenessConstraintOnNode() {
db.executeTransactionally("CREATE CONSTRAINT ON (bar:Bar) ASSERT bar.foo IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (bar:Bar) REQUIRE bar.foo IS UNIQUE");
awaitIndexesOnline();

testResult(db, "CALL apoc.schema.nodes()", (result) -> {
Expand All @@ -365,7 +365,7 @@ public void testUniquenessConstraintOnNode() {
@Test
public void testIndexAndUniquenessConstraintOnNode() {
db.executeTransactionally("CREATE INDEX FOR (n:Foo) ON (n.foo)");
db.executeTransactionally("CREATE CONSTRAINT ON (bar:Bar) ASSERT bar.bar IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (bar:Bar) REQUIRE bar.bar IS UNIQUE");
awaitIndexesOnline();

testResult(db, "CALL apoc.schema.nodes()", (result) -> {
Expand Down Expand Up @@ -551,15 +551,15 @@ public void testIndexesMoreLabels() {
@Test
public void testSchemaRelationshipsExclude() {
ignoreException(() -> {
db.executeTransactionally("CREATE CONSTRAINT ON ()-[like:LIKED]-() ASSERT exists(like.day)");
db.executeTransactionally("CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE exists(like.day)");
testResult(db, "CALL apoc.schema.relationships({excludeRelationships:['LIKED']})", (result) -> assertFalse(result.hasNext()));
}, QueryExecutionException.class);
}

@Test
public void testSchemaNodesExclude() {
ignoreException(() -> {
db.executeTransactionally("CREATE CONSTRAINT ON (book:Book) ASSERT book.isbn IS UNIQUE");
db.executeTransactionally("CREATE CONSTRAINT FOR (book:Book) REQUIRE book.isbn IS UNIQUE");
testResult(db, "CALL apoc.schema.nodes({excludeLabels:['Book']})", (result) -> assertFalse(result.hasNext()));

}, QueryExecutionException.class);
Expand Down Expand Up @@ -587,8 +587,8 @@ public void testIndexesLabelsAndExcludeLabelsValuatedShouldFail() {

@Test(expected = QueryExecutionException.class)
public void testConstraintsRelationshipsAndExcludeRelationshipsValuatedShouldFail() {
db.executeTransactionally("CREATE CONSTRAINT ON ()-[like:LIKED]-() ASSERT exists(like.day)");
db.executeTransactionally("CREATE CONSTRAINT ON ()-[knows:SINCE]-() ASSERT exists(since.year)");
db.executeTransactionally("CREATE CONSTRAINT FOR ()-[like:LIKED]-() REQUIRE exists(like.day)");
db.executeTransactionally("CREATE CONSTRAINT FOR ()-[knows:SINCE]-() REQUIRE exists(since.year)");
awaitIndexesOnline();
try (Transaction tx = db.beginTx()) {
tx.schema().awaitIndexesOnline(5, TimeUnit.SECONDS);
Expand Down

0 comments on commit 2192047

Please sign in to comment.