From 6a6ea559b54466f027d9f41e218dc2c498b82823 Mon Sep 17 00:00:00 2001 From: Michael Simons Date: Tue, 24 Sep 2024 07:44:55 +0200 Subject: [PATCH] docs: Add example test for `LabelExpression`. Closes #1077. --- .../org/neo4j/cypherdsl/core/CypherTest.java | 2 + .../cypherdsl/core/LabelExpressionTest.java | 45 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/LabelExpressionTest.java diff --git a/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/CypherTest.java b/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/CypherTest.java index 0863cff58c..5491e6f7d9 100644 --- a/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/CypherTest.java +++ b/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/CypherTest.java @@ -37,6 +37,8 @@ */ class CypherTest { + + @Test void sortDirectionShouldBeSpecified() { diff --git a/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/LabelExpressionTest.java b/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/LabelExpressionTest.java new file mode 100644 index 0000000000..f551b0573a --- /dev/null +++ b/neo4j-cypher-dsl/src/test/java/org/neo4j/cypherdsl/core/LabelExpressionTest.java @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019-2024 "Neo4j," + * Neo4j Sweden AB [https://neo4j.com] + * + * This file is part of Neo4j. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.neo4j.cypherdsl.core; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.jupiter.api.Test; + +class LabelExpressionTest { + + @Test // GH-1077 + void labelExpressionsShouldWork1() { + + var node = Cypher.node(new LabelExpression("Person").or(new LabelExpression("Organization"))).named("n"); + var cypher = Cypher.match(node).returning(node).build().getCypher(); + + assertThat(cypher).isEqualTo("MATCH (n:`Person`|`Organization`) RETURN n"); + } + + @Test // GH-1077 + void labelExpressionsShouldWork2() { + + var node = Cypher.node(new LabelExpression("Person").or(new LabelExpression("Organization")) + .and(new LabelExpression("Sanctioned").negate())).named("n"); + var cypher = Cypher.match(node).returning(node).build().getCypher(); + + assertThat(cypher).isEqualTo("MATCH (n:(`Person`|`Organization`)&!`Sanctioned`) RETURN n"); + } +}