Update Mockito, JUnit and use MockitoExtensions in itests (#9702)

* Updates Mockito to 3.7.0
* Updates JUnit to 5.7.0
* Use MockitoExtensions where possible

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born
2021-01-06 14:30:40 +01:00
committed by GitHub
parent 8f84646ed1
commit 0816045a59
20 changed files with 148 additions and 165 deletions

View File

@@ -16,15 +16,15 @@ import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.openMocks;
import javax.ws.rs.client.ClientBuilder;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.nest.internal.config.NestBridgeConfiguration;
import org.openhab.binding.nest.internal.handler.NestBridgeHandler;
import org.openhab.binding.nest.internal.handler.NestRedirectUrlSupplier;
@@ -42,12 +42,11 @@ import org.osgi.service.jaxrs.client.SseEventSourceFactory;
*
* @author David Bennett - Initial contribution
*/
@ExtendWith(MockitoExtension.class)
public class NestBridgeHandlerTest {
private ThingHandler handler;
private AutoCloseable mocksCloseable;
private @Mock Bridge bridge;
private @Mock ThingHandlerCallback callback;
private @Mock ClientBuilder clientBuilder;
@@ -57,16 +56,10 @@ public class NestBridgeHandlerTest {
@BeforeEach
public void beforeEach() {
mocksCloseable = openMocks(this);
handler = new NestTestBridgeHandler(bridge, clientBuilder, eventSourceFactory, "http://localhost");
handler.setCallback(callback);
}
@AfterEach
public void afterEach() throws Exception {
mocksCloseable.close();
}
@SuppressWarnings("null")
@Test
public void initializeShouldCallTheCallback() {