|
26 | 26 | import java.util.Collections;
|
27 | 27 | import java.util.HashSet;
|
28 | 28 | import java.util.UUID;
|
| 29 | +import java.util.concurrent.atomic.AtomicReference; |
| 30 | +import java.util.function.Predicate; |
29 | 31 |
|
30 | 32 | import org.junit.jupiter.api.BeforeEach;
|
31 | 33 | import org.junit.jupiter.api.Nested;
|
|
56 | 58 | import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithBusinessIdAndVersion;
|
57 | 59 | import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SimpleDynamicLabelsWithVersion;
|
58 | 60 | import org.springframework.data.neo4j.integration.shared.common.EntitiesWithDynamicLabels.SuperNode;
|
| 61 | +import org.springframework.data.neo4j.integration.shared.common.EntityWithDynamicLabelsAndIdThatNeedsToBeConverted; |
59 | 62 | import org.springframework.data.neo4j.test.Neo4jExtension;
|
60 | 63 | import org.springframework.test.context.ContextConfiguration;
|
61 | 64 | import org.springframework.test.context.junit.jupiter.SpringExtension;
|
@@ -349,6 +352,27 @@ void shouldReadDynamicLabelsOnClassWithMultipleNodeLabel(@Autowired ReactiveNeo4
|
349 | 352 | .flatMapMany(entity -> Flux.fromIterable(entity.moreLabels)).sort().as(StepVerifier::create)
|
350 | 353 | .expectNext("Baz", "Foobar", "SimpleDynamicLabels");
|
351 | 354 | }
|
| 355 | + |
| 356 | + @Test // GH-2296 |
| 357 | + void shouldConvertIds(@Autowired ReactiveNeo4jTemplate template) { |
| 358 | + |
| 359 | + String label = "value_1"; |
| 360 | + Predicate<EntityWithDynamicLabelsAndIdThatNeedsToBeConverted> expectatations = savedInstance -> |
| 361 | + label.equals(savedInstance.getValue()) && savedInstance.getExtraLabels().contains(label); |
| 362 | + |
| 363 | + AtomicReference<UUID> generatedUUID = new AtomicReference<>(); |
| 364 | + template.deleteAll(EntityWithDynamicLabelsAndIdThatNeedsToBeConverted.class) |
| 365 | + .then(template.save(new EntityWithDynamicLabelsAndIdThatNeedsToBeConverted(label))) |
| 366 | + .doOnNext(s -> generatedUUID.set(s.getId())) |
| 367 | + .as(StepVerifier::create) |
| 368 | + .expectNextMatches(expectatations) |
| 369 | + .verifyComplete(); |
| 370 | + |
| 371 | + template.findById(generatedUUID.get(), EntityWithDynamicLabelsAndIdThatNeedsToBeConverted.class) |
| 372 | + .as(StepVerifier::create) |
| 373 | + .expectNextMatches(expectatations) |
| 374 | + .verifyComplete(); |
| 375 | + } |
352 | 376 | }
|
353 | 377 |
|
354 | 378 | @Nested
|
|
0 commit comments