Skip to content

Commit 8aaee80

Browse files
committed
GH-2386 - Upgrade CypherDSL to 2021.2.4.
Add also a test case provided by the reporting user. Closes #2386
1 parent e3749e4 commit 8aaee80

File tree

4 files changed

+74
-1
lines changed

4 files changed

+74
-1
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@
7676
<cdi>2.0.SP1</cdi>
7777
<changelist>-SNAPSHOT</changelist>
7878
<checkstyle.version>8.40</checkstyle.version>
79-
<cypher-dsl.version>2021.2.3</cypher-dsl.version>
79+
<cypher-dsl.version>2021.2.4</cypher-dsl.version>
8080
<dist.id>spring-data-neo4j</dist.id>
8181
<dist.key>SDNEO4J</dist.key>
8282
<flatten-maven-plugin.version>1.2.5</flatten-maven-plugin.version>

src/test/java/org/springframework/data/neo4j/integration/issues/gh2323/GH2323IT.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.stream.Collectors;
2323

2424
import org.junit.jupiter.api.BeforeAll;
25+
import org.junit.jupiter.api.RepeatedTest;
2526
import org.junit.jupiter.api.Test;
2627
import org.neo4j.driver.Driver;
2728
import org.neo4j.driver.Session;
@@ -79,6 +80,27 @@ void listOfRelationshipPropertiesShouldBeUnwindable(@Autowired PersonService per
7980
});
8081
}
8182

83+
@RepeatedTest(20) // GH-2386
84+
void dontMixRelatedNodes(@Autowired PersonRepository repository, @Autowired BookmarkCapture bookmarkCapture) {
85+
String id;
86+
try (Session session = neo4jConnectionSupport.getDriver().session(bookmarkCapture.createSessionConfig());
87+
Transaction transaction = session.beginTransaction();
88+
) {
89+
id = transaction.run("CREATE (n:Person {id:randomUUID(), name: 'Gerrit'})-[:KNOWS]->(:Language{name:'English'}) return n.id").single().get(0).asString();
90+
transaction.run("MATCH (n:Person {name: 'Gerrit'}) MERGE (n)-[:MOTHER_TONGUE_IS]->(:Language{name:'German'})").consume();
91+
transaction.commit();
92+
bookmarkCapture.seedWith(session.lastBookmark());
93+
94+
Person gerrit = repository.findById(id).get();
95+
List<Knows> knownLanguages = gerrit.getKnownLanguages();
96+
assertThat(knownLanguages).hasSize(1);
97+
assertThat(knownLanguages.get(0).getLanguage().getName()).isEqualTo("English");
98+
KnowsMtEntity motherTongue = gerrit.getMotherTongue();
99+
assertThat(motherTongue).isNotNull();
100+
assertThat(motherTongue.getLanguage().getName()).isEqualTo("German");
101+
}
102+
}
103+
82104
@Repository
83105
public interface PersonRepository extends Neo4jRepository<Person, String> {
84106

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright 2011-2021 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.neo4j.integration.issues.gh2323;
17+
18+
import lombok.Data;
19+
import lombok.EqualsAndHashCode;
20+
import org.springframework.data.neo4j.core.schema.GeneratedValue;
21+
import org.springframework.data.neo4j.core.schema.Id;
22+
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
23+
import org.springframework.data.neo4j.core.schema.TargetNode;
24+
25+
/**
26+
* another relationship property for {@link Language}
27+
*/
28+
@RelationshipProperties
29+
@EqualsAndHashCode
30+
@Data
31+
public class KnowsMtEntity {
32+
33+
@Id
34+
@GeneratedValue
35+
private Long id;
36+
37+
private String blubb;
38+
39+
@TargetNode
40+
private Language language;
41+
42+
}

src/test/java/org/springframework/data/neo4j/integration/issues/gh2323/Person.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.springframework.data.neo4j.core.schema.GeneratedValue;
2222
import org.springframework.data.neo4j.core.schema.Id;
2323
import org.springframework.data.neo4j.core.schema.Node;
24+
import org.springframework.data.neo4j.core.schema.Property;
2425
import org.springframework.data.neo4j.core.schema.Relationship;
2526

2627
/**
@@ -52,4 +53,12 @@ public String getName() {
5253
public List<Knows> getKnownLanguages() {
5354
return knownLanguages;
5455
}
56+
57+
@Relationship(type = "MOTHER_TONGUE_IS", direction = Relationship.Direction.OUTGOING)
58+
@Property("motherTongue")
59+
private KnowsMtEntity motherTongue;
60+
61+
public KnowsMtEntity getMotherTongue() {
62+
return motherTongue;
63+
}
5564
}

0 commit comments

Comments
 (0)