diff --git a/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java b/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java index dfe4726..cc9a525 100644 --- a/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java +++ b/src/test/java/com/lmax/disruptor/spring/boot/DisruptorEventHandlerCreaterTest.java @@ -170,16 +170,40 @@ void create_withDefinitionsWithStringAndMatchingHandler_shouldParseIni() { } @Test - void emptyDefinitionStringUsesDefinitionMap() { + void emptyDefinitionStringRoutesThroughDefinitionMap() throws Exception { DisruptorEventHandlerCreater creater = new DisruptorEventHandlerCreater(mock(ApplicationContext.class)); EventHandlerDefinition definition = new EventHandlerDefinition(); definition.setDefinitions(""); definition.setOrder(0); - definition.setDefinitionMap(Map.of("/**", "handler1")); - Map> handlers = Map.of( - "handler1", mock(DisruptorHandler.class)); + definition.setDefinitionMap(Map.of("orders/**", "mapped")); + DisruptorHandler mapped = mock(DisruptorHandler.class); + DisruptorEventDispatcher dispatcher = creater.createDisruptorEventHandler( + definition, Map.of("mapped", mapped)); + + DisruptorEvent event = new DisruptorEvent(); + event.setNamespace("orders"); + event.setTopic("created"); + dispatcher.onEvent(event, 0L, true); + verify(mapped).doHandler(eq(event), any()); + } - assertThat(creater.createDisruptorEventHandler(definition, handlers)).isNotNull(); + @Test + void explicitDefinitionStringRoutesBeforeDefinitionMap() throws Exception { + DisruptorEventHandlerCreater creater = new DisruptorEventHandlerCreater(mock(ApplicationContext.class)); + EventHandlerDefinition definition = new EventHandlerDefinition(); + definition.setDefinitions("[urls]\norders/** = explicit"); + definition.setDefinitionMap(Map.of("orders/**", "fallback")); + DisruptorHandler explicit = mock(DisruptorHandler.class); + DisruptorHandler fallback = mock(DisruptorHandler.class); + DisruptorEventDispatcher dispatcher = creater.createDisruptorEventHandler( + definition, Map.of("explicit", explicit, "fallback", fallback)); + + DisruptorEvent event = new DisruptorEvent(); + event.setNamespace("orders"); + event.setTopic("created"); + dispatcher.onEvent(event, 0L, true); + verify(explicit).doHandler(eq(event), any()); + verifyNoInteractions(fallback); } @Test