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:
@@ -26,7 +26,6 @@ Fragment-Host: org.openhab.binding.tradfri
|
||||
com.google.gson;version='[2.8.2,2.8.3)',\
|
||||
javax.jmdns;version='[3.5.6,3.5.7)',\
|
||||
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
|
||||
org.objenesis;version='[2.6.0,2.6.1)',\
|
||||
tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\
|
||||
tec.uom.se;version='[1.0.10,1.0.11)',\
|
||||
org.eclipse.jetty.http;version='[9.4.20,9.4.21)',\
|
||||
@@ -40,15 +39,7 @@ Fragment-Host: org.openhab.binding.tradfri
|
||||
org.eclipse.californium.scandium;version='[2.0.0,2.0.1)',\
|
||||
ch.qos.logback.classic;version='[1.2.3,1.2.4)',\
|
||||
biz.aQute.tester.junit-platform;version='[5.1.2,5.1.3)',\
|
||||
junit-jupiter-api;version='[5.6.2,5.6.3)',\
|
||||
junit-jupiter-engine;version='[5.6.2,5.6.3)',\
|
||||
junit-platform-commons;version='[1.6.2,1.6.3)',\
|
||||
junit-platform-engine;version='[1.6.2,1.6.3)',\
|
||||
junit-platform-launcher;version='[1.6.2,1.6.3)',\
|
||||
net.bytebuddy.byte-buddy;version='[1.10.13,1.10.14)',\
|
||||
net.bytebuddy.byte-buddy-agent;version='[1.10.13,1.10.14)',\
|
||||
org.hamcrest;version='[2.2.0,2.2.1)',\
|
||||
org.mockito.mockito-core;version='[3.4.6,3.4.7)',\
|
||||
org.opentest4j;version='[1.2.0,1.2.1)',\
|
||||
com.sun.xml.bind.jaxb-osgi;version='[2.3.3,2.3.4)',\
|
||||
jakarta.xml.bind-api;version='[2.3.3,2.3.4)',\
|
||||
@@ -67,4 +58,14 @@ Fragment-Host: org.openhab.binding.tradfri
|
||||
org.openhab.core.test;version='[3.1.0,3.1.1)',\
|
||||
org.openhab.core.thing;version='[3.1.0,3.1.1)',\
|
||||
org.openhab.core.thing.xml;version='[3.1.0,3.1.1)',\
|
||||
xstream;version='[1.4.15,1.4.16)'
|
||||
xstream;version='[1.4.15,1.4.16)',\
|
||||
junit-jupiter-api;version='[5.7.0,5.7.1)',\
|
||||
junit-jupiter-engine;version='[5.7.0,5.7.1)',\
|
||||
junit-platform-commons;version='[1.7.0,1.7.1)',\
|
||||
junit-platform-engine;version='[1.7.0,1.7.1)',\
|
||||
junit-platform-launcher;version='[1.7.0,1.7.1)',\
|
||||
net.bytebuddy.byte-buddy;version='[1.10.19,1.10.20)',\
|
||||
net.bytebuddy.byte-buddy-agent;version='[1.10.19,1.10.20)',\
|
||||
org.mockito.junit-jupiter;version='[3.7.0,3.7.1)',\
|
||||
org.mockito.mockito-core;version='[3.7.0,3.7.1)',\
|
||||
org.objenesis;version='[3.1.0,3.1.1)'
|
||||
|
||||
@@ -16,15 +16,17 @@ import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.mockito.MockitoAnnotations.openMocks;
|
||||
import static org.openhab.binding.tradfri.internal.TradfriBindingConstants.*;
|
||||
|
||||
import javax.jmdns.ServiceInfo;
|
||||
|
||||
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.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
import org.openhab.core.config.discovery.DiscoveryResult;
|
||||
import org.openhab.core.config.discovery.DiscoveryResultFlag;
|
||||
import org.openhab.core.config.discovery.mdns.MDNSDiscoveryParticipant;
|
||||
@@ -37,19 +39,17 @@ import org.openhab.core.thing.ThingUID;
|
||||
*
|
||||
* @author Kai Kreuzer - Initial contribution
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.WARN)
|
||||
public class TradfriDiscoveryParticipantOSGITest extends JavaOSGiTest {
|
||||
|
||||
private MDNSDiscoveryParticipant discoveryParticipant;
|
||||
|
||||
private AutoCloseable mocksCloseable;
|
||||
|
||||
private @Mock ServiceInfo tradfriGateway;
|
||||
private @Mock ServiceInfo otherDevice;
|
||||
|
||||
@BeforeEach
|
||||
public void beforeEach() {
|
||||
mocksCloseable = openMocks(this);
|
||||
|
||||
discoveryParticipant = getService(MDNSDiscoveryParticipant.class, TradfriDiscoveryParticipant.class);
|
||||
|
||||
when(tradfriGateway.getType()).thenReturn("_coap._udp.local.");
|
||||
@@ -65,11 +65,6 @@ public class TradfriDiscoveryParticipantOSGITest extends JavaOSGiTest {
|
||||
when(otherDevice.getPropertyString("version")).thenReturn("1.1");
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
public void afterEach() throws Exception {
|
||||
mocksCloseable.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctSupportedTypes() {
|
||||
assertThat(discoveryParticipant.getSupportedThingTypeUIDs().size(), is(1));
|
||||
|
||||
Reference in New Issue
Block a user