Inject EventPublisher dependency into ChatServiceTest setup for enhanced test isolation and mocking.

This commit is contained in:
akastijn 2026-08-02 17:21:17 +02:00
parent 4f67228c39
commit 9757ce2ffa

View File

@ -3,6 +3,7 @@ package com.alttd.altitudeweb.services.chat;
import com.alttd.altitudeweb.controllers.chat.ChatMessage; import com.alttd.altitudeweb.controllers.chat.ChatMessage;
import com.alttd.altitudeweb.controllers.chat.ChatMessageType; import com.alttd.altitudeweb.controllers.chat.ChatMessageType;
import com.alttd.altitudeweb.model.PermissionClaimDto; import com.alttd.altitudeweb.model.PermissionClaimDto;
import com.alttd.altitudeweb.services.chat.event_publisher.EventPublisher;
import com.alttd.altitudeweb.services.chat.event_publisher.EventUser; import com.alttd.altitudeweb.services.chat.event_publisher.EventUser;
import com.alttd.altitudeweb.services.chat.event_publisher.MessageForUser; import com.alttd.altitudeweb.services.chat.event_publisher.MessageForUser;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -25,7 +26,8 @@ class ChatServiceTest {
@BeforeEach @BeforeEach
void setUp() { void setUp() {
chatService = spy(new ChatService()); EventPublisher eventPublisher = mock(EventPublisher.class);
chatService = spy(new ChatService(eventPublisher));
ReflectionTestUtils.setField(chatService, "allowedServers", new String[]{"server1"}); ReflectionTestUtils.setField(chatService, "allowedServers", new String[]{"server1"});
} }