|
19 | 19 |
|
20 | 20 | import org.junit.jupiter.api.Test;
|
21 | 21 | import org.neo4j.driver.Driver;
|
| 22 | +import org.neo4j.driver.Record; |
| 23 | +import org.neo4j.driver.Session; |
| 24 | +import org.neo4j.driver.types.Node; |
22 | 25 | import org.springframework.beans.factory.annotation.Autowired;
|
23 | 26 | import org.springframework.context.annotation.Bean;
|
24 | 27 | import org.springframework.context.annotation.Configuration;
|
@@ -81,6 +84,28 @@ void compositePropertiesOnNodesShouldBeRead(@Autowired Repository repository) {
|
81 | 84 | assertThat(repository.findById(id)).isPresent().hasValueSatisfying(this::assertNodePropertiesOn);
|
82 | 85 | }
|
83 | 86 |
|
| 87 | + @Test // GH-2280 |
| 88 | + void compositePropertiesOnNodesShouldBeDeleted(@Autowired Repository repository) { |
| 89 | + |
| 90 | + Long id = createNodeWithCompositeProperties(); |
| 91 | + ThingWithCompositeProperties thing = repository.findById(id).get(); |
| 92 | + thing.setDatesWithTransformedKey(Collections.singletonMap("Test", null)); |
| 93 | + thing.setSomeDatesByEnumA(Collections.singletonMap(ThingWithCompositeProperties.EnumA.VALUE_AA, null)); |
| 94 | + thing.setSomeOtherDTO(null); |
| 95 | + repository.save(thing); |
| 96 | + |
| 97 | + try (Session session = driver.session()) { |
| 98 | + Record r = session.readTransaction(tx -> tx.run("MATCH (t:CompositeProperties) WHERE id(t) = $id RETURN t", |
| 99 | + Collections.singletonMap("id", id)).single()); |
| 100 | + Node n = r.get("t").asNode(); |
| 101 | + assertThat(n.asMap()).doesNotContainKeys( |
| 102 | + "someDatesByEnumA.VALUE_AA", |
| 103 | + "datesWithTransformedKey.test", |
| 104 | + "dto.x", "dto.y", "dto.z" |
| 105 | + ); |
| 106 | + } |
| 107 | + } |
| 108 | + |
84 | 109 | public interface Repository extends Neo4jRepository<ThingWithCompositeProperties, Long> {
|
85 | 110 | }
|
86 | 111 |
|
|
0 commit comments