Skip to content

Commit

Permalink
docs: Add additional tests proving bidi relationships with properties…
Browse files Browse the repository at this point in the history
… work as intended.

Closes #2905.
  • Loading branch information
michael-simons committed May 23, 2024
1 parent 68762fd commit 7d38286
Show file tree
Hide file tree
Showing 5 changed files with 419 additions and 0 deletions.
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 + ")";
}
}
}
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 + ")";
}
}
}
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 + ")";
}
}
}
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;
}
}

0 comments on commit 7d38286

Please sign in to comment.