Skip to content

Commit

Permalink
docs: Add example test for LabelExpression.
Browse files Browse the repository at this point in the history
Closes #1077.
  • Loading branch information
michael-simons committed Sep 24, 2024
1 parent 63da2fd commit 6a6ea55
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
*/
class CypherTest {



@Test
void sortDirectionShouldBeSpecified() {

Expand Down
Original file line number Diff line number Diff line change
@@ -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");
}
}

0 comments on commit 6a6ea55

Please sign in to comment.