Skip to content

Commit

Permalink
Added test to showcase spring-projects#2918
Browse files Browse the repository at this point in the history
Signed-off-by: Mathias Kühn <kuehn@synerva.de>
  • Loading branch information
ma-ku committed Jul 5, 2024
1 parent be59c43 commit 32c2666
Show file tree
Hide file tree
Showing 5 changed files with 142 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@
import org.springframework.data.neo4j.integration.issues.gh2906.FromRepository;
import org.springframework.data.neo4j.integration.issues.gh2906.OutgoingBugRelationship;
import org.springframework.data.neo4j.integration.issues.gh2906.ToRepository;
import org.springframework.data.neo4j.integration.issues.gh2918.ConditionNode;
import org.springframework.data.neo4j.integration.issues.gh2918.ConditionRepository;
import org.springframework.data.neo4j.integration.issues.qbe.A;
import org.springframework.data.neo4j.integration.issues.qbe.ARepository;
import org.springframework.data.neo4j.integration.issues.qbe.B;
Expand Down Expand Up @@ -1557,6 +1559,16 @@ private static void assertGH2906Graph(Driver driver, int cnt) {
});
}

@Test
@Tag("GH-2918")
void loadCycleFreeWithInAndOutgoingRelationship (@Autowired ConditionRepository conditionRepository, @Autowired Driver driver) {

var conditionSaved = conditionRepository.save(new ConditionNode());

// It will never execute any Cypher as the statement preparation will already fail.
var conditionLoaded = conditionRepository.findById(conditionSaved.uuid);
}

@Configuration
@EnableTransactionManagement
@EnableNeo4jRepositories(namedQueriesLocation = "more-custom-queries.properties")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* 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.gh2918;

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.Node;
import org.springframework.data.neo4j.core.schema.Relationship;
import org.springframework.data.neo4j.core.support.UUIDStringGenerator;

/**
* @author Mathias Kühn
*/
@Node
public class ConditionNode {
@Id
@GeneratedValue(UUIDStringGenerator.class)
public String uuid;

@Relationship(type = "CAUSES", direction = Relationship.Direction.INCOMING)
public Set<FailureRelationship> upstreamFailures;

@Relationship(type = "CAUSES", direction = Relationship.Direction.OUTGOING)
public Set<FailureRelationship> downstreamFailures;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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.gh2918;

import org.springframework.data.neo4j.repository.Neo4jRepository;

/**
* @author Mathias Kühn
*/
public interface ConditionRepository extends Neo4jRepository<ConditionNode, String> {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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.gh2918;

import org.springframework.data.neo4j.core.schema.GeneratedValue;
import org.springframework.data.neo4j.core.schema.Id;
import org.springframework.data.neo4j.core.schema.Node;
import org.springframework.data.neo4j.core.support.UUIDStringGenerator;

/**
* @author Mathias Kühn
*/
@Node
public class FailureNode {
@Id
@GeneratedValue(UUIDStringGenerator.class)
public String uuid;
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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.gh2918;

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
*/
@RelationshipProperties
public abstract class FailureRelationship {

@RelationshipId
public String id;

@TargetNode
public FailureNode target;
}

0 comments on commit 32c2666

Please sign in to comment.