-
Notifications
You must be signed in to change notification settings - Fork 618
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5efb9b2
commit db05e2e
Showing
7 changed files
with
218 additions
and
0 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
...amework/data/neo4j/integration/issues/gh2728/Neo4jVersionDependentRelationshipSaveIT.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,98 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
import org.junit.jupiter.api.Assertions; | ||
import org.junit.jupiter.api.Test; | ||
import org.neo4j.driver.Driver; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.neo4j.core.DatabaseSelectionProvider; | ||
import org.springframework.data.neo4j.core.transaction.Neo4jBookmarkManager; | ||
import org.springframework.data.neo4j.core.transaction.Neo4jTransactionManager; | ||
import org.springframework.data.neo4j.integration.issues.gh2168.UnrelatedObjectPropertyConverterAsBean; | ||
import org.springframework.data.neo4j.repository.config.EnableNeo4jRepositories; | ||
import org.springframework.data.neo4j.test.BookmarkCapture; | ||
import org.springframework.data.neo4j.test.Neo4jExtension; | ||
import org.springframework.data.neo4j.test.Neo4jImperativeTestConfiguration; | ||
import org.springframework.data.neo4j.test.Neo4jIntegrationTest; | ||
import org.springframework.transaction.PlatformTransactionManager; | ||
import org.springframework.transaction.annotation.EnableTransactionManagement; | ||
|
||
/** | ||
* @author Gerrit Meier | ||
*/ | ||
@Neo4jIntegrationTest | ||
public class Neo4jVersionDependentRelationshipSaveIT { | ||
|
||
protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport; | ||
|
||
@Autowired | ||
private TestEntityWithGeneratedDeprecatedId1Repository generatedDeprecatedIdRepository; | ||
|
||
@Autowired | ||
private TestEntityWithAssignedId1Repository assignedIdRepository; | ||
|
||
@Test | ||
public void testGeneratedDeprecatedIds() { | ||
TestEntityWithGeneratedDeprecatedId2 t2 = new TestEntityWithGeneratedDeprecatedId2(null, "v2"); | ||
TestEntityWithGeneratedDeprecatedId1 t1 = new TestEntityWithGeneratedDeprecatedId1(null, "v1", t2); | ||
|
||
TestEntityWithGeneratedDeprecatedId1 result = generatedDeprecatedIdRepository.save(t1); | ||
|
||
TestEntityWithGeneratedDeprecatedId1 freshRetrieved = generatedDeprecatedIdRepository.findById(result.getId()).get(); | ||
|
||
Assertions.assertNotNull(result.getRelatedEntity()); | ||
Assertions.assertNotNull(freshRetrieved.getRelatedEntity()); // FAILS! | ||
} | ||
|
||
@Test | ||
public void testAssignedIds() { | ||
TestEntityWithAssignedId2 t2 = new TestEntityWithAssignedId2("second", "v2"); | ||
TestEntityWithAssignedId1 t1 = new TestEntityWithAssignedId1("first", "v1", t2); | ||
|
||
TestEntityWithAssignedId1 result = assignedIdRepository.save(t1); | ||
|
||
TestEntityWithAssignedId1 freshRetrieved = assignedIdRepository.findById(result.getAssignedId()).get(); | ||
|
||
Assertions.assertNotNull(result.getRelatedEntity()); | ||
Assertions.assertNotNull(freshRetrieved.getRelatedEntity()); // FAILS! | ||
} | ||
|
||
@Configuration | ||
@EnableTransactionManagement | ||
@EnableNeo4jRepositories(considerNestedRepositories = true) | ||
static class Config extends Neo4jImperativeTestConfiguration { | ||
|
||
@Bean | ||
public Driver driver() { | ||
|
||
return neo4jConnectionSupport.getDriver(); | ||
} | ||
|
||
@Bean | ||
public BookmarkCapture bookmarkCapture() { | ||
return new BookmarkCapture(); | ||
} | ||
|
||
@Bean | ||
public UnrelatedObjectPropertyConverterAsBean converterBean() { | ||
return new UnrelatedObjectPropertyConverterAsBean(); | ||
} | ||
|
||
@Override | ||
public PlatformTransactionManager transactionManager(Driver driver, | ||
DatabaseSelectionProvider databaseNameProvider) { | ||
|
||
BookmarkCapture bookmarkCapture = bookmarkCapture(); | ||
return new Neo4jTransactionManager(driver, databaseNameProvider, | ||
Neo4jBookmarkManager.create(bookmarkCapture)); | ||
} | ||
|
||
@Override | ||
public boolean isCypher5Compatible() { | ||
return neo4jConnectionSupport.isCypher5SyntaxCompatible(); | ||
// return false; // explicitly not compatible with Neo4j 5 although connected to one | ||
} | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...a/org/springframework/data/neo4j/integration/issues/gh2728/TestEntityWithAssignedId1.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,32 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
import org.springframework.data.neo4j.core.schema.Id; | ||
import org.springframework.data.neo4j.core.schema.Node; | ||
import org.springframework.data.neo4j.core.schema.Property; | ||
import org.springframework.data.neo4j.core.schema.Relationship; | ||
|
||
@Node | ||
public class TestEntityWithAssignedId1 { | ||
|
||
@Id | ||
private String assignedId; | ||
|
||
@Property("value_one") | ||
private String valueOne; | ||
|
||
@Relationship("related_to") | ||
private TestEntityWithAssignedId2 relatedEntity; | ||
|
||
public TestEntityWithAssignedId1(String assignedId, String valueOne, TestEntityWithAssignedId2 relatedEntity) { | ||
this.assignedId = assignedId; | ||
this.valueOne = valueOne; | ||
this.relatedEntity = relatedEntity; | ||
} | ||
public String getAssignedId() { | ||
return assignedId; | ||
} | ||
|
||
public TestEntityWithAssignedId2 getRelatedEntity() { | ||
return relatedEntity; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ngframework/data/neo4j/integration/issues/gh2728/TestEntityWithAssignedId1Repository.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,6 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
import org.springframework.data.neo4j.repository.Neo4jRepository; | ||
|
||
public interface TestEntityWithAssignedId1Repository extends Neo4jRepository<TestEntityWithAssignedId1, String> { | ||
} |
20 changes: 20 additions & 0 deletions
20
...a/org/springframework/data/neo4j/integration/issues/gh2728/TestEntityWithAssignedId2.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,20 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
import org.springframework.data.neo4j.core.schema.Id; | ||
import org.springframework.data.neo4j.core.schema.Node; | ||
import org.springframework.data.neo4j.core.schema.Property; | ||
|
||
@Node | ||
public class TestEntityWithAssignedId2 { | ||
|
||
@Id | ||
private String assignedId; | ||
|
||
@Property("valueTwo") | ||
private String valueTwo; | ||
|
||
public TestEntityWithAssignedId2(String assignedId, String valueTwo) { | ||
this.assignedId = assignedId; | ||
this.valueTwo = valueTwo; | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
...gframework/data/neo4j/integration/issues/gh2728/TestEntityWithGeneratedDeprecatedId1.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,34 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
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.Property; | ||
import org.springframework.data.neo4j.core.schema.Relationship; | ||
|
||
@Node | ||
public class TestEntityWithGeneratedDeprecatedId1 { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
@Property("value_one") | ||
private String valueOne; | ||
|
||
@Relationship("related_to") | ||
private TestEntityWithGeneratedDeprecatedId2 relatedEntity; | ||
|
||
public TestEntityWithGeneratedDeprecatedId1(Long id, String valueOne, TestEntityWithGeneratedDeprecatedId2 relatedEntity) { | ||
this.id = id; | ||
this.valueOne = valueOne; | ||
this.relatedEntity = relatedEntity; | ||
} | ||
public Long getId() { | ||
return id; | ||
} | ||
|
||
public TestEntityWithGeneratedDeprecatedId2 getRelatedEntity() { | ||
return relatedEntity; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
.../data/neo4j/integration/issues/gh2728/TestEntityWithGeneratedDeprecatedId1Repository.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,6 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
import org.springframework.data.neo4j.repository.Neo4jRepository; | ||
|
||
public interface TestEntityWithGeneratedDeprecatedId1Repository extends Neo4jRepository<TestEntityWithGeneratedDeprecatedId1, Long> { | ||
} |
22 changes: 22 additions & 0 deletions
22
...gframework/data/neo4j/integration/issues/gh2728/TestEntityWithGeneratedDeprecatedId2.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,22 @@ | ||
package org.springframework.data.neo4j.integration.issues.gh2728; | ||
|
||
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.Property; | ||
|
||
@Node | ||
public class TestEntityWithGeneratedDeprecatedId2 { | ||
|
||
@Id | ||
@GeneratedValue | ||
private Long id; | ||
|
||
@Property("valueTwo") | ||
private String valueTwo; | ||
|
||
public TestEntityWithGeneratedDeprecatedId2(Long id, String valueTwo) { | ||
this.id = id; | ||
this.valueTwo = valueTwo; | ||
} | ||
} |