Skip to content

Commit

Permalink
Fix WebSocketClientFactoryTest
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Hernán Carle <pablo.carle@broadcom.com>
  • Loading branch information
Pablo Hernán Carle committed Aug 23, 2024
1 parent 458e694 commit 7221a3f
Showing 1 changed file with 19 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,44 @@

package org.zowe.apiml.gateway.ws;

import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.test.util.ReflectionTestUtils;
import org.springframework.web.socket.client.jetty.JettyWebSocketClient;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertSame;
import static org.mockito.Mockito.*;

import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;

@ExtendWith(MockitoExtension.class)
class WebSocketClientFactoryTest {

@Nested
class CreatedInstance {

private WebSocketClientFactory webSocketClientFactory;
@Mock
private JettyWebSocketClient client;

private WebSocketClientFactory webSocketClientFactory;

@BeforeEach
void setUp() {
this.client = mock(JettyWebSocketClient.class);
this.webSocketClientFactory = new WebSocketClientFactory(null, 0, 0, 0, 0, 0);
ConcurrentMap<String, JettyWebSocketClient> clients = new ConcurrentHashMap<>();
clients.put("key", client);
ReflectionTestUtils.setField(webSocketClientFactory, "clientsMap", clients);
}

@Test
Expand Down

0 comments on commit 7221a3f

Please sign in to comment.