-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add additional tests proving bidi relationships with properties…
… work as intended. Closes #2905.
- Loading branch information
1 parent
68762fd
commit 7d38286
Showing
5 changed files
with
419 additions
and
0 deletions.
There are no files selected for viewing
78 changes: 78 additions & 0 deletions
78
src/test/java/org/springframework/data/neo4j/integration/issues/gh2905/BugFrom.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
/* | ||
* Copyright 2011-2024 the original author or authors. | ||
* | ||
* 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.springframework.data.neo4j.integration.issues.gh2905; | ||
|
||
import org.springframework.data.neo4j.core.schema.GeneratedValue; | ||
import org.springframework.data.neo4j.core.schema.Id; | ||
import org.springframework.data.neo4j.core.schema.Relationship; | ||
import org.springframework.data.neo4j.core.support.UUIDStringGenerator; | ||
|
||
/** | ||
* @author Mathias Kühn | ||
*/ | ||
@SuppressWarnings("HiddenField") // Not worth cleaning up the Delomboked version | ||
class BugFrom { | ||
@Id | ||
@GeneratedValue(UUIDStringGenerator.class) | ||
protected String uuid; | ||
|
||
private String name; | ||
|
||
@Relationship(type = "RELI", direction = Relationship.Direction.INCOMING) | ||
private BugRelationship reli; | ||
|
||
BugFrom(String uuid, String name, BugRelationship reli) { | ||
this.uuid = uuid; | ||
this.name = name; | ||
this.reli = reli; | ||
} | ||
|
||
public static BugFromBuilder builder() { | ||
return new BugFromBuilder(); | ||
} | ||
|
||
public static class BugFromBuilder { | ||
private String uuid; | ||
private String name; | ||
private BugRelationship reli; | ||
|
||
BugFromBuilder() { | ||
} | ||
|
||
public BugFromBuilder uuid(String uuid) { | ||
this.uuid = uuid; | ||
return this; | ||
} | ||
|
||
public BugFromBuilder name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public BugFromBuilder reli(BugRelationship reli) { | ||
this.reli = reli; | ||
return this; | ||
} | ||
|
||
public BugFrom build() { | ||
return new BugFrom(this.uuid, this.name, this.reli); | ||
} | ||
|
||
public String toString() { | ||
return "BugFrom.BugFromBuilder(uuid=" + this.uuid + ", name=" + this.name + ", reli=" + this.reli + ")"; | ||
} | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
src/test/java/org/springframework/data/neo4j/integration/issues/gh2905/BugRelationship.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2011-2024 the original author or authors. | ||
* | ||
* 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.springframework.data.neo4j.integration.issues.gh2905; | ||
|
||
import org.springframework.data.neo4j.core.schema.RelationshipId; | ||
import org.springframework.data.neo4j.core.schema.RelationshipProperties; | ||
import org.springframework.data.neo4j.core.schema.TargetNode; | ||
|
||
/** | ||
* @author Mathias Kühn | ||
*/ | ||
@SuppressWarnings("HiddenField") // Not worth cleaning up the Delomboked version | ||
@RelationshipProperties | ||
class BugRelationship { | ||
@RelationshipId | ||
protected Long id; | ||
|
||
protected String comment; | ||
|
||
@TargetNode | ||
private BugTargetBase target; | ||
|
||
BugRelationship(Long id, String comment, BugTargetBase target) { | ||
this.id = id; | ||
this.comment = comment; | ||
this.target = target; | ||
} | ||
|
||
public static BugRelationshipBuilder builder() { | ||
return new BugRelationshipBuilder(); | ||
} | ||
|
||
public static class BugRelationshipBuilder { | ||
private Long id; | ||
private String comment; | ||
private BugTargetBase target; | ||
|
||
BugRelationshipBuilder() { | ||
} | ||
|
||
public BugRelationshipBuilder id(Long id) { | ||
this.id = id; | ||
return this; | ||
} | ||
|
||
public BugRelationshipBuilder comment(String comment) { | ||
this.comment = comment; | ||
return this; | ||
} | ||
|
||
public BugRelationshipBuilder target(BugTargetBase target) { | ||
this.target = target; | ||
return this; | ||
} | ||
|
||
public BugRelationship build() { | ||
return new BugRelationship(this.id, this.comment, this.target); | ||
} | ||
|
||
public String toString() { | ||
return "BugRelationship.BugRelationshipBuilder(id=" + this.id + ", comment=" + this.comment + ", target=" + this.target + ")"; | ||
} | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/test/java/org/springframework/data/neo4j/integration/issues/gh2905/BugTarget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright 2011-2024 the original author or authors. | ||
* | ||
* 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.springframework.data.neo4j.integration.issues.gh2905; | ||
|
||
import java.util.Set; | ||
|
||
/** | ||
* @author Mathias Kühn | ||
*/ | ||
@SuppressWarnings("HiddenField") // Not worth cleaning up the Delomboked version | ||
class BugTarget extends BugTargetBase { | ||
private String type; | ||
|
||
BugTarget(String uuid, String name, Set<BugFrom> relatedBugs, String type) { | ||
super(uuid, name, relatedBugs); | ||
this.type = type; | ||
} | ||
|
||
public static BugTargetBuilder builder() { | ||
return new BugTargetBuilder(); | ||
} | ||
|
||
public static class BugTargetBuilder { | ||
private String uuid; | ||
private String name; | ||
private Set<BugFrom> relatedBugs; | ||
private String type; | ||
|
||
BugTargetBuilder() { | ||
} | ||
|
||
public BugTargetBuilder uuid(String uuid) { | ||
this.uuid = uuid; | ||
return this; | ||
} | ||
|
||
public BugTargetBuilder name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public BugTargetBuilder relatedBugs(Set<BugFrom> relatedBugs) { | ||
this.relatedBugs = relatedBugs; | ||
return this; | ||
} | ||
|
||
public BugTargetBuilder type(String type) { | ||
this.type = type; | ||
return this; | ||
} | ||
|
||
public BugTarget build() { | ||
return new BugTarget(this.uuid, this.name, this.relatedBugs, this.type); | ||
} | ||
|
||
public String toString() { | ||
return "BugTarget.BugTargetBuilder(uuid=" + this.uuid + ", name=" + this.name + ", relatedBugs=" + this.relatedBugs + ", type=" + this.type + ")"; | ||
} | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/test/java/org/springframework/data/neo4j/integration/issues/gh2905/BugTargetBase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright 2011-2024 the original author or authors. | ||
* | ||
* 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.springframework.data.neo4j.integration.issues.gh2905; | ||
|
||
import java.util.Set; | ||
|
||
import org.springframework.data.neo4j.core.schema.GeneratedValue; | ||
import org.springframework.data.neo4j.core.schema.Id; | ||
import org.springframework.data.neo4j.core.schema.Relationship; | ||
import org.springframework.data.neo4j.core.support.UUIDStringGenerator; | ||
|
||
/** | ||
* @author Mathias Kühn | ||
*/ | ||
abstract class BugTargetBase { | ||
@Id | ||
@GeneratedValue(UUIDStringGenerator.class) | ||
protected String uuid; | ||
|
||
private String name; | ||
|
||
@Relationship(type = "RELI", direction = Relationship.Direction.OUTGOING) | ||
Set<BugFrom> relatedBugs; | ||
|
||
BugTargetBase(String uuid, String name, Set<BugFrom> relatedBugs) { | ||
this.uuid = uuid; | ||
this.name = name; | ||
this.relatedBugs = relatedBugs; | ||
} | ||
} |
Oops, something went wrong.