update
This commit is contained in:
@@ -23,7 +23,7 @@ public class HeuristicEventMatchingEngine implements EventMatchingEngine {
|
|||||||
boolean hasPolyMatch = false;
|
boolean hasPolyMatch = false;
|
||||||
for (String pe : polyEvents) {
|
for (String pe : polyEvents) {
|
||||||
if (pe.contains(".") && smEventRaw.contains(".")) {
|
if (pe.contains(".") && smEventRaw.contains(".")) {
|
||||||
if (smEventRaw.equals(pe) || smEventRaw.endsWith("." + pe)) {
|
if (smEventRaw.equals(pe) || smEventRaw.endsWith("." + pe) || pe.endsWith("." + smEventRaw)) {
|
||||||
hasPolyMatch = true;
|
hasPolyMatch = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public class HeuristicEventMatchingEngine implements EventMatchingEngine {
|
|||||||
if (polyEvents.isEmpty() && isWildcard) return true;
|
if (polyEvents.isEmpty() && isWildcard) return true;
|
||||||
|
|
||||||
if (rawTriggerEvent.contains(".") && smEventRaw.contains(".")) {
|
if (rawTriggerEvent.contains(".") && smEventRaw.contains(".")) {
|
||||||
if (smEventRaw.equals(rawTriggerEvent) || smEventRaw.endsWith("." + rawTriggerEvent)) {
|
if (smEventRaw.equals(rawTriggerEvent) || smEventRaw.endsWith("." + rawTriggerEvent) || rawTriggerEvent.endsWith("." + smEventRaw)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -75,4 +75,17 @@ class HeuristicEventMatchingEngineTest {
|
|||||||
|
|
||||||
assertThat(engine.matches(smEvent, triggerPoint)).isTrue();
|
assertThat(engine.matches(smEvent, triggerPoint)).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldMatchBidirectionalFqnAndShortName() {
|
||||||
|
// Case 1: smEvent is short, trigger event is FQN
|
||||||
|
Event smEvent1 = Event.of("PAY", "OrderEvents.PAY");
|
||||||
|
TriggerPoint triggerPoint1 = TriggerPoint.builder().event("com.example.OrderEvents.PAY").build();
|
||||||
|
assertThat(engine.matches(smEvent1, triggerPoint1)).isTrue();
|
||||||
|
|
||||||
|
// Case 2: smEvent is short, polymorphic event is FQN
|
||||||
|
Event smEvent2 = Event.of("PAY", "OrderEvents.PAY");
|
||||||
|
TriggerPoint triggerPoint2 = TriggerPoint.builder().event("getType()").polymorphicEvents(List.of("com.example.OrderEvents.PAY")).build();
|
||||||
|
assertThat(engine.matches(smEvent2, triggerPoint2)).isTrue();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user