|
19 | 19 | import static org.neo4j.cypherdsl.core.Conditions.not;
|
20 | 20 | import static org.neo4j.cypherdsl.core.Predicates.exists;
|
21 | 21 |
|
| 22 | +import org.junit.jupiter.api.RepeatedTest; |
| 23 | +import org.springframework.data.neo4j.core.mapping.Neo4jMappingContext; |
| 24 | +import org.springframework.data.neo4j.integration.shared.common.CounterMetric; |
| 25 | +import org.springframework.data.neo4j.integration.shared.common.GaugeMetric; |
| 26 | +import org.springframework.data.neo4j.integration.shared.common.HistogramMetric; |
| 27 | +import org.springframework.data.neo4j.integration.shared.common.Metric; |
| 28 | +import org.springframework.data.neo4j.integration.shared.common.SummaryMetric; |
22 | 29 | import reactor.core.publisher.Flux;
|
23 | 30 | import reactor.core.publisher.Mono;
|
24 | 31 | import reactor.test.StepVerifier;
|
25 | 32 |
|
| 33 | +import java.util.Arrays; |
26 | 34 | import java.util.Collections;
|
| 35 | +import java.util.HashMap; |
27 | 36 | import java.util.HashSet;
|
| 37 | +import java.util.List; |
| 38 | +import java.util.Map; |
28 | 39 | import java.util.UUID;
|
29 | 40 | import java.util.concurrent.atomic.AtomicReference;
|
30 | 41 | import java.util.function.Predicate;
|
@@ -80,6 +91,38 @@ public class ReactiveDynamicLabelsIT {
|
80 | 91 |
|
81 | 92 | protected static Neo4jExtension.Neo4jConnectionSupport neo4jConnectionSupport;
|
82 | 93 |
|
| 94 | + |
| 95 | + @Nested |
| 96 | + class DynamicLabelsAndOrderOfClassesBeingLoaded extends SpringTestBase { |
| 97 | + |
| 98 | + @Override |
| 99 | + Long createTestEntity(Transaction t) { |
| 100 | + return t.run("CREATE (m:Metric:Counter:A:B:C:D {timestamp: datetime()}) RETURN id(m)").single().get(0).asLong(); |
| 101 | + |
| 102 | + } |
| 103 | + |
| 104 | + @RepeatedTest(100) // GH-2619 |
| 105 | + void ownLabelsShouldNotEndUpWithDynamicLabels(@Autowired Neo4jMappingContext mappingContext, @Autowired ReactiveNeo4jTemplate template) { |
| 106 | + |
| 107 | + List<Class<? extends Metric>> metrics = Arrays.asList(GaugeMetric.class, SummaryMetric.class, HistogramMetric.class, CounterMetric.class); |
| 108 | + Collections.shuffle(metrics); |
| 109 | + for (Class<?> type : metrics) { |
| 110 | + assertThat(mappingContext.getPersistentEntity(type)).isNotNull(); |
| 111 | + } |
| 112 | + |
| 113 | + Map<String, Object> args = new HashMap<>(); |
| 114 | + args.put("agentIdLabel", "B"); |
| 115 | + template.findAll("MATCH (m:Metric) WHERE $agentIdLabel in labels(m) RETURN m ORDER BY m.timestamp DESC", args, Metric.class) |
| 116 | + .as(StepVerifier::create) |
| 117 | + .assertNext(cm -> { |
| 118 | + assertThat(cm).isInstanceOf(CounterMetric.class); |
| 119 | + assertThat(cm.getId()).isEqualTo(existingEntityId); |
| 120 | + assertThat(cm.getDynamicLabels()).containsExactlyInAnyOrder("A", "B", "C", "D"); |
| 121 | + }) |
| 122 | + .verifyComplete(); |
| 123 | + } |
| 124 | + } |
| 125 | + |
83 | 126 | @Nested
|
84 | 127 | class EntityWithSingleStaticLabelAndGeneratedId extends SpringTestBase {
|
85 | 128 |
|
|
0 commit comments