update number 3
This commit is contained in:
@@ -69,6 +69,16 @@ public class StrictFqnMatchingEngine implements EventMatchingEngine {
|
|||||||
|
|
||||||
if (!tConst.equals(smConst)) return false;
|
if (!tConst.equals(smConst)) return false;
|
||||||
|
|
||||||
|
// Prevent matching string/primitive triggers to enum transitions
|
||||||
|
if (isStringTypeOrPrimitive(eventTypeFqn) && smEvent.contains(".")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prevent matching enum triggers to string transitions
|
||||||
|
if (!smEvent.contains(".") && triggerEvent.contains(".")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (eventTypeFqn != null && eventTypeFqn.contains(".") && smEvent.contains(".")) {
|
if (eventTypeFqn != null && eventTypeFqn.contains(".") && smEvent.contains(".")) {
|
||||||
String fullTriggerFqn = eventTypeFqn + "." + tConst;
|
String fullTriggerFqn = eventTypeFqn + "." + tConst;
|
||||||
return fullTriggerFqn.equals(smEvent);
|
return fullTriggerFqn.equals(smEvent);
|
||||||
@@ -85,6 +95,12 @@ public class StrictFqnMatchingEngine implements EventMatchingEngine {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isStringTypeOrPrimitive(String typeFqn) {
|
||||||
|
if (typeFqn == null) return false;
|
||||||
|
return typeFqn.equals("String") || typeFqn.equals("java.lang.String") ||
|
||||||
|
typeFqn.equals("int") || typeFqn.equals("long") || typeFqn.equals("char");
|
||||||
|
}
|
||||||
|
|
||||||
private boolean isWildcardVariable(String eventStr) {
|
private boolean isWildcardVariable(String eventStr) {
|
||||||
if (eventStr == null) return false;
|
if (eventStr == null) return false;
|
||||||
|
|
||||||
|
|||||||
@@ -118,4 +118,26 @@ class StrictFqnMatchingEngineTest {
|
|||||||
|
|
||||||
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
|
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNotMatchStringTypeToEnumFqn() {
|
||||||
|
Event smEvent = Event.of("PAY", "com.example.OrderEvents.PAY");
|
||||||
|
TriggerPoint triggerPoint = TriggerPoint.builder()
|
||||||
|
.event("PAY")
|
||||||
|
.eventTypeFqn("java.lang.String")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void shouldNotMatchEnumTypeToStringFqn() {
|
||||||
|
Event smEvent = Event.of("PAY", "PAY");
|
||||||
|
TriggerPoint triggerPoint = TriggerPoint.builder()
|
||||||
|
.event("OrderEvents.PAY")
|
||||||
|
.eventTypeFqn("com.example.OrderEvents")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
assertThat(engine.matches(smEvent, triggerPoint)).isFalse();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user