test: updated test for UserManager

This commit is contained in:
Yannik Bretschneider 2021-06-06 19:27:50 +02:00
parent e544c00d2e
commit 36285238ec

View File

@ -9,6 +9,8 @@ import uulm.teamname.marvelous.gamelibrary.messages.ParticipantType;
import uulm.teamname.marvelous.gamelibrary.messages.client.*; import uulm.teamname.marvelous.gamelibrary.messages.client.*;
import uulm.teamname.marvelous.server.lobbymanager.Participant; import uulm.teamname.marvelous.server.lobbymanager.Participant;
import java.lang.reflect.InvocationTargetException;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.assertj.core.api.Assertions.*; import static org.assertj.core.api.Assertions.*;
@ -21,10 +23,13 @@ class UserManagerTest {
ClientHandshake handshake; ClientHandshake handshake;
@BeforeEach @BeforeEach
void beforeEach() { void beforeEach()
throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
connection = mock(WebSocket.class); connection = mock(WebSocket.class);
// when(connection.hashCode()).thenReturn(1); // just for testing, of course
manager = spy(new UserManager()); var constructor = UserManager.class.getDeclaredConstructor();
constructor.setAccessible(true);
manager = spy(constructor.newInstance());
handshake = mock(ClientHandshake.class); handshake = mock(ClientHandshake.class);
when(handshake.getResourceDescriptor()).thenReturn("/someDescriptor"); when(handshake.getResourceDescriptor()).thenReturn("/someDescriptor");