@@ -110,7 +110,30 @@ void handlersAreRegistered() {
110110
111111 var handlerSize = 8 ;
112112 verify (configurer , times (handlerSize )).eventHandler (handlerArgumentCaptor .capture ());
113- var handlers = handlerArgumentCaptor .getAllValues ();
113+ checkHandlers (handlerArgumentCaptor .getAllValues (), handlerSize );
114+ }
115+
116+ @ Test
117+ void handlersAreRegisteredWithoutOutboxService () {
118+ when (serviceCatalog .getService (PersistenceService .class , PersistenceService .DEFAULT_NAME ))
119+ .thenReturn (persistenceService );
120+ when (serviceCatalog .getService (AttachmentService .class , AttachmentService .DEFAULT_NAME ))
121+ .thenReturn (attachmentService );
122+ when (serviceCatalog .getServices (DraftService .class )).thenReturn (Stream .of (draftService ));
123+ when (serviceCatalog .getServices (ApplicationService .class ))
124+ .thenReturn (Stream .of (applicationService ));
125+ // Return null for OutboxService to test the missing branch
126+ when (serviceCatalog .getService (OutboxService .class , OutboxService .PERSISTENT_UNORDERED_NAME ))
127+ .thenReturn (null );
128+
129+ cut .eventHandlers (configurer );
130+
131+ var handlerSize = 8 ;
132+ verify (configurer , times (handlerSize )).eventHandler (handlerArgumentCaptor .capture ());
133+ checkHandlers (handlerArgumentCaptor .getAllValues (), handlerSize );
134+ }
135+
136+ private void checkHandlers (List <EventHandler > handlers , int handlerSize ) {
114137 assertThat (handlers ).hasSize (handlerSize );
115138 isHandlerForClassIncluded (handlers , DefaultAttachmentsServiceHandler .class );
116139 isHandlerForClassIncluded (handlers , CreateAttachmentsHandler .class );
@@ -162,4 +185,5 @@ private void isHandlerForClassMissing(
162185 handlers .stream ().anyMatch (handler -> handler .getClass () == includedClass );
163186 assertThat (isHandlerIncluded ).isFalse ();
164187 }
188+
165189}
0 commit comments