Skip to content

Commit 7d38286

Browse files
docs: Add additional tests proving bidi relationships with properties work as intended.
Closes #2905.
1 parent 68762fd commit 7d38286

File tree

5 files changed

+419
-0
lines changed

5 files changed

+419
-0
lines changed
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright 2011-2024 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.gh2905;
17+
18+
import org.springframework.data.neo4j.core.schema.GeneratedValue;
19+
import org.springframework.data.neo4j.core.schema.Id;
20+
import org.springframework.data.neo4j.core.schema.Relationship;
21+
import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
22+
23+
/**
24+
* @author Mathias Kühn
25+
*/
26+
@SuppressWarnings("HiddenField") // Not worth cleaning up the Delomboked version
27+
class BugFrom {
28+
@Id
29+
@GeneratedValue(UUIDStringGenerator.class)
30+
protected String uuid;
31+
32+
private String name;
33+
34+
@Relationship(type = "RELI", direction = Relationship.Direction.INCOMING)
35+
private BugRelationship reli;
36+
37+
BugFrom(String uuid, String name, BugRelationship reli) {
38+
this.uuid = uuid;
39+
this.name = name;
40+
this.reli = reli;
41+
}
42+
43+
public static BugFromBuilder builder() {
44+
return new BugFromBuilder();
45+
}
46+
47+
public static class BugFromBuilder {
48+
private String uuid;
49+
private String name;
50+
private BugRelationship reli;
51+
52+
BugFromBuilder() {
53+
}
54+
55+
public BugFromBuilder uuid(String uuid) {
56+
this.uuid = uuid;
57+
return this;
58+
}
59+
60+
public BugFromBuilder name(String name) {
61+
this.name = name;
62+
return this;
63+
}
64+
65+
public BugFromBuilder reli(BugRelationship reli) {
66+
this.reli = reli;
67+
return this;
68+
}
69+
70+
public BugFrom build() {
71+
return new BugFrom(this.uuid, this.name, this.reli);
72+
}
73+
74+
public String toString() {
75+
return "BugFrom.BugFromBuilder(uuid=" + this.uuid + ", name=" + this.name + ", reli=" + this.reli + ")";
76+
}
77+
}
78+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright 2011-2024 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.gh2905;
17+
18+
import org.springframework.data.neo4j.core.schema.RelationshipId;
19+
import org.springframework.data.neo4j.core.schema.RelationshipProperties;
20+
import org.springframework.data.neo4j.core.schema.TargetNode;
21+
22+
/**
23+
* @author Mathias Kühn
24+
*/
25+
@SuppressWarnings("HiddenField") // Not worth cleaning up the Delomboked version
26+
@RelationshipProperties
27+
class BugRelationship {
28+
@RelationshipId
29+
protected Long id;
30+
31+
protected String comment;
32+
33+
@TargetNode
34+
private BugTargetBase target;
35+
36+
BugRelationship(Long id, String comment, BugTargetBase target) {
37+
this.id = id;
38+
this.comment = comment;
39+
this.target = target;
40+
}
41+
42+
public static BugRelationshipBuilder builder() {
43+
return new BugRelationshipBuilder();
44+
}
45+
46+
public static class BugRelationshipBuilder {
47+
private Long id;
48+
private String comment;
49+
private BugTargetBase target;
50+
51+
BugRelationshipBuilder() {
52+
}
53+
54+
public BugRelationshipBuilder id(Long id) {
55+
this.id = id;
56+
return this;
57+
}
58+
59+
public BugRelationshipBuilder comment(String comment) {
60+
this.comment = comment;
61+
return this;
62+
}
63+
64+
public BugRelationshipBuilder target(BugTargetBase target) {
65+
this.target = target;
66+
return this;
67+
}
68+
69+
public BugRelationship build() {
70+
return new BugRelationship(this.id, this.comment, this.target);
71+
}
72+
73+
public String toString() {
74+
return "BugRelationship.BugRelationshipBuilder(id=" + this.id + ", comment=" + this.comment + ", target=" + this.target + ")";
75+
}
76+
}
77+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2011-2024 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.gh2905;
17+
18+
import java.util.Set;
19+
20+
/**
21+
* @author Mathias Kühn
22+
*/
23+
@SuppressWarnings("HiddenField") // Not worth cleaning up the Delomboked version
24+
class BugTarget extends BugTargetBase {
25+
private String type;
26+
27+
BugTarget(String uuid, String name, Set<BugFrom> relatedBugs, String type) {
28+
super(uuid, name, relatedBugs);
29+
this.type = type;
30+
}
31+
32+
public static BugTargetBuilder builder() {
33+
return new BugTargetBuilder();
34+
}
35+
36+
public static class BugTargetBuilder {
37+
private String uuid;
38+
private String name;
39+
private Set<BugFrom> relatedBugs;
40+
private String type;
41+
42+
BugTargetBuilder() {
43+
}
44+
45+
public BugTargetBuilder uuid(String uuid) {
46+
this.uuid = uuid;
47+
return this;
48+
}
49+
50+
public BugTargetBuilder name(String name) {
51+
this.name = name;
52+
return this;
53+
}
54+
55+
public BugTargetBuilder relatedBugs(Set<BugFrom> relatedBugs) {
56+
this.relatedBugs = relatedBugs;
57+
return this;
58+
}
59+
60+
public BugTargetBuilder type(String type) {
61+
this.type = type;
62+
return this;
63+
}
64+
65+
public BugTarget build() {
66+
return new BugTarget(this.uuid, this.name, this.relatedBugs, this.type);
67+
}
68+
69+
public String toString() {
70+
return "BugTarget.BugTargetBuilder(uuid=" + this.uuid + ", name=" + this.name + ", relatedBugs=" + this.relatedBugs + ", type=" + this.type + ")";
71+
}
72+
}
73+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2011-2024 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.gh2905;
17+
18+
import java.util.Set;
19+
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.Relationship;
23+
import org.springframework.data.neo4j.core.support.UUIDStringGenerator;
24+
25+
/**
26+
* @author Mathias Kühn
27+
*/
28+
abstract class BugTargetBase {
29+
@Id
30+
@GeneratedValue(UUIDStringGenerator.class)
31+
protected String uuid;
32+
33+
private String name;
34+
35+
@Relationship(type = "RELI", direction = Relationship.Direction.OUTGOING)
36+
Set<BugFrom> relatedBugs;
37+
38+
BugTargetBase(String uuid, String name, Set<BugFrom> relatedBugs) {
39+
this.uuid = uuid;
40+
this.name = name;
41+
this.relatedBugs = relatedBugs;
42+
}
43+
}

0 commit comments

Comments
 (0)