Migrate tests to JUnit 5 (#8519)

Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
Wouter Born 2020-09-21 18:21:26 +02:00 committed by GitHub
parent 6df6783b60
commit bd82ca82df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
478 changed files with 3996 additions and 4419 deletions

View File

@ -12,15 +12,15 @@
*/ */
package org.openhab.binding.astro.internal.calc; package org.openhab.binding.astro.internal.calc;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.util.Calendar; import java.util.Calendar;
import java.util.GregorianCalendar; import java.util.GregorianCalendar;
import java.util.TimeZone; import java.util.TimeZone;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.astro.internal.model.Sun; import org.openhab.binding.astro.internal.model.Sun;
import org.openhab.binding.astro.internal.model.SunPhaseName; import org.openhab.binding.astro.internal.model.SunPhaseName;
@ -51,7 +51,7 @@ public class SunCalcTest {
private SunCalc sunCalc; private SunCalc sunCalc;
@Before @BeforeEach
public void init() { public void init() {
sunCalc = new SunCalc(); sunCalc = new SunCalc();
} }
@ -178,7 +178,7 @@ public class SunCalcTest {
} }
@Test @Test
@Ignore @Disabled
public void testRangesForCoherenceBetweenNightEndAndAstroDawnStart() { public void testRangesForCoherenceBetweenNightEndAndAstroDawnStart() {
Sun sun = sunCalc.getSunInfo(FEB_27_2019, AMSTERDAM_LATITUDE, AMSTERDAM_LONGITUDE, AMSTERDAM_ALTITUDE, false); Sun sun = sunCalc.getSunInfo(FEB_27_2019, AMSTERDAM_LATITUDE, AMSTERDAM_LONGITUDE, AMSTERDAM_ALTITUDE, false);

View File

@ -12,12 +12,12 @@
*/ */
package org.openhab.binding.astro.internal.model; package org.openhab.binding.astro.internal.model;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.time.ZoneId; import java.time.ZoneId;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.astro.internal.config.AstroChannelConfig; import org.openhab.binding.astro.internal.config.AstroChannelConfig;
import org.openhab.binding.astro.internal.util.PropertyUtils; import org.openhab.binding.astro.internal.util.PropertyUtils;
import org.openhab.core.library.types.StringType; import org.openhab.core.library.types.StringType;
@ -39,7 +39,7 @@ public class SunTest {
private static ZoneId ZONE = ZoneId.systemDefault(); private static ZoneId ZONE = ZoneId.systemDefault();
@Before @BeforeEach
public void init() { public void init() {
sun = new Sun(); sun = new Sun();
config = new AstroChannelConfig(); config = new AstroChannelConfig();
@ -68,13 +68,14 @@ public class SunTest {
PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE)); PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE));
} }
@Test(expected = NullPointerException.class) @Test
public void testGetStateWhenNullPhase() throws Exception { public void testGetStateWhenNullPhase() throws Exception {
sun.setPhase(null); sun.setPhase(null);
assertNull(sun.getPhase()); assertNull(sun.getPhase());
assertEquals(UnDefType.UNDEF,
PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE)); assertThrows(NullPointerException.class, () -> assertEquals(UnDefType.UNDEF,
PropertyUtils.getState(new ChannelUID("astro:sun:home:phase#name"), config, sun, ZONE)));
} }
@Test @Test

View File

@ -12,11 +12,13 @@
*/ */
package org.openhab.binding.avmfritz.actions; package org.openhab.binding.avmfritz.actions;
import static org.mockito.MockitoAnnotations.initMocks; import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.avmfritz.internal.handler.AVMFritzHeatingActionsHandler; import org.openhab.binding.avmfritz.internal.handler.AVMFritzHeatingActionsHandler;
import org.openhab.core.thing.binding.ThingActions; import org.openhab.core.thing.binding.ThingActions;
import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandler;
@ -26,6 +28,7 @@ import org.openhab.core.thing.binding.ThingHandler;
* *
* @author Christoph Weitkamp - Initial contribution * @author Christoph Weitkamp - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
public class AVMFritzHeatingActionsTest { public class AVMFritzHeatingActionsTest {
private final ThingActions thingActionsStub = new ThingActions() { private final ThingActions thingActionsStub = new ThingActions() {
@ -43,32 +46,32 @@ public class AVMFritzHeatingActionsTest {
private AVMFritzHeatingActions heatingActions; private AVMFritzHeatingActions heatingActions;
@Before @BeforeEach
public void setUp() { public void setUp() {
initMocks(this);
heatingActions = new AVMFritzHeatingActions(); heatingActions = new AVMFritzHeatingActions();
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetBoostModeThingActionsIsNull() { public void testSetBoostModeThingActionsIsNull() {
AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L)); assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(null, Long.valueOf(5L)));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetBoostModeThingActionsIsNotPushoverThingActions() { public void testSetBoostModeThingActionsIsNotPushoverThingActions() {
AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L)); assertThrows(IllegalArgumentException.class,
() -> AVMFritzHeatingActions.setBoostMode(thingActionsStub, Long.valueOf(5L)));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetBoostModeThingHandlerIsNull() { public void testSetBoostModeThingHandlerIsNull() {
AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L)); assertThrows(IllegalArgumentException.class,
() -> AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L)));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetBoostModeDurationNull() { public void testSetBoostModeDurationNull() {
heatingActions.setThingHandler(heatingActionsHandler); heatingActions.setThingHandler(heatingActionsHandler);
AVMFritzHeatingActions.setBoostMode(heatingActions, null); assertThrows(IllegalArgumentException.class, () -> AVMFritzHeatingActions.setBoostMode(heatingActions, null));
} }
@Test @Test
@ -77,25 +80,29 @@ public class AVMFritzHeatingActionsTest {
AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L)); AVMFritzHeatingActions.setBoostMode(heatingActions, Long.valueOf(5L));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetWindowOpenModeThingActionsIsNull() { public void testSetWindowOpenModeThingActionsIsNull() {
AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L)); assertThrows(IllegalArgumentException.class,
() -> AVMFritzHeatingActions.setWindowOpenMode(null, Long.valueOf(5L)));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetWindowOpenModeThingActionsIsNotPushoverThingActions() { public void testSetWindowOpenModeThingActionsIsNotPushoverThingActions() {
AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L)); assertThrows(IllegalArgumentException.class,
() -> AVMFritzHeatingActions.setWindowOpenMode(thingActionsStub, Long.valueOf(5L)));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetWindowOpenModeThingHandlerIsNull() { public void testSetWindowOpenModeThingHandlerIsNull() {
AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L)); assertThrows(IllegalArgumentException.class,
() -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, Long.valueOf(5L)));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSetWindowOpenModeDurationNull() { public void testSetWindowOpenModeDurationNull() {
heatingActions.setThingHandler(heatingActionsHandler); heatingActions.setThingHandler(heatingActionsHandler);
AVMFritzHeatingActions.setWindowOpenMode(heatingActions, null); assertThrows(IllegalArgumentException.class,
() -> AVMFritzHeatingActions.setWindowOpenMode(heatingActions, null));
} }
@Test @Test

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.avmfritz.internal.dto; package org.openhab.binding.avmfritz.internal.dto;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*; import static org.openhab.binding.avmfritz.internal.AVMFritzBindingConstants.*;
import java.io.StringReader; import java.io.StringReader;
@ -23,8 +23,8 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.avmfritz.internal.util.JAXBUtils; import org.openhab.binding.avmfritz.internal.util.JAXBUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -41,7 +41,7 @@ public class AVMFritzDeviceListModelTest {
private @NonNullByDefault({}) DeviceListModel devices; private @NonNullByDefault({}) DeviceListModel devices;
@Before @BeforeEach
public void setUp() { public void setUp() {
//@formatter:off //@formatter:off
String xml = String xml =

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.avmfritz.internal.dto; package org.openhab.binding.avmfritz.internal.dto;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.io.StringReader; import java.io.StringReader;
import java.util.Optional; import java.util.Optional;
@ -21,8 +21,8 @@ import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller; import javax.xml.bind.Unmarshaller;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.avmfritz.internal.dto.templates.TemplateListModel; import org.openhab.binding.avmfritz.internal.dto.templates.TemplateListModel;
import org.openhab.binding.avmfritz.internal.dto.templates.TemplateModel; import org.openhab.binding.avmfritz.internal.dto.templates.TemplateModel;
import org.openhab.binding.avmfritz.internal.util.JAXBUtils; import org.openhab.binding.avmfritz.internal.util.JAXBUtils;
@ -41,7 +41,7 @@ public class AVMFritzTemplateListModelTest {
private @NonNullByDefault({}) TemplateListModel templates; private @NonNullByDefault({}) TemplateListModel templates;
@Before @BeforeEach
public void setUp() { public void setUp() {
//@formatter:off //@formatter:off
String xml = String xml =

View File

@ -12,12 +12,12 @@
*/ */
package org.openhab.binding.avmfritz.internal.dto; package org.openhab.binding.avmfritz.internal.dto;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests for {@link HeatingModel} methods. * Tests for {@link HeatingModel} methods.

View File

@ -12,10 +12,10 @@
*/ */
package org.openhab.binding.bluetooth.airthings; package org.openhab.binding.bluetooth.airthings;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.bluetooth.airthings.internal.AirthingsParserException; import org.openhab.binding.bluetooth.airthings.internal.AirthingsParserException;
import org.openhab.binding.bluetooth.airthings.internal.AirthingsWavePlusDataParser; import org.openhab.binding.bluetooth.airthings.internal.AirthingsWavePlusDataParser;
@ -27,22 +27,22 @@ import org.openhab.binding.bluetooth.airthings.internal.AirthingsWavePlusDataPar
@NonNullByDefault @NonNullByDefault
public class AirthingsWavePlusParserTest { public class AirthingsWavePlusParserTest {
@Test(expected = AirthingsParserException.class) @Test
public void testWrongVersion() throws AirthingsParserException { public void testWrongVersion() {
int[] data = { 5, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0, 0, 4, 20 }; int[] data = { 5, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0, 0, 4, 20 };
new AirthingsWavePlusDataParser(data); assertThrows(AirthingsParserException.class, () -> new AirthingsWavePlusDataParser(data));
} }
@Test(expected = AirthingsParserException.class) @Test
public void testEmptyData() throws AirthingsParserException { public void testEmptyData() {
int[] data = {}; int[] data = {};
new AirthingsWavePlusDataParser(data); assertThrows(AirthingsParserException.class, () -> new AirthingsWavePlusDataParser(data));
} }
@Test(expected = AirthingsParserException.class) @Test
public void testWrongDataLen() throws AirthingsParserException { public void testWrongDataLen() throws AirthingsParserException {
int[] data = { 1, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0 }; int[] data = { 1, 55, 51, 0, 122, 0, 61, 0, 119, 9, 11, 194, 169, 2, 46, 0, 0 };
new AirthingsWavePlusDataParser(data); assertThrows(AirthingsParserException.class, () -> new AirthingsWavePlusDataParser(data));
} }
@Test @Test

View File

@ -12,9 +12,10 @@
*/ */
package org.openhab.binding.bluetooth.am43; package org.openhab.binding.bluetooth.am43;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Assert; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.openhab.binding.bluetooth.am43.internal.command.ControlCommand; import org.openhab.binding.bluetooth.am43.internal.command.ControlCommand;
import org.openhab.binding.bluetooth.am43.internal.command.GetAllCommand; import org.openhab.binding.bluetooth.am43.internal.command.GetAllCommand;
import org.openhab.binding.bluetooth.am43.internal.data.ControlAction; import org.openhab.binding.bluetooth.am43.internal.data.ControlAction;
@ -31,7 +32,7 @@ public class CommandTest {
public void findAllCommandTest() { public void findAllCommandTest() {
byte[] expected = HexUtils.hexToBytes("00ff00009aa701013d"); byte[] expected = HexUtils.hexToBytes("00ff00009aa701013d");
byte[] actual = new GetAllCommand().getRequest(); byte[] actual = new GetAllCommand().getRequest();
Assert.assertArrayEquals(expected, actual); assertArrayEquals(expected, actual);
} }
@Test @Test
@ -39,7 +40,7 @@ public class CommandTest {
byte[] expected = HexUtils.hexToBytes("00ff00009a0a01cc5d"); byte[] expected = HexUtils.hexToBytes("00ff00009a0a01cc5d");
byte[] actual = new ControlCommand(ControlAction.STOP).getRequest(); byte[] actual = new ControlCommand(ControlAction.STOP).getRequest();
Assert.assertArrayEquals(expected, actual); assertArrayEquals(expected, actual);
} }
@Test @Test
@ -47,6 +48,6 @@ public class CommandTest {
byte[] expected = HexUtils.hexToBytes("00ff00009a0a01dd4c"); byte[] expected = HexUtils.hexToBytes("00ff00009a0a01dd4c");
byte[] actual = new ControlCommand(ControlAction.OPEN).getRequest(); byte[] actual = new ControlCommand(ControlAction.OPEN).getRequest();
Assert.assertArrayEquals(expected, actual); assertArrayEquals(expected, actual);
} }
} }

View File

@ -12,10 +12,10 @@
*/ */
package org.openhab.binding.bluetooth.bluegiga.internal.attributeclient; package org.openhab.binding.bluetooth.bluegiga.internal.attributeclient;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.bluetooth.bluegiga.internal.command.attributeclient.BlueGigaFindInformationFoundEvent; import org.openhab.binding.bluetooth.bluegiga.internal.command.attributeclient.BlueGigaFindInformationFoundEvent;
/** /**

View File

@ -12,14 +12,14 @@
*/ */
package org.openhab.binding.bluetooth.bluegiga.internal.eir; package org.openhab.binding.bluetooth.bluegiga.internal.eir;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests {@link EirRecord}. * Tests {@link EirRecord}.

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.bluetooth.daikinmadoka.internal; package org.openhab.binding.bluetooth.daikinmadoka.internal;
import static org.junit.Assert.assertArrayEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage; import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage;
import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaValue; import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaValue;
import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetIndoorOutoorTemperatures; import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetIndoorOutoorTemperatures;

View File

@ -12,7 +12,9 @@
*/ */
package org.openhab.binding.bluetooth; package org.openhab.binding.bluetooth;
import org.junit.Test; import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.Test;
/** /**
* Tests {@link BluetoothAddress}. * Tests {@link BluetoothAddress}.
@ -21,14 +23,14 @@ import org.junit.Test;
*/ */
public class BluetoothAddressTest { public class BluetoothAddressTest {
@Test(expected = IllegalArgumentException.class) @Test
public void testConstructorWithNullParam() { public void testConstructorWithNullParam() {
new BluetoothAddress(null); assertThrows(IllegalArgumentException.class, () -> new BluetoothAddress(null));
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testConstructorWithoutColons() { public void testConstructorWithoutColons() {
new BluetoothAddress("123456789ABC"); assertThrows(IllegalArgumentException.class, () -> new BluetoothAddress("123456789ABC"));
} }
@Test @Test

View File

@ -13,6 +13,8 @@
package org.openhab.binding.bluetooth.discovery.internal; package org.openhab.binding.bluetooth.discovery.internal;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -25,16 +27,18 @@ import org.apache.commons.lang.RandomStringUtils;
import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Assert; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.runner.RunWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers; import org.mockito.ArgumentMatchers;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.Spy; import org.mockito.Spy;
import org.mockito.junit.MockitoJUnitRunner; import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.openhab.binding.bluetooth.BluetoothAdapter; import org.openhab.binding.bluetooth.BluetoothAdapter;
import org.openhab.binding.bluetooth.BluetoothAddress; import org.openhab.binding.bluetooth.BluetoothAddress;
import org.openhab.binding.bluetooth.BluetoothBindingConstants; import org.openhab.binding.bluetooth.BluetoothBindingConstants;
@ -59,8 +63,10 @@ import org.slf4j.LoggerFactory;
* *
* @author Connor Petty - Initial contribution * @author Connor Petty - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.WARN)
@NonNullByDefault @NonNullByDefault
@RunWith(MockitoJUnitRunner.class) @Disabled("Needs to be updated for OH3")
public class BluetoothDiscoveryServiceTest { public class BluetoothDiscoveryServiceTest {
private static final int TIMEOUT = 2000; private static final int TIMEOUT = 2000;
@ -69,13 +75,10 @@ public class BluetoothDiscoveryServiceTest {
private @NonNullByDefault({}) BluetoothDiscoveryService discoveryService; private @NonNullByDefault({}) BluetoothDiscoveryService discoveryService;
@Spy private @Spy @NonNullByDefault({}) MockDiscoveryParticipant participant1 = new MockDiscoveryParticipant();
private @NonNullByDefault({}) MockDiscoveryParticipant participant1 = new MockDiscoveryParticipant(); private @Mock @NonNullByDefault({}) DiscoveryListener mockDiscoveryListener;
@Mock @BeforeEach
private @NonNullByDefault({}) DiscoveryListener mockDiscoveryListener;
@Before
public void setup() { public void setup() {
discoveryService = new BluetoothDiscoveryService(); discoveryService = new BluetoothDiscoveryService();
discoveryService.addDiscoveryListener(mockDiscoveryListener); discoveryService.addDiscoveryListener(mockDiscoveryListener);
@ -185,12 +188,12 @@ public class BluetoothDiscoveryServiceTest {
DiscoveryResult result1 = results.get(0); DiscoveryResult result1 = results.get(0);
DiscoveryResult result2 = results.get(1); DiscoveryResult result2 = results.get(1);
Assert.assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID()); assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID());
Assert.assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID()))); assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID())));
Assert.assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID()))); assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(mockAdapter2.getUID())));
Assert.assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId()); assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId());
Assert.assertEquals(result1.getLabel(), result2.getLabel()); assertEquals(result1.getLabel(), result2.getLabel());
Assert.assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty()); assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty());
} }
@Test @Test
@ -308,7 +311,7 @@ public class BluetoothDiscoveryServiceTest {
DiscoveryResult result = resultCaptor.getValue(); DiscoveryResult result = resultCaptor.getValue();
Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID()); assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingRemoved( Mockito.verify(mockDiscoveryListener, Mockito.timeout(TIMEOUT).times(1)).thingRemoved(
ArgumentMatchers.same(discoveryService), ArgumentMatchers.same(discoveryService),
@ -330,7 +333,7 @@ public class BluetoothDiscoveryServiceTest {
DiscoveryResult result = resultCaptor.getValue(); DiscoveryResult result = resultCaptor.getValue();
Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID()); assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
discoveryService.deviceRemoved(device); discoveryService.deviceRemoved(device);
@ -382,7 +385,7 @@ public class BluetoothDiscoveryServiceTest {
DiscoveryResult result = resultCaptor.getValue(); DiscoveryResult result = resultCaptor.getValue();
Assert.assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID()); assertEquals(BluetoothBindingConstants.THING_TYPE_BEACON, result.getThingTypeUID());
device.setManufacturerId(10); device.setManufacturerId(10);
@ -450,7 +453,7 @@ public class BluetoothDiscoveryServiceTest {
ArgumentMatchers.same(discoveryService), ArgumentMatchers.same(discoveryService),
ArgumentMatchers.argThat(arg -> arg.getThingTypeUID().equals(participant2.typeUID))); ArgumentMatchers.argThat(arg -> arg.getThingTypeUID().equals(participant2.typeUID)));
Assert.assertEquals(1, callCount.get()); assertEquals(1, callCount.get());
} }
@Test @Test
@ -471,12 +474,12 @@ public class BluetoothDiscoveryServiceTest {
DiscoveryResult result1 = results.get(0); DiscoveryResult result1 = results.get(0);
DiscoveryResult result2 = results.get(1); DiscoveryResult result2 = results.get(1);
Assert.assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID()); assertNotEquals(result1.getBridgeUID(), result2.getBridgeUID());
Assert.assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID()))); assertThat(result1.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID())));
Assert.assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID()))); assertThat(result2.getBridgeUID(), anyOf(is(mockAdapter1.getUID()), is(roamingAdapter.getUID())));
Assert.assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId()); assertEquals(result1.getThingUID().getId(), result2.getThingUID().getId());
Assert.assertEquals(result1.getLabel(), result2.getLabel()); assertEquals(result1.getLabel(), result2.getLabel());
Assert.assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty()); assertEquals(result1.getRepresentationProperty(), result2.getRepresentationProperty());
} }
@Test @Test
@ -499,12 +502,12 @@ public class BluetoothDiscoveryServiceTest {
ThingUID result1 = results.get(0); ThingUID result1 = results.get(0);
ThingUID result2 = results.get(1); ThingUID result2 = results.get(1);
Assert.assertNotEquals(result1.getBridgeIds(), result2.getBridgeIds()); assertNotEquals(result1.getBridgeIds(), result2.getBridgeIds());
Assert.assertThat(result1.getBridgeIds().get(0), assertThat(result1.getBridgeIds().get(0),
anyOf(is(mockAdapter1.getUID().getId()), is(roamingAdapter.getUID().getId()))); anyOf(is(mockAdapter1.getUID().getId()), is(roamingAdapter.getUID().getId())));
Assert.assertThat(result2.getBridgeIds().get(0), assertThat(result2.getBridgeIds().get(0),
anyOf(is(mockAdapter1.getUID().getId()), is(roamingAdapter.getUID().getId()))); anyOf(is(mockAdapter1.getUID().getId()), is(roamingAdapter.getUID().getId())));
Assert.assertEquals(result1.getId(), result2.getId()); assertEquals(result1.getId(), result2.getId());
} }
private class RoamingDiscoveryParticipant implements BluetoothDiscoveryParticipant { private class RoamingDiscoveryParticipant implements BluetoothDiscoveryParticipant {
@ -555,7 +558,8 @@ public class BluetoothDiscoveryServiceTest {
@Override @Override
public @NonNull ThingUID getThingUID(BluetoothDiscoveryDevice device) { public @NonNull ThingUID getThingUID(BluetoothDiscoveryDevice device) {
String id = device.getName() != null ? device.getName() : RandomStringUtils.randomAlphabetic(6); String deviceName = device.getName();
String id = deviceName != null ? deviceName : RandomStringUtils.randomAlphabetic(6);
return new ThingUID(typeUID, device.getAdapter().getUID(), id); return new ThingUID(typeUID, device.getAdapter().getUID(), id);
} }
} }

View File

@ -12,11 +12,10 @@
*/ */
package org.openhab.binding.bsblan.internal; package org.openhab.binding.bsblan.internal;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertTrue;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingTypeUID;
/** /**

View File

@ -12,12 +12,10 @@
*/ */
package org.openhab.binding.bsblan.internal.api; package org.openhab.binding.bsblan.internal.api;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO; import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterQueryResponseDTO; import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterQueryResponseDTO;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterSetRequestDTO; import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterSetRequestDTO;

View File

@ -12,13 +12,11 @@
*/ */
package org.openhab.binding.bsblan.internal.helper; package org.openhab.binding.bsblan.internal.helper;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*; import static org.openhab.binding.bsblan.internal.BsbLanBindingConstants.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO; import org.openhab.binding.bsblan.internal.api.dto.BsbLanApiParameterDTO;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
@ -219,10 +217,10 @@ public class BsbLanParameterConverterTests {
@Test @Test
public void testGetValueForNumberValueChannel() { public void testGetValueForNumberValueChannel() {
assertNull("1", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.ON)); assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.ON), "1");
assertNull("0", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.OFF)); assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, OnOffType.OFF), "0");
assertEquals("42", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(42))); assertEquals(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(42)), "42");
assertEquals("22.5", BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(22.5))); assertEquals(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new DecimalType(22.5)), "22.5");
assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE,
new StringType("Not a number value"))); new StringType("Not a number value")));
assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new StringType(""))); assertNull(BsbLanParameterConverter.getValue(PARAMETER_CHANNEL_NUMBER_VALUE, new StringType("")));

View File

@ -12,14 +12,14 @@
*/ */
package org.openhab.binding.buienradar; package org.openhab.binding.buienradar;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.ZoneId; import java.time.ZoneId;
import java.time.ZonedDateTime; import java.time.ZonedDateTime;
import java.util.Optional; import java.util.Optional;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarParseException; import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarParseException;
import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI; import org.openhab.binding.buienradar.internal.buienradarapi.BuienradarPredictionAPI;
import org.openhab.binding.buienradar.internal.buienradarapi.Prediction; import org.openhab.binding.buienradar.internal.buienradarapi.Prediction;

View File

@ -12,11 +12,10 @@
*/ */
package org.openhab.binding.danfossairunit.internal; package org.openhab.binding.danfossairunit.internal;
import static org.junit.Assert.assertFalse; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertTrue;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
/** /**

View File

@ -13,16 +13,16 @@
package org.openhab.binding.darksky.internal.utils; package org.openhab.binding.darksky.internal.utils;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.junit.After; import org.junit.jupiter.api.AfterAll;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.config.core.ConfigConstants; import org.openhab.core.config.core.ConfigConstants;
/** /**
@ -45,18 +45,18 @@ public class ByteArrayFileCacheTest {
private ByteArrayFileCache subject; private ByteArrayFileCache subject;
@Before @BeforeEach
public void setUp() { public void setUp() {
subject = new ByteArrayFileCache(SERVICE_PID); subject = new ByteArrayFileCache(SERVICE_PID);
} }
@After @AfterEach
public void tearDown() { public void tearDown() {
// delete all files // delete all files
subject.clear(); subject.clear();
} }
@AfterClass @AfterAll
public static void cleanUp() { public static void cleanUp() {
// delete all folders // delete all folders
SERVICE_CACHE_FOLDER.delete(); SERVICE_CACHE_FOLDER.delete();

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.deconz; package org.openhab.binding.deconz;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.times; import static org.mockito.Mockito.times;
import static org.mockito.MockitoAnnotations.initMocks;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
@ -23,11 +23,14 @@ import java.time.ZonedDateTime;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Assert; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.openhab.binding.deconz.internal.Util; import org.openhab.binding.deconz.internal.Util;
import org.openhab.binding.deconz.internal.discovery.ThingDiscoveryService; import org.openhab.binding.deconz.internal.discovery.ThingDiscoveryService;
import org.openhab.binding.deconz.internal.dto.BridgeFullState; import org.openhab.binding.deconz.internal.dto.BridgeFullState;
@ -49,23 +52,18 @@ import com.google.gson.GsonBuilder;
* *
* @author Jan N. Klug - Initial contribution * @author Jan N. Klug - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.WARN)
@NonNullByDefault @NonNullByDefault
public class DeconzTest { public class DeconzTest {
private @NonNullByDefault({}) Gson gson; private @NonNullByDefault({}) Gson gson;
@Mock private @Mock @NonNullByDefault({}) DiscoveryListener discoveryListener;
private @NonNullByDefault({}) DiscoveryListener discoveryListener; private @Mock @NonNullByDefault({}) DeconzBridgeHandler bridgeHandler;
private @Mock @NonNullByDefault({}) Bridge bridge;
@Mock @BeforeEach
private @NonNullByDefault({}) DeconzBridgeHandler bridgeHandler;
@Mock
private @NonNullByDefault({}) Bridge bridge;
@Before
public void initialize() { public void initialize() {
initMocks(this);
Mockito.doAnswer(answer -> bridge).when(bridgeHandler).getThing(); Mockito.doAnswer(answer -> bridge).when(bridgeHandler).getThing();
Mockito.doAnswer(answer -> new ThingUID("deconz", "mybridge")).when(bridge).getUID(); Mockito.doAnswer(answer -> new ThingUID("deconz", "mybridge")).when(bridge).getUID();
@ -78,9 +76,9 @@ public class DeconzTest {
@Test @Test
public void discoveryTest() throws IOException { public void discoveryTest() throws IOException {
BridgeFullState bridgeFullState = getObjectFromJson("discovery.json", BridgeFullState.class, gson); BridgeFullState bridgeFullState = getObjectFromJson("discovery.json", BridgeFullState.class, gson);
Assert.assertNotNull(bridgeFullState); assertNotNull(bridgeFullState);
Assert.assertEquals(6, bridgeFullState.lights.size()); assertEquals(6, bridgeFullState.lights.size());
Assert.assertEquals(9, bridgeFullState.sensors.size()); assertEquals(9, bridgeFullState.sensors.size());
ThingDiscoveryService discoveryService = new ThingDiscoveryService(); ThingDiscoveryService discoveryService = new ThingDiscoveryService();
discoveryService.setThingHandler(bridgeHandler); discoveryService.setThingHandler(bridgeHandler);
@ -98,10 +96,10 @@ public class DeconzTest {
@Test @Test
public void dateTimeConversionTest() { public void dateTimeConversionTest() {
DateTimeType dateTime = Util.convertTimestampToDateTime("2020-08-22T11:09Z"); DateTimeType dateTime = Util.convertTimestampToDateTime("2020-08-22T11:09Z");
Assert.assertEquals(new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:00Z")), dateTime); assertEquals(new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:00Z")), dateTime);
dateTime = Util.convertTimestampToDateTime("2020-08-22T11:09:47"); dateTime = Util.convertTimestampToDateTime("2020-08-22T11:09:47");
Assert.assertEquals( assertEquals(new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:47Z")).toZone(ZoneId.systemDefault()),
new DateTimeType(ZonedDateTime.parse("2020-08-22T11:09:47Z")).toZone(ZoneId.systemDefault()), dateTime); dateTime);
} }
} }

View File

@ -12,9 +12,8 @@
*/ */
package org.openhab.binding.deconz; package org.openhab.binding.deconz;
import static org.mockito.ArgumentMatchers.any; import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.openhab.binding.deconz.internal.BindingConstants.*; import static org.openhab.binding.deconz.internal.BindingConstants.*;
import java.io.IOException; import java.io.IOException;
@ -23,11 +22,12 @@ import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Assert; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.deconz.internal.StateDescriptionProvider; import org.openhab.binding.deconz.internal.StateDescriptionProvider;
import org.openhab.binding.deconz.internal.dto.LightMessage; import org.openhab.binding.deconz.internal.dto.LightMessage;
import org.openhab.binding.deconz.internal.handler.LightThingHandler; import org.openhab.binding.deconz.internal.handler.LightThingHandler;
@ -53,20 +53,16 @@ import com.google.gson.GsonBuilder;
* *
* @author Jan N. Klug - Initial contribution * @author Jan N. Klug - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
@NonNullByDefault @NonNullByDefault
public class LightsTest { public class LightsTest {
private @NonNullByDefault({}) Gson gson; private @NonNullByDefault({}) Gson gson;
@Mock private @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
private @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback; private @Mock @NonNullByDefault({}) StateDescriptionProvider stateDescriptionProvider;
@Mock @BeforeEach
private @NonNullByDefault({}) StateDescriptionProvider stateDescriptionProvider;
@Before
public void initialize() { public void initialize() {
initMocks(this);
GsonBuilder gsonBuilder = new GsonBuilder(); GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LightType.class, new LightTypeDeserializer()); gsonBuilder.registerTypeAdapter(LightType.class, new LightTypeDeserializer());
gsonBuilder.registerTypeAdapter(ThermostatMode.class, new ThermostatModeGsonTypeAdapter()); gsonBuilder.registerTypeAdapter(ThermostatMode.class, new ThermostatModeGsonTypeAdapter());
@ -76,7 +72,7 @@ public class LightsTest {
@Test @Test
public void colorTemperatureLightUpdateTest() throws IOException { public void colorTemperatureLightUpdateTest() throws IOException {
LightMessage lightMessage = DeconzTest.getObjectFromJson("colortemperature.json", LightMessage.class, gson); LightMessage lightMessage = DeconzTest.getObjectFromJson("colortemperature.json", LightMessage.class, gson);
Assert.assertNotNull(lightMessage); assertNotNull(lightMessage);
ThingUID thingUID = new ThingUID("deconz", "light"); ThingUID thingUID = new ThingUID("deconz", "light");
ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS); ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@ -122,7 +118,7 @@ public class LightsTest {
@Test @Test
public void dimmableLightUpdateTest() throws IOException { public void dimmableLightUpdateTest() throws IOException {
LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable.json", LightMessage.class, gson); LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable.json", LightMessage.class, gson);
Assert.assertNotNull(lightMessage); assertNotNull(lightMessage);
ThingUID thingUID = new ThingUID("deconz", "light"); ThingUID thingUID = new ThingUID("deconz", "light");
ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS); ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@ -139,7 +135,7 @@ public class LightsTest {
@Test @Test
public void dimmableLightOverrangeUpdateTest() throws IOException { public void dimmableLightOverrangeUpdateTest() throws IOException {
LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable_overrange.json", LightMessage.class, gson); LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable_overrange.json", LightMessage.class, gson);
Assert.assertNotNull(lightMessage); assertNotNull(lightMessage);
ThingUID thingUID = new ThingUID("deconz", "light"); ThingUID thingUID = new ThingUID("deconz", "light");
ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS); ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@ -156,7 +152,7 @@ public class LightsTest {
@Test @Test
public void dimmableLightUnderrangeUpdateTest() throws IOException { public void dimmableLightUnderrangeUpdateTest() throws IOException {
LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable_underrange.json", LightMessage.class, gson); LightMessage lightMessage = DeconzTest.getObjectFromJson("dimmable_underrange.json", LightMessage.class, gson);
Assert.assertNotNull(lightMessage); assertNotNull(lightMessage);
ThingUID thingUID = new ThingUID("deconz", "light"); ThingUID thingUID = new ThingUID("deconz", "light");
ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS); ChannelUID channelUID_bri = new ChannelUID(thingUID, CHANNEL_BRIGHTNESS);
@ -173,7 +169,7 @@ public class LightsTest {
@Test @Test
public void windowCoveringUpdateTest() throws IOException { public void windowCoveringUpdateTest() throws IOException {
LightMessage lightMessage = DeconzTest.getObjectFromJson("windowcovering.json", LightMessage.class, gson); LightMessage lightMessage = DeconzTest.getObjectFromJson("windowcovering.json", LightMessage.class, gson);
Assert.assertNotNull(lightMessage); assertNotNull(lightMessage);
ThingUID thingUID = new ThingUID("deconz", "light"); ThingUID thingUID = new ThingUID("deconz", "light");
ChannelUID channelUID_pos = new ChannelUID(thingUID, CHANNEL_POSITION); ChannelUID channelUID_pos = new ChannelUID(thingUID, CHANNEL_POSITION);

View File

@ -12,18 +12,19 @@
*/ */
package org.openhab.binding.deconz; package org.openhab.binding.deconz;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.openhab.binding.deconz.internal.BindingConstants.*; import static org.openhab.binding.deconz.internal.BindingConstants.*;
import java.io.IOException; import java.io.IOException;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Assert; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.deconz.internal.dto.SensorMessage; import org.openhab.binding.deconz.internal.dto.SensorMessage;
import org.openhab.binding.deconz.internal.handler.SensorThermostatThingHandler; import org.openhab.binding.deconz.internal.handler.SensorThermostatThingHandler;
import org.openhab.binding.deconz.internal.handler.SensorThingHandler; import org.openhab.binding.deconz.internal.handler.SensorThingHandler;
@ -52,17 +53,15 @@ import com.google.gson.GsonBuilder;
* @author Jan N. Klug - Initial contribution * @author Jan N. Klug - Initial contribution
* @author Lukas Agethen - Added Thermostat * @author Lukas Agethen - Added Thermostat
*/ */
@ExtendWith(MockitoExtension.class)
@NonNullByDefault @NonNullByDefault
public class SensorsTest { public class SensorsTest {
private @NonNullByDefault({}) Gson gson; private @NonNullByDefault({}) Gson gson;
@Mock private @Mock @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
private @NonNullByDefault({}) ThingHandlerCallback thingHandlerCallback;
@Before @BeforeEach
public void initialize() { public void initialize() {
initMocks(this);
GsonBuilder gsonBuilder = new GsonBuilder(); GsonBuilder gsonBuilder = new GsonBuilder();
gsonBuilder.registerTypeAdapter(LightType.class, new LightTypeDeserializer()); gsonBuilder.registerTypeAdapter(LightType.class, new LightTypeDeserializer());
gsonBuilder.registerTypeAdapter(ThermostatMode.class, new ThermostatModeGsonTypeAdapter()); gsonBuilder.registerTypeAdapter(ThermostatMode.class, new ThermostatModeGsonTypeAdapter());
@ -72,7 +71,7 @@ public class SensorsTest {
@Test @Test
public void carbonmonoxideSensorUpdateTest() throws IOException { public void carbonmonoxideSensorUpdateTest() throws IOException {
SensorMessage sensorMessage = DeconzTest.getObjectFromJson("carbonmonoxide.json", SensorMessage.class, gson); SensorMessage sensorMessage = DeconzTest.getObjectFromJson("carbonmonoxide.json", SensorMessage.class, gson);
Assert.assertNotNull(sensorMessage); assertNotNull(sensorMessage);
ThingUID thingUID = new ThingUID("deconz", "sensor"); ThingUID thingUID = new ThingUID("deconz", "sensor");
ChannelUID channelUID = new ChannelUID(thingUID, "carbonmonoxide"); ChannelUID channelUID = new ChannelUID(thingUID, "carbonmonoxide");
@ -88,7 +87,7 @@ public class SensorsTest {
@Test @Test
public void thermostatSensorUpdateTest() throws IOException { public void thermostatSensorUpdateTest() throws IOException {
SensorMessage sensorMessage = DeconzTest.getObjectFromJson("thermostat.json", SensorMessage.class, gson); SensorMessage sensorMessage = DeconzTest.getObjectFromJson("thermostat.json", SensorMessage.class, gson);
Assert.assertNotNull(sensorMessage); assertNotNull(sensorMessage);
ThingUID thingUID = new ThingUID("deconz", "sensor"); ThingUID thingUID = new ThingUID("deconz", "sensor");
ChannelUID channelValveUID = new ChannelUID(thingUID, "valve"); ChannelUID channelValveUID = new ChannelUID(thingUID, "valve");

View File

@ -13,9 +13,9 @@
package org.openhab.binding.dmx.internal; package org.openhab.binding.dmx.internal;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dmx.internal.action.ActionState; import org.openhab.binding.dmx.internal.action.ActionState;
import org.openhab.binding.dmx.internal.action.FadeAction; import org.openhab.binding.dmx.internal.action.FadeAction;
import org.openhab.binding.dmx.internal.multiverse.DmxChannel; import org.openhab.binding.dmx.internal.multiverse.DmxChannel;

View File

@ -13,9 +13,9 @@
package org.openhab.binding.dmx.internal; package org.openhab.binding.dmx.internal;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dmx.internal.multiverse.DmxChannel; import org.openhab.binding.dmx.internal.multiverse.DmxChannel;
import org.openhab.core.library.types.PercentType; import org.openhab.core.library.types.PercentType;

View File

@ -13,11 +13,11 @@
package org.openhab.binding.dmx.internal; package org.openhab.binding.dmx.internal;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests cases ValueSet * Tests cases ValueSet

View File

@ -12,8 +12,9 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@ -21,9 +22,9 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.After; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.test.java.JavaTest; import org.openhab.core.test.java.JavaTest;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
@ -53,7 +54,7 @@ public class ArtnetBridgeHandlerTest extends JavaTest {
private Bridge bridge; private Bridge bridge;
private ArtnetBridgeHandler bridgeHandler; private ArtnetBridgeHandler bridgeHandler;
@Before @BeforeEach
public void setUp() { public void setUp() {
bridgeProperties = new HashMap<>(); bridgeProperties = new HashMap<>();
bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS); bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
@ -79,7 +80,7 @@ public class ArtnetBridgeHandlerTest extends JavaTest {
bridgeHandler.initialize(); bridgeHandler.initialize();
} }
@After @AfterEach
public void tearDown() { public void tearDown() {
bridgeHandler.dispose(); bridgeHandler.dispose();
} }

View File

@ -13,8 +13,8 @@
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@ -24,8 +24,8 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dmx.test.AbstractDmxThingTestParent; import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
import org.openhab.binding.dmx.test.TestBridgeHandler; import org.openhab.binding.dmx.test.TestBridgeHandler;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
@ -61,7 +61,7 @@ public class ChaserThingHandlerTest extends AbstractDmxThingTestParent {
private TestBridgeHandler dmxBridgeHandler; private TestBridgeHandler dmxBridgeHandler;
private ChaserThingHandler chaserThingHandler; private ChaserThingHandler chaserThingHandler;
@Before @BeforeEach
public void setUp() { public void setUp() {
super.setup(); super.setup();

View File

@ -12,17 +12,18 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.hamcrest.number.IsCloseTo.closeTo; import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dmx.test.AbstractDmxThingTestParent; import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;
@ -58,7 +59,7 @@ public class ColorThingHandlerTest extends AbstractDmxThingTestParent {
private final ChannelUID CHANNEL_UID_BRIGHTNESS_G = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_G); private final ChannelUID CHANNEL_UID_BRIGHTNESS_G = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_G);
private final ChannelUID CHANNEL_UID_BRIGHTNESS_B = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_B); private final ChannelUID CHANNEL_UID_BRIGHTNESS_B = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_B);
@Before @BeforeEach
public void setUp() { public void setUp() {
super.setup(); super.setup();
thingProperties = new HashMap<>(); thingProperties = new HashMap<>();

View File

@ -12,17 +12,18 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.hamcrest.number.IsCloseTo.closeTo; import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dmx.test.AbstractDmxThingTestParent; import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
@ -51,7 +52,7 @@ public class DimmerThingHandlerTest extends AbstractDmxThingTestParent {
private final ThingUID THING_UID_DIMMER = new ThingUID(THING_TYPE_DIMMER, "testdimmer"); private final ThingUID THING_UID_DIMMER = new ThingUID(THING_TYPE_DIMMER, "testdimmer");
private final ChannelUID CHANNEL_UID_BRIGHTNESS = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS); private final ChannelUID CHANNEL_UID_BRIGHTNESS = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS);
@Before @BeforeEach
public void setUp() { public void setUp() {
super.setup(); super.setup();

View File

@ -12,8 +12,9 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@ -21,10 +22,10 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.After; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Ignore; import org.junit.jupiter.api.Disabled;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.openhab.binding.dmx.internal.DmxBridgeHandler; import org.openhab.binding.dmx.internal.DmxBridgeHandler;
import org.openhab.binding.dmx.internal.multiverse.BaseDmxChannel; import org.openhab.binding.dmx.internal.multiverse.BaseDmxChannel;
@ -93,7 +94,7 @@ public class DmxBridgeHandlerTest extends JavaTest {
private Bridge bridge; private Bridge bridge;
private DmxBridgeHandlerImpl bridgeHandler; private DmxBridgeHandlerImpl bridgeHandler;
@Before @BeforeEach
public void setUp() { public void setUp() {
bridgeProperties = new HashMap<>(); bridgeProperties = new HashMap<>();
bridge = BridgeBuilder.create(THING_TYPE_TEST_BRIDGE, "testbridge").withLabel("Test Bridge") bridge = BridgeBuilder.create(THING_TYPE_TEST_BRIDGE, "testbridge").withLabel("Test Bridge")
@ -112,7 +113,7 @@ public class DmxBridgeHandlerTest extends JavaTest {
bridgeHandler.initialize(); bridgeHandler.initialize();
} }
@After @AfterEach
public void tearDown() { public void tearDown() {
bridgeHandler.dispose(); bridgeHandler.dispose();
} }
@ -122,13 +123,13 @@ public class DmxBridgeHandlerTest extends JavaTest {
waitForAssert(() -> assertEquals(ThingStatus.ONLINE, bridge.getStatusInfo().getStatus())); waitForAssert(() -> assertEquals(ThingStatus.ONLINE, bridge.getStatusInfo().getStatus()));
} }
@Ignore("https://github.com/eclipse/smarthome/issues/6015#issuecomment-411313627") @Disabled("https://github.com/eclipse/smarthome/issues/6015#issuecomment-411313627")
@Test @Test
public void assertSendDmxDataIsCalled() { public void assertSendDmxDataIsCalled() {
Mockito.verify(bridgeHandler, after(500).atLeast(9)).sendDmxData(); Mockito.verify(bridgeHandler, after(500).atLeast(9)).sendDmxData();
} }
@Ignore("https://github.com/eclipse/smarthome/issues/6015") @Disabled("https://github.com/eclipse/smarthome/issues/6015")
@Test @Test
public void assertMuteChannelMutesOutput() { public void assertMuteChannelMutesOutput() {
bridgeHandler.handleCommand(CHANNEL_UID_MUTE, OnOffType.ON); bridgeHandler.handleCommand(CHANNEL_UID_MUTE, OnOffType.ON);

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@ -20,9 +20,9 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.After; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.test.java.JavaTest; import org.openhab.core.test.java.JavaTest;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
@ -51,7 +51,7 @@ public class Lib485BridgeHandlerTest extends JavaTest {
private Bridge bridge; private Bridge bridge;
private Lib485BridgeHandler bridgeHandler; private Lib485BridgeHandler bridgeHandler;
@Before @BeforeEach
public void setUp() { public void setUp() {
bridgeProperties = new HashMap<>(); bridgeProperties = new HashMap<>();
bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS); bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
@ -76,7 +76,7 @@ public class Lib485BridgeHandlerTest extends JavaTest {
bridgeHandler.initialize(); bridgeHandler.initialize();
} }
@After @AfterEach
public void tearDown() { public void tearDown() {
bridgeHandler.dispose(); bridgeHandler.dispose();
} }

View File

@ -12,8 +12,9 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
@ -21,9 +22,9 @@ import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.After; import org.junit.jupiter.api.AfterEach;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.test.java.JavaTest; import org.openhab.core.test.java.JavaTest;
import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Bridge;
@ -52,7 +53,7 @@ public class SacnBridgeHandlerTest extends JavaTest {
private Bridge bridge; private Bridge bridge;
private SacnBridgeHandler bridgeHandler; private SacnBridgeHandler bridgeHandler;
@Before @BeforeEach
public void setUp() { public void setUp() {
bridgeProperties = new HashMap<>(); bridgeProperties = new HashMap<>();
bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS); bridgeProperties.put(CONFIG_ADDRESS, TEST_ADDRESS);
@ -79,7 +80,7 @@ public class SacnBridgeHandlerTest extends JavaTest {
bridgeHandler.initialize(); bridgeHandler.initialize();
} }
@After @AfterEach
public void tearDown() { public void tearDown() {
bridgeHandler.dispose(); bridgeHandler.dispose();
} }

View File

@ -12,17 +12,18 @@
*/ */
package org.openhab.binding.dmx.internal.handler; package org.openhab.binding.dmx.internal.handler;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.hamcrest.number.IsCloseTo.closeTo; import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openhab.binding.dmx.internal.DmxBindingConstants.*; import static org.openhab.binding.dmx.internal.DmxBindingConstants.*;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dmx.test.AbstractDmxThingTestParent; import org.openhab.binding.dmx.test.AbstractDmxThingTestParent;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
@ -54,7 +55,7 @@ public class TunableWhiteThingHandlerTest extends AbstractDmxThingTestParent {
private final ChannelUID CHANNEL_UID_BRIGHTNESS_WW = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_WW); private final ChannelUID CHANNEL_UID_BRIGHTNESS_WW = new ChannelUID(THING_UID_DIMMER, CHANNEL_BRIGHTNESS_WW);
private final ChannelUID CHANNEL_UID_COLOR_TEMP = new ChannelUID(THING_UID_DIMMER, CHANNEL_COLOR_TEMPERATURE); private final ChannelUID CHANNEL_UID_COLOR_TEMP = new ChannelUID(THING_UID_DIMMER, CHANNEL_COLOR_TEMPERATURE);
@Before @BeforeEach
public void setUp() { public void setUp() {
super.setup(); super.setup();

View File

@ -13,11 +13,11 @@
package org.openhab.binding.dmx.internal.multiverse; package org.openhab.binding.dmx.internal.multiverse;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests cases for BaseChannel * Tests cases for BaseChannel

View File

@ -13,10 +13,10 @@
package org.openhab.binding.dmx.internal.multiverse; package org.openhab.binding.dmx.internal.multiverse;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.openhab.binding.dmx.internal.DmxBindingConstants.ListenerType; import org.openhab.binding.dmx.internal.DmxBindingConstants.ListenerType;
import org.openhab.binding.dmx.internal.action.FadeAction; import org.openhab.binding.dmx.internal.action.FadeAction;
@ -37,7 +37,7 @@ public class DmxChannelTest {
DimmerThingHandler dimmerThingHandler; DimmerThingHandler dimmerThingHandler;
long currentTime; long currentTime;
@Before @BeforeEach
public void setup() { public void setup() {
dimmerThingHandler = Mockito.mock(DimmerThingHandler.class); dimmerThingHandler = Mockito.mock(DimmerThingHandler.class);
dmxChannel = new DmxChannel(0, 1, 0); dmxChannel = new DmxChannel(0, 1, 0);

View File

@ -12,9 +12,10 @@
*/ */
package org.openhab.binding.dmx.test; package org.openhab.binding.dmx.test;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is; import static org.hamcrest.core.Is.is;
import static org.hamcrest.number.IsCloseTo.closeTo; import static org.hamcrest.number.IsCloseTo.closeTo;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.dmx.test.TestBridgeHandler.THING_TYPE_TEST_BRIDGE; import static org.openhab.binding.dmx.test.TestBridgeHandler.THING_TYPE_TEST_BRIDGE;

View File

@ -12,10 +12,10 @@
*/ */
package org.openhab.binding.doorbird.internal; package org.openhab.binding.doorbird.internal;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.doorbird.internal.api.DoorbirdInfo; import org.openhab.binding.doorbird.internal.api.DoorbirdInfo;
/** /**

View File

@ -12,10 +12,10 @@
*/ */
package org.openhab.binding.doorbird.internal; package org.openhab.binding.doorbird.internal;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.doorbird.internal.api.SipStatus; import org.openhab.binding.doorbird.internal.api.SipStatus;
/** /**

View File

@ -13,10 +13,10 @@
package org.openhab.binding.draytonwiser.internal.discovery; package org.openhab.binding.draytonwiser.internal.discovery;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.*; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.doReturn;
import static org.mockito.MockitoAnnotations.initMocks;
import java.io.IOException; import java.io.IOException;
import java.net.URISyntaxException; import java.net.URISyntaxException;
@ -28,17 +28,18 @@ import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.client.HttpContentResponse; import org.eclipse.jetty.client.HttpContentResponse;
import org.eclipse.jetty.client.HttpResponse; import org.eclipse.jetty.client.HttpResponse;
import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.api.Request;
import org.eclipse.jetty.server.Response; import org.junit.jupiter.api.BeforeEach;
import org.junit.Before; import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.Test; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.runner.RunWith; import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.draytonwiser.internal.DraytonWiserBindingConstants; import org.openhab.binding.draytonwiser.internal.DraytonWiserBindingConstants;
import org.openhab.binding.draytonwiser.internal.api.DraytonWiserApi; import org.openhab.binding.draytonwiser.internal.api.DraytonWiserApi;
import org.openhab.binding.draytonwiser.internal.api.DraytonWiserApiException; import org.openhab.binding.draytonwiser.internal.api.DraytonWiserApiException;
@ -55,35 +56,22 @@ import org.openhab.core.thing.ThingUID;
* *
* @author Hilbrand Bouwkamp - Initial contribution * @author Hilbrand Bouwkamp - Initial contribution
*/ */
@RunWith(Parameterized.class) @ExtendWith(MockitoExtension.class)
public class DraytonWiserDiscoveryServiceTest { public class DraytonWiserDiscoveryServiceTest {
@Mock private @Mock HeatHubHandler bridgeHandler;
private HeatHubHandler bridgeHandler; private @Mock Bridge bridge;
@Mock private @Mock HttpClient httpClient;
private Bridge bridge; private @Mock Request request;
@Mock
private HttpClient httpClient;
@Mock
private Request request;
private DraytonWiserApi api; private DraytonWiserApi api;
private final String jsonFile;
private final int expectedResults;
public DraytonWiserDiscoveryServiceTest(final String jsonFile, final int expectedResults) {
this.jsonFile = jsonFile;
this.expectedResults = expectedResults;
}
@Parameters(name = "{0}")
public static List<Object[]> data() { public static List<Object[]> data() {
return Arrays.asList(new Object[] { "../test1.json", 11 }, new Object[] { "../test2.json", 22 }); return Arrays.asList(new Object[] { "../test1.json", 11 }, new Object[] { "../test2.json", 22 });
} }
@Before @BeforeEach
public void before() { public void before() {
initMocks(this);
api = new DraytonWiserApi(httpClient); api = new DraytonWiserApi(httpClient);
api.setConfiguration(new HeatHubConfiguration()); api.setConfiguration(new HeatHubConfiguration());
@ -96,12 +84,13 @@ public class DraytonWiserDiscoveryServiceTest {
doReturn(new ThingUID(DraytonWiserBindingConstants.THING_TYPE_BRIDGE, "1")).when(bridge).getUID(); doReturn(new ThingUID(DraytonWiserBindingConstants.THING_TYPE_BRIDGE, "1")).when(bridge).getUID();
} }
@Test @ParameterizedTest
public void testDiscovery() throws IOException, URISyntaxException, InterruptedException, TimeoutException, @MethodSource("data")
ExecutionException, DraytonWiserApiException { public void testDiscovery(final String jsonFile, final int expectedResults) throws IOException, URISyntaxException,
InterruptedException, TimeoutException, ExecutionException, DraytonWiserApiException {
final byte[] content = Files.readAllBytes(Paths.get(getClass().getResource(jsonFile).toURI())); final byte[] content = Files.readAllBytes(Paths.get(getClass().getResource(jsonFile).toURI()));
final HttpResponse response = new HttpResponse(null, null); final HttpResponse response = new HttpResponse(null, null);
response.status(Response.SC_OK); response.status(HttpServletResponse.SC_OK);
doReturn(new HttpContentResponse(response, content, null, null)).when(request).send(); doReturn(new HttpContentResponse(response, content, null, null)).when(request).send();
final List<DiscoveryResult> discoveryResults = new ArrayList<>(); final List<DiscoveryResult> discoveryResults = new ArrayList<>();
final DraytonWiserDiscoveryService service = new DraytonWiserDiscoveryService() { final DraytonWiserDiscoveryService service = new DraytonWiserDiscoveryService() {

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.dsmr.internal; package org.openhab.binding.dsmr.internal;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -63,9 +63,9 @@ public final class TelegramReaderUtil {
parser.setLenientMode(true); parser.setLenientMode(true);
parser.parse(telegram, telegram.length); parser.parse(telegram, telegram.length);
assertNotNull("Telegram state should have been set. (Missing newline at end of message?)", p1Telegram.get()); assertNotNull(p1Telegram.get(), "Telegram state should have been set. (Missing newline at end of message?)");
assertEquals("Expected TelegramState should be as expected", expectedTelegramState, assertEquals(expectedTelegramState, p1Telegram.get().getTelegramState(),
p1Telegram.get().getTelegramState()); "Expected TelegramState should be as expected");
return p1Telegram.get(); return p1Telegram.get();
} }
} }

View File

@ -12,10 +12,9 @@
*/ */
package org.openhab.binding.dsmr.internal.device; package org.openhab.binding.dsmr.internal.device;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
@ -25,9 +24,11 @@ import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.dsmr.internal.DSMRBindingConstants; import org.openhab.binding.dsmr.internal.DSMRBindingConstants;
import org.openhab.binding.dsmr.internal.TelegramReaderUtil; import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
import org.openhab.binding.dsmr.internal.device.DSMRSerialAutoDevice.DeviceState; import org.openhab.binding.dsmr.internal.device.DSMRSerialAutoDevice.DeviceState;
@ -45,22 +46,20 @@ import org.openhab.core.io.transport.serial.SerialPortManager;
* *
* @author Hilbrand Bouwkamp - Initial contribution * @author Hilbrand Bouwkamp - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
public class DSMRSerialAutoDeviceTest { public class DSMRSerialAutoDeviceTest {
private static final String DUMMY_PORTNAME = "/dev/dummy-serial"; private static final String DUMMY_PORTNAME = "/dev/dummy-serial";
private static final String TELEGRAM_NAME = "dsmr_50"; private static final String TELEGRAM_NAME = "dsmr_50";
@Mock private @Mock SerialPortIdentifier mockIdentifier;
private SerialPortIdentifier mockIdentifier; private @Mock ScheduledExecutorService scheduler;
@Mock private @Mock SerialPort mockSerialPort;
private ScheduledExecutorService scheduler;
@Mock
private SerialPort mockSerialPort;
private SerialPortManager serialPortManager = new SerialPortManager() { private SerialPortManager serialPortManager = new SerialPortManager() {
@Override @Override
public SerialPortIdentifier getIdentifier(String name) { public SerialPortIdentifier getIdentifier(String name) {
assertEquals("Expect the passed serial port name", DUMMY_PORTNAME, name); assertEquals(DUMMY_PORTNAME, name, "Expect the passed serial port name");
return mockIdentifier; return mockIdentifier;
} }
@ -71,9 +70,8 @@ public class DSMRSerialAutoDeviceTest {
}; };
private SerialPortEventListener serialPortEventListener; private SerialPortEventListener serialPortEventListener;
@Before @BeforeEach
public void setUp() throws PortInUseException, TooManyListenersException { public void setUp() throws PortInUseException, TooManyListenersException {
initMocks(this);
doAnswer(a -> { doAnswer(a -> {
serialPortEventListener = a.getArgument(0); serialPortEventListener = a.getArgument(0);
return null; return null;
@ -100,18 +98,18 @@ public class DSMRSerialAutoDeviceTest {
DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener, DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener,
new DSMRTelegramListener(), scheduler, 1); new DSMRTelegramListener(), scheduler, 1);
device.start(); device.start();
assertSame("Expect to be starting discovery state", DeviceState.DISCOVER_SETTINGS, device.getState()); assertSame(DeviceState.DISCOVER_SETTINGS, device.getState(), "Expect to be starting discovery state");
serialPortEventListener serialPortEventListener
.serialEvent(new MockSerialPortEvent(mockSerialPort, SerialPortEvent.BI, false, true)); .serialEvent(new MockSerialPortEvent(mockSerialPort, SerialPortEvent.BI, false, true));
assertSame("Expect to be still in discovery state", DeviceState.DISCOVER_SETTINGS, device.getState()); assertSame(DeviceState.DISCOVER_SETTINGS, device.getState(), "Expect to be still in discovery state");
serialPortEventListener serialPortEventListener
.serialEvent(new MockSerialPortEvent(mockSerialPort, SerialPortEvent.DATA_AVAILABLE, false, true)); .serialEvent(new MockSerialPortEvent(mockSerialPort, SerialPortEvent.DATA_AVAILABLE, false, true));
assertSame("Expect to be in normal state", DeviceState.NORMAL, device.getState()); assertSame(DeviceState.NORMAL, device.getState(), "Expect to be in normal state");
device.restart(); device.restart();
assertSame("Expect not to start rediscovery when in normal state", DeviceState.NORMAL, device.getState()); assertSame(DeviceState.NORMAL, device.getState(), "Expect not to start rediscovery when in normal state");
device.stop(); device.stop();
} }
assertNotNull("Expected to have read a telegram", telegramRef.get()); assertNotNull(telegramRef.get(), "Expected to have read a telegram");
} }
@Test @Test
@ -137,19 +135,19 @@ public class DSMRSerialAutoDeviceTest {
DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener, DSMRSerialAutoDevice device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener,
new DSMRTelegramListener(), scheduler, 1); new DSMRTelegramListener(), scheduler, 1);
device.start(); device.start();
assertSame("Expected an error", DSMRConnectorErrorEvent.IN_USE, eventRef.get()); assertSame(DSMRConnectorErrorEvent.IN_USE, eventRef.get(), "Expected an error");
assertSame("Expect to be in error state", DeviceState.ERROR, device.getState()); assertSame(DeviceState.ERROR, device.getState(), "Expect to be in error state");
// Trigger device to restart // Trigger device to restart
mockValidSerialPort(); mockValidSerialPort();
device.restart(); device.restart();
assertSame("Expect to be starting discovery state", DeviceState.DISCOVER_SETTINGS, device.getState()); assertSame(DeviceState.DISCOVER_SETTINGS, device.getState(), "Expect to be starting discovery state");
// Trigger device to go into error stage with port doesn't exist. // Trigger device to go into error stage with port doesn't exist.
mockIdentifier = null; mockIdentifier = null;
device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener, new DSMRTelegramListener(), device = new DSMRSerialAutoDevice(serialPortManager, DUMMY_PORTNAME, listener, new DSMRTelegramListener(),
scheduler, 1); scheduler, 1);
device.start(); device.start();
assertSame("Expected an error", DSMRConnectorErrorEvent.DONT_EXISTS, eventRef.get()); assertSame(DSMRConnectorErrorEvent.DONT_EXISTS, eventRef.get(), "Expected an error");
assertSame("Expect to be in error state", DeviceState.ERROR, device.getState()); assertSame(DeviceState.ERROR, device.getState(), "Expect to be in error state");
} }
} }

View File

@ -13,13 +13,13 @@
package org.openhab.binding.dsmr.internal.device; package org.openhab.binding.dsmr.internal.device;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dsmr.internal.TelegramReaderUtil; import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
import org.openhab.binding.dsmr.internal.device.p1telegram.P1TelegramListener; import org.openhab.binding.dsmr.internal.device.p1telegram.P1TelegramListener;
import org.openhab.binding.dsmr.internal.device.p1telegram.P1TelegramParser; import org.openhab.binding.dsmr.internal.device.p1telegram.P1TelegramParser;

View File

@ -12,16 +12,13 @@
*/ */
package org.openhab.binding.dsmr.internal.device.p1telegram; package org.openhab.binding.dsmr.internal.device.p1telegram;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.runner.RunWith; import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.openhab.binding.dsmr.internal.TelegramReaderUtil; import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState; import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
@ -30,11 +27,9 @@ import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramSt
* *
* @author Hilbrand Bouwkamp - Initial contribution * @author Hilbrand Bouwkamp - Initial contribution
*/ */
@RunWith(value = Parameterized.class)
public class P1TelegramParserTest { public class P1TelegramParserTest {
// @formatter:off // @formatter:off
@Parameters(name = "{0}")
public static final List<Object[]> data() { public static final List<Object[]> data() {
return Arrays.asList(new Object[][] { return Arrays.asList(new Object[][] {
{ "ace4000", 59, }, { "ace4000", 59, },
@ -52,17 +47,13 @@ public class P1TelegramParserTest {
} }
// @formatter:on // @formatter:on
@Parameter(0) @ParameterizedTest
public String telegramName; @MethodSource("data")
public void testParsing(final String telegramName, final int numberOfCosemObjects) {
@Parameter(1)
public int numberOfCosemObjects;
@Test
public void testParsing() {
P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK); P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK);
assertEquals("Should not have any unknown cosem objects", 0, telegram.getUnknownCosemObjects().size()); assertEquals(0, telegram.getUnknownCosemObjects().size(), "Should not have any unknown cosem objects");
assertEquals("Expected number of objects", numberOfCosemObjects, assertEquals(numberOfCosemObjects,
telegram.getCosemObjects().stream().mapToInt(co -> co.getCosemValues().size()).sum()); telegram.getCosemObjects().stream().mapToInt(co -> co.getCosemValues().size()).sum(),
"Expected number of objects");
} }
} }

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.dsmr.internal.discovery; package org.openhab.binding.dsmr.internal.discovery;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.openhab.binding.dsmr.internal.meter.DSMRMeterType.*; import static org.openhab.binding.dsmr.internal.meter.DSMRMeterType.*;
import java.util.Arrays; import java.util.Arrays;
@ -24,11 +24,8 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import org.junit.Test; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.runner.RunWith; import org.junit.jupiter.params.provider.MethodSource;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameter;
import org.junit.runners.Parameterized.Parameters;
import org.openhab.binding.dsmr.internal.TelegramReaderUtil; import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
import org.openhab.binding.dsmr.internal.device.cosem.CosemObject; import org.openhab.binding.dsmr.internal.device.cosem.CosemObject;
import org.openhab.binding.dsmr.internal.device.cosem.CosemObjectType; import org.openhab.binding.dsmr.internal.device.cosem.CosemObjectType;
@ -42,11 +39,9 @@ import org.openhab.binding.dsmr.internal.meter.DSMRMeterType;
* *
* @author Hilbrand Bouwkamp - Initial contribution * @author Hilbrand Bouwkamp - Initial contribution
*/ */
@RunWith(value = Parameterized.class)
public class DSMRMeterDetectorTest { public class DSMRMeterDetectorTest {
// @formatter:off // @formatter:off
@Parameters(name = "{0}")
public static final List<Object[]> data() { public static final List<Object[]> data() {
return Arrays.asList(new Object[][] { return Arrays.asList(new Object[][] {
{ "ace4000", EnumSet.of( ELECTRICITY_ACE4000, GAS_ACE4000)}, { "ace4000", EnumSet.of( ELECTRICITY_ACE4000, GAS_ACE4000)},
@ -64,30 +59,26 @@ public class DSMRMeterDetectorTest {
} }
// @formatter:on // @formatter:on
@Parameter(0) @ParameterizedTest
public String telegramName; @MethodSource("data")
public void testDetectMeters(final String telegramName, final Set<DSMRMeterType> expectedMeters) {
@Parameter(1)
public Set<DSMRMeterType> expectedMeters;
@Test
public void testDetectMeters() {
P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK); P1Telegram telegram = TelegramReaderUtil.readTelegram(telegramName, TelegramState.OK);
DSMRMeterDetector detector = new DSMRMeterDetector(); DSMRMeterDetector detector = new DSMRMeterDetector();
Entry<Collection<DSMRMeterDescriptor>, Map<CosemObjectType, CosemObject>> entry = detector Entry<Collection<DSMRMeterDescriptor>, Map<CosemObjectType, CosemObject>> entry = detector
.detectMeters(telegram); .detectMeters(telegram);
Collection<DSMRMeterDescriptor> detectMeters = entry.getKey(); Collection<DSMRMeterDescriptor> detectMeters = entry.getKey();
assertEquals("Should detect correct number of meters: " + Arrays.toString(detectMeters.toArray()), assertEquals(expectedMeters.size(), detectMeters.size(),
expectedMeters.size(), detectMeters.size()); "Should detect correct number of meters: " + Arrays.toString(detectMeters.toArray()));
assertEquals("Should not have any undetected cosem objects: ", Collections.emptyMap(), entry.getValue()); assertEquals(Collections.emptyMap(), entry.getValue(), "Should not have any undetected cosem objects: ");
assertEquals("Should not have any unknown cosem objects", Collections.emptyList(), assertEquals(Collections.emptyList(), telegram.getUnknownCosemObjects(),
telegram.getUnknownCosemObjects()); "Should not have any unknown cosem objects");
for (DSMRMeterType meter : expectedMeters) { for (DSMRMeterType meter : expectedMeters) {
assertEquals( assertEquals(
1, detectMeters.stream().filter(e -> e.getMeterType() == meter).count(),
String.format("Meter '%s' not found: %s", meter, String.format("Meter '%s' not found: %s", meter,
Arrays.toString(detectMeters.toArray(new DSMRMeterDescriptor[0]))), Arrays.toString(detectMeters.toArray(new DSMRMeterDescriptor[0]))));
1, detectMeters.stream().filter(e -> e.getMeterType() == meter).count());
} }
} }
} }

View File

@ -12,24 +12,23 @@
*/ */
package org.openhab.binding.dsmr.internal.discovery; package org.openhab.binding.dsmr.internal.discovery;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import static org.openhab.binding.dsmr.internal.meter.DSMRMeterType.*; import static org.openhab.binding.dsmr.internal.meter.DSMRMeterType.*;
import java.util.Collections; import java.util.Collections;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.TooManyListenersException;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference; import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.Before; import org.junit.jupiter.api.Test;
import org.junit.Test; import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Answers; import org.mockito.Answers;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.openhab.binding.dsmr.internal.TelegramReaderUtil; import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram; import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram;
import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState; import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
@ -37,7 +36,6 @@ import org.openhab.binding.dsmr.internal.handler.DSMRBridgeHandler;
import org.openhab.binding.dsmr.internal.handler.DSMRMeterHandler; import org.openhab.binding.dsmr.internal.handler.DSMRMeterHandler;
import org.openhab.binding.dsmr.internal.meter.DSMRMeterDescriptor; import org.openhab.binding.dsmr.internal.meter.DSMRMeterDescriptor;
import org.openhab.binding.dsmr.internal.meter.DSMRMeterType; import org.openhab.binding.dsmr.internal.meter.DSMRMeterType;
import org.openhab.core.io.transport.serial.PortInUseException;
import org.openhab.core.thing.Thing; import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.ThingUID;
@ -46,22 +44,15 @@ import org.openhab.core.thing.ThingUID;
* *
* @author Hilbrand Bouwkamp - Initial contribution * @author Hilbrand Bouwkamp - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
public class DSMRMeterDiscoveryServiceTest { public class DSMRMeterDiscoveryServiceTest {
private static final String EXPECTED_CONFIGURED_TELEGRAM = "dsmr_50"; private static final String EXPECTED_CONFIGURED_TELEGRAM = "dsmr_50";
private static final String UNREGISTERED_METER_TELEGRAM = "unregistered_meter"; private static final String UNREGISTERED_METER_TELEGRAM = "unregistered_meter";
@Mock(answer = Answers.RETURNS_DEEP_STUBS) private @Mock(answer = Answers.RETURNS_DEEP_STUBS) DSMRBridgeHandler bridge;
private DSMRBridgeHandler bridge; private @Mock Thing thing;
@Mock private @Mock DSMRMeterHandler meterHandler;
private Thing thing;
@Mock
private DSMRMeterHandler meterHandler;
@Before
public void setUp() throws PortInUseException, TooManyListenersException {
initMocks(this);
}
/** /**
* Test if discovery reports when the user has incorrectly configured the binding with the wrong meter types. * Test if discovery reports when the user has incorrectly configured the binding with the wrong meter types.
@ -100,12 +91,12 @@ public class DSMRMeterDiscoveryServiceTest {
when(bridge.getThing().getThings()).thenReturn(things); when(bridge.getThing().getThings()).thenReturn(things);
service.telegramReceived(expected); service.telegramReceived(expected);
assertNotNull("Should have invalid configured meters", invalidConfiguredRef.get()); assertNotNull(invalidConfiguredRef.get(), "Should have invalid configured meters");
assertTrue("Should have found specific invalid meter", assertTrue(invalidConfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V4_2),
invalidConfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V4_2)); "Should have found specific invalid meter");
assertNotNull("Should have undetected meters", unconfiguredRef.get()); assertNotNull(unconfiguredRef.get(), "Should have undetected meters");
assertTrue("Should have found specific undetected meter", assertTrue(unconfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V5_0),
unconfiguredRef.get().contains(DSMRMeterType.ELECTRICITY_V5_0)); "Should have found specific undetected meter");
} }
/** /**
@ -128,6 +119,6 @@ public class DSMRMeterDiscoveryServiceTest {
when(bridge.getThing().getThings()).thenReturn(Collections.emptyList()); when(bridge.getThing().getThings()).thenReturn(Collections.emptyList());
service.telegramReceived(telegram); service.telegramReceived(telegram);
assertTrue("Should have found an unregistered meter", unregisteredMeter.get()); assertTrue(unregisteredMeter.get(), "Should have found an unregistered meter");
} }
} }

View File

@ -12,12 +12,12 @@
*/ */
package org.openhab.binding.dsmr.internal.meter; package org.openhab.binding.dsmr.internal.meter;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.List; import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.dsmr.internal.TelegramReaderUtil; import org.openhab.binding.dsmr.internal.TelegramReaderUtil;
import org.openhab.binding.dsmr.internal.device.cosem.CosemObject; import org.openhab.binding.dsmr.internal.device.cosem.CosemObject;
import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState; import org.openhab.binding.dsmr.internal.device.p1telegram.P1Telegram.TelegramState;
@ -40,7 +40,7 @@ public class DSMRMeterTest {
List<CosemObject> filterMeterValues = meter List<CosemObject> filterMeterValues = meter
.filterMeterValues(TelegramReaderUtil.readTelegram("dsmr_50", TelegramState.OK).getCosemObjects()); .filterMeterValues(TelegramReaderUtil.readTelegram("dsmr_50", TelegramState.OK).getCosemObjects());
assertEquals("Filter should return all required objects", DSMRMeterType.DEVICE_V5.requiredCosemObjects.length, assertEquals(DSMRMeterType.DEVICE_V5.requiredCosemObjects.length, filterMeterValues.size(),
filterMeterValues.size()); "Filter should return all required objects");
} }
} }

View File

@ -13,10 +13,9 @@
package org.openhab.binding.dwdunwetter; package org.openhab.binding.dwdunwetter;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.mockito.MockitoAnnotations.initMocks;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
@ -26,10 +25,14 @@ import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.hamcrest.CoreMatchers; import org.hamcrest.CoreMatchers;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.Mock; import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;
import org.openhab.binding.dwdunwetter.internal.DwdUnwetterBindingConstants; import org.openhab.binding.dwdunwetter.internal.DwdUnwetterBindingConstants;
import org.openhab.binding.dwdunwetter.internal.handler.DwdUnwetterHandler; import org.openhab.binding.dwdunwetter.internal.handler.DwdUnwetterHandler;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
@ -51,19 +54,17 @@ import org.w3c.dom.NodeList;
* *
* @author Martin Koehler - Initial contribution * @author Martin Koehler - Initial contribution
*/ */
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.WARN)
public class DwdUnwetterHandlerTest extends JavaTest { public class DwdUnwetterHandlerTest extends JavaTest {
private ThingHandler handler; private ThingHandler handler;
@Mock private @Mock ThingHandlerCallback callback;
private ThingHandlerCallback callback; private @Mock Thing thing;
@Mock @BeforeEach
private Thing thing;
@Before
public void setUp() { public void setUp() {
initMocks(this);
handler = new DwdUnwetterHandler(thing); handler = new DwdUnwetterHandler(thing);
handler.setCallback(callback); handler.setCallback(callback);
// mock getConfiguration to prevent NPEs // mock getConfiguration to prevent NPEs

View File

@ -13,12 +13,12 @@
package org.openhab.binding.dwdunwetter.internal.data; package org.openhab.binding.dwdunwetter.internal.data;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.time.Instant; import java.time.Instant;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests for {@link DwdWarningCache} * Tests for {@link DwdWarningCache}
@ -29,7 +29,7 @@ public class DwdWarningCacheTest {
private DwdWarningCache cache; private DwdWarningCache cache;
@Before @BeforeEach
public void setUp() { public void setUp() {
cache = new DwdWarningCache(); cache = new DwdWarningCache();
} }

View File

@ -13,7 +13,7 @@
package org.openhab.binding.dwdunwetter.internal.data; package org.openhab.binding.dwdunwetter.internal.data;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -23,8 +23,8 @@ import java.io.StringWriter;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.ZoneId; import java.time.ZoneId;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.library.types.DateTimeType; import org.openhab.core.library.types.DateTimeType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
import org.openhab.core.types.UnDefType; import org.openhab.core.types.UnDefType;
@ -47,7 +47,7 @@ public class DwdWarningsDataTest {
private TestDataProvider testDataProvider; private TestDataProvider testDataProvider;
private DwdWarningsData warningsData; private DwdWarningsData warningsData;
@Before @BeforeEach
public void setUp() throws IOException { public void setUp() throws IOException {
this.testDataProvider = new TestDataProvider(); this.testDataProvider = new TestDataProvider();
loadXmlFromFile(); loadXmlFromFile();

View File

@ -12,14 +12,15 @@
*/ */
package org.openhab.binding.enigma2.actions; package org.openhab.binding.enigma2.actions;
import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.enigma2.handler.Enigma2Handler; import org.openhab.binding.enigma2.handler.Enigma2Handler;
import org.openhab.binding.enigma2.internal.Enigma2BindingConstants; import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
@ -37,7 +38,7 @@ public class Enigma2ActionsTest {
private Enigma2Handler enigma2Handler; private Enigma2Handler enigma2Handler;
public static final String SOME_TEXT = "some Text"; public static final String SOME_TEXT = "some Text";
@Before @BeforeEach
public void setUp() { public void setUp() {
enigma2Handler = mock(Enigma2Handler.class); enigma2Handler = mock(Enigma2Handler.class);
enigma2Actions = new Enigma2Actions(); enigma2Actions = new Enigma2Actions();
@ -109,9 +110,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendRcCommand("KEY_1"); verify(enigma2Handler).sendRcCommand("KEY_1");
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSendRcCommandStaticWithException() { public void testSendRcCommandStaticWithException() {
Enigma2Actions.sendRcCommand(null, "KEY_1"); assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendRcCommand(null, "KEY_1"));
} }
@Test @Test
@ -126,9 +127,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendInfo(10, SOME_TEXT); verify(enigma2Handler).sendInfo(10, SOME_TEXT);
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSendInfoStaticWithException() { public void testSendInfoStaticWithException() {
Enigma2Actions.sendInfo(null, SOME_TEXT); assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendInfo(null, SOME_TEXT));
} }
@Test @Test
@ -143,9 +144,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendError(10, SOME_TEXT); verify(enigma2Handler).sendError(10, SOME_TEXT);
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSendErrorStaticWithException() { public void testSendErrorStaticWithException() {
Enigma2Actions.sendError(null, SOME_TEXT); assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendError(null, SOME_TEXT));
} }
@Test @Test
@ -160,9 +161,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendWarning(10, SOME_TEXT); verify(enigma2Handler).sendWarning(10, SOME_TEXT);
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSendWarningStaticWithException() { public void testSendWarningStaticWithException() {
Enigma2Actions.sendWarning(null, SOME_TEXT); assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendWarning(null, SOME_TEXT));
} }
@Test @Test
@ -177,8 +178,8 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendQuestion(10, SOME_TEXT); verify(enigma2Handler).sendQuestion(10, SOME_TEXT);
} }
@Test(expected = IllegalArgumentException.class) @Test
public void testSendQuestionStaticWithException() { public void testSendQuestionStaticWithException() {
Enigma2Actions.sendQuestion(null, SOME_TEXT); assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendQuestion(null, SOME_TEXT));
} }
} }

View File

@ -13,8 +13,8 @@
package org.openhab.binding.enigma2.handler; package org.openhab.binding.enigma2.handler;
import static org.eclipse.jdt.annotation.Checks.requireNonNull; import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -23,15 +23,20 @@ import java.util.Optional;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.enigma2.actions.Enigma2Actions; import org.openhab.binding.enigma2.actions.Enigma2Actions;
import org.openhab.binding.enigma2.internal.Enigma2BindingConstants; import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
import org.openhab.binding.enigma2.internal.Enigma2Client; import org.openhab.binding.enigma2.internal.Enigma2Client;
import org.openhab.binding.enigma2.internal.Enigma2Configuration; import org.openhab.binding.enigma2.internal.Enigma2Configuration;
import org.openhab.binding.enigma2.internal.Enigma2RemoteKey; import org.openhab.binding.enigma2.internal.Enigma2RemoteKey;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.library.types.*; import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.NextPreviousType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.PlayPauseType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.ChannelUID;
import org.openhab.core.thing.Thing; import org.openhab.core.thing.Thing;
import org.openhab.core.thing.binding.ThingHandlerCallback; import org.openhab.core.thing.binding.ThingHandlerCallback;
@ -58,7 +63,7 @@ public class Enigma2HandlerTest {
@Nullable @Nullable
private ThingHandlerCallback callback; private ThingHandlerCallback callback;
@Before @BeforeEach
public void setUp() { public void setUp() {
enigma2Client = mock(Enigma2Client.class); enigma2Client = mock(Enigma2Client.class);
thing = mock(Thing.class); thing = mock(Thing.class);

View File

@ -13,8 +13,9 @@
package org.openhab.binding.enigma2.internal; package org.openhab.binding.enigma2.internal;
import static org.eclipse.jdt.annotation.Checks.requireNonNull; import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import java.io.IOException; import java.io.IOException;
@ -22,8 +23,8 @@ import java.time.LocalDateTime;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* The {@link Enigma2ClientTest} class is responsible for testing {@link Enigma2Client}. * The {@link Enigma2ClientTest} class is responsible for testing {@link Enigma2Client}.
@ -41,7 +42,7 @@ public class Enigma2ClientTest {
@Nullable @Nullable
private Enigma2HttpClient enigma2HttpClient; private Enigma2HttpClient enigma2HttpClient;
@Before @BeforeEach
public void setUp() throws IOException { public void setUp() throws IOException {
enigma2HttpClient = mock(Enigma2HttpClient.class); enigma2HttpClient = mock(Enigma2HttpClient.class);
enigma2Client = spy(new Enigma2Client("localhost:8080", "user", "password", 5)); enigma2Client = spy(new Enigma2Client("localhost:8080", "user", "password", 5));

View File

@ -13,15 +13,14 @@
package org.openhab.binding.enigma2.internal; package org.openhab.binding.enigma2.internal;
import static org.eclipse.jdt.annotation.Checks.requireNonNull; import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*; import static org.mockito.Mockito.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.openhab.binding.enigma2.internal.Enigma2BindingConstants.THING_TYPE_DEVICE; import static org.openhab.binding.enigma2.internal.Enigma2BindingConstants.THING_TYPE_DEVICE;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.config.core.Configuration; import org.openhab.core.config.core.Configuration;
import org.openhab.core.thing.Thing; import org.openhab.core.thing.Thing;
import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingTypeUID;

View File

@ -12,11 +12,11 @@
*/ */
package org.openhab.binding.enigma2.internal; package org.openhab.binding.enigma2.internal;
import static org.hamcrest.Matchers.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.*; import static org.hamcrest.Matchers.is;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* The {@link Enigma2RemoteKeyTest} class is responsible for testing {@link Enigma2RemoteKey}. * The {@link Enigma2RemoteKeyTest} class is responsible for testing {@link Enigma2RemoteKey}.

View File

@ -13,10 +13,9 @@
package org.openhab.binding.enigma2.internal.discovery; package org.openhab.binding.enigma2.internal.discovery;
import static org.eclipse.jdt.annotation.Checks.requireNonNull; import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*; import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.mockito.Mockito.when;
import java.net.Inet4Address; import java.net.Inet4Address;
import java.net.InetAddress; import java.net.InetAddress;
@ -25,8 +24,8 @@ import javax.jmdns.ServiceInfo;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.enigma2.internal.Enigma2BindingConstants; import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
import org.openhab.binding.enigma2.internal.Enigma2HttpClient; import org.openhab.binding.enigma2.internal.Enigma2HttpClient;
import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResult;
@ -47,7 +46,7 @@ public class Enigma2DiscoveryParticipantTest {
@Nullable @Nullable
private Enigma2DiscoveryParticipant enigma2DiscoveryParticipant; private Enigma2DiscoveryParticipant enigma2DiscoveryParticipant;
@Before @BeforeEach
public void setUp() { public void setUp() {
enigma2HttpClient = mock(Enigma2HttpClient.class); enigma2HttpClient = mock(Enigma2HttpClient.class);
serviceInfo = mock(ServiceInfo.class); serviceInfo = mock(ServiceInfo.class);

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.junit.Assert.fail; import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
@ -30,7 +30,7 @@ import org.eclipse.jdt.annotation.Nullable;
import org.hamcrest.Description; import org.hamcrest.Description;
import org.hamcrest.Matcher; import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher; import org.hamcrest.TypeSafeMatcher;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.openhab.binding.fmiweather.internal.client.Client; import org.openhab.binding.fmiweather.internal.client.Client;
import org.openhab.binding.fmiweather.internal.client.Data; import org.openhab.binding.fmiweather.internal.client.Data;
import org.openhab.binding.fmiweather.internal.client.FMIResponse; import org.openhab.binding.fmiweather.internal.client.FMIResponse;
@ -47,7 +47,7 @@ public class AbstractFMIResponseParsingTest {
@NonNullByDefault({}) @NonNullByDefault({})
protected Client client; protected Client client;
@Before @BeforeEach
public void setUpClient() { public void setUpClient() {
client = new Client(); client = new Client();
} }

View File

@ -13,7 +13,7 @@
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.AbstractMap; import java.util.AbstractMap;
@ -22,7 +22,7 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.FMISID; import org.openhab.binding.fmiweather.internal.client.FMISID;
import org.openhab.binding.fmiweather.internal.client.ForecastRequest; import org.openhab.binding.fmiweather.internal.client.ForecastRequest;
import org.openhab.binding.fmiweather.internal.client.LatLon; import org.openhab.binding.fmiweather.internal.client.LatLon;

View File

@ -13,12 +13,13 @@
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.nio.file.Path; import java.nio.file.Path;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Client; import org.openhab.binding.fmiweather.internal.client.Client;
import org.openhab.binding.fmiweather.internal.client.FMIResponse; import org.openhab.binding.fmiweather.internal.client.FMIResponse;
@ -33,7 +34,7 @@ public class FMIResponseParsingEmptyTest extends AbstractFMIResponseParsingTest
private FMIResponse observationsResponse; private FMIResponse observationsResponse;
@Before @BeforeEach
public void setUp() { public void setUp() {
client = new Client(); client = new Client();
try { try {

View File

@ -13,12 +13,13 @@
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.fail;
import java.nio.file.Path; import java.nio.file.Path;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException; import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
/** /**

View File

@ -12,11 +12,12 @@
*/ */
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import java.io.IOException; import static org.junit.jupiter.api.Assertions.assertThrows;
import java.nio.file.Path; import java.nio.file.Path;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException; import org.openhab.binding.fmiweather.internal.client.exception.FMIResponseException;
import org.xml.sax.SAXParseException; import org.xml.sax.SAXParseException;
@ -30,13 +31,15 @@ public class FMIResponseParsingInvalidOrUnexpectedXmlTest extends AbstractFMIRes
private Path observations1 = getTestResource("observations_single_place.xml"); private Path observations1 = getTestResource("observations_single_place.xml");
@Test(expected = SAXParseException.class) @Test
public void testInvalidXml() throws IOException, Throwable { public void testInvalidXml() {
parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<")); assertThrows(SAXParseException.class,
() -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<<")));
} }
@Test(expected = FMIResponseException.class) @Test
public void testUnexpectedXml() throws IOException, Throwable { public void testUnexpectedXml() {
parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>")); assertThrows(FMIResponseException.class,
() -> parseMultiPointCoverageXml(readTestResourceUtf8(observations1).replace("276.0", "<foo>4</foo>")));
} }
} }

View File

@ -13,7 +13,7 @@
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Path; import java.nio.file.Path;
@ -21,8 +21,8 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Data; import org.openhab.binding.fmiweather.internal.client.Data;
import org.openhab.binding.fmiweather.internal.client.FMIResponse; import org.openhab.binding.fmiweather.internal.client.FMIResponse;
import org.openhab.binding.fmiweather.internal.client.Location; import org.openhab.binding.fmiweather.internal.client.Location;
@ -60,7 +60,7 @@ public class FMIResponseParsingMultiplePlacesTest extends AbstractFMIResponsePar
private Location pointWithNoName = new Location("19.9,61.0973", "61.09726,19.90000", new BigDecimal("61.09726"), private Location pointWithNoName = new Location("19.9,61.0973", "61.09726,19.90000", new BigDecimal("61.09726"),
new BigDecimal("19.90000")); new BigDecimal("19.90000"));
@Before @BeforeEach
public void setUp() { public void setUp() {
try { try {
observationsMultiplePlacesResponse = parseMultiPointCoverageXml( observationsMultiplePlacesResponse = parseMultiPointCoverageXml(

View File

@ -13,7 +13,8 @@
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Path; import java.nio.file.Path;
@ -21,8 +22,8 @@ import java.util.Optional;
import java.util.Set; import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Data; import org.openhab.binding.fmiweather.internal.client.Data;
import org.openhab.binding.fmiweather.internal.client.FMIResponse; import org.openhab.binding.fmiweather.internal.client.FMIResponse;
import org.openhab.binding.fmiweather.internal.client.Location; import org.openhab.binding.fmiweather.internal.client.Location;
@ -46,7 +47,7 @@ public class FMIResponseParsingSinglePlaceTest extends AbstractFMIResponseParsin
private Location emasalo = new Location("Porvoo Emäsalo", "101023", new BigDecimal("60.20382"), private Location emasalo = new Location("Porvoo Emäsalo", "101023", new BigDecimal("60.20382"),
new BigDecimal("25.62546")); new BigDecimal("25.62546"));
@Before @BeforeEach
public void setUp() { public void setUp() {
try { try {
observationsResponse1 = parseMultiPointCoverageXml(readTestResourceUtf8(observations1)); observationsResponse1 = parseMultiPointCoverageXml(readTestResourceUtf8(observations1));

View File

@ -13,14 +13,15 @@
package org.openhab.binding.fmiweather; package org.openhab.binding.fmiweather;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Set; import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.fmiweather.internal.client.Location; import org.openhab.binding.fmiweather.internal.client.Location;
/** /**

View File

@ -12,14 +12,14 @@
*/ */
package org.openhab.binding.foobot.internal.handler; package org.openhab.binding.foobot.internal.handler;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.List; import java.util.List;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mock; import org.mockito.Mock;
import org.openhab.binding.foobot.internal.FoobotApiConnector; import org.openhab.binding.foobot.internal.FoobotApiConnector;
import org.openhab.binding.foobot.internal.FoobotApiException; import org.openhab.binding.foobot.internal.FoobotApiException;
@ -50,7 +50,7 @@ public class FoobotAccountHandlerTest {
public void testSensorDataToState() throws IOException, FoobotApiException { public void testSensorDataToState() throws IOException, FoobotApiException {
final List<FoobotDevice> deviceList = handler.getDeviceList(); final List<FoobotDevice> deviceList = handler.getDeviceList();
assertFalse("Device list should not return empty", deviceList.isEmpty()); assertFalse(deviceList.isEmpty(), "Device list should not return empty");
assertEquals("1234567890ABCDEF", deviceList.get(0).getUuid()); assertEquals(deviceList.get(0).getUuid(), "1234567890ABCDEF");
} }
} }

View File

@ -12,13 +12,13 @@
*/ */
package org.openhab.binding.foobot.internal.handler; package org.openhab.binding.foobot.internal.handler;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mock; import org.mockito.Mock;
import org.openhab.binding.foobot.internal.FoobotApiConnector; import org.openhab.binding.foobot.internal.FoobotApiConnector;
import org.openhab.binding.foobot.internal.FoobotApiException; import org.openhab.binding.foobot.internal.FoobotApiException;
@ -52,7 +52,7 @@ public class FoobotDeviceHandlerTest {
public void testSensorDataToState() throws IOException, FoobotApiException { public void testSensorDataToState() throws IOException, FoobotApiException {
final FoobotJsonData sensorData = connector.getSensorData("1234"); final FoobotJsonData sensorData = connector.getSensorData("1234");
assertNotNull("No sensor data read", sensorData); assertNotNull(sensorData, "No sensor data read");
assertEquals(handler.sensorDataToState("temperature", sensorData), new QuantityType(12.345, SIUnits.CELSIUS)); assertEquals(handler.sensorDataToState("temperature", sensorData), new QuantityType(12.345, SIUnits.CELSIUS));
assertEquals(handler.sensorDataToState("gpi", sensorData), new DecimalType(5.6789012)); assertEquals(handler.sensorDataToState("gpi", sensorData), new DecimalType(5.6789012));
} }

View File

@ -12,9 +12,10 @@
*/ */
package org.openhab.binding.freebox.internal.api; package org.openhab.binding.freebox.internal.api;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Assert; import org.junit.jupiter.api.Test;
import org.junit.Test;
/** /**
* *
@ -27,6 +28,6 @@ public class FreeboxApiManagerTest {
public void hmacSha1Test() throws Exception { public void hmacSha1Test() throws Exception {
String expected = "25dad1bb5604321f12b755cc9d755d1480cf7989"; String expected = "25dad1bb5604321f12b755cc9d755d1480cf7989";
String actual = FreeboxApiManager.hmacSha1("Token1234", "Challenge"); String actual = FreeboxApiManager.hmacSha1("Token1234", "Challenge");
Assert.assertEquals(expected, actual); assertEquals(expected, actual);
} }
} }

View File

@ -12,14 +12,14 @@
*/ */
package org.openhab.binding.fsinternetradio.test; package org.openhab.binding.fsinternetradio.test;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URI; import java.net.URI;
import java.net.URL; import java.net.URL;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.jupnp.model.ValidationException; import org.jupnp.model.ValidationException;
import org.jupnp.model.meta.DeviceDetails; import org.jupnp.model.meta.DeviceDetails;
import org.jupnp.model.meta.ManufacturerDetails; import org.jupnp.model.meta.ManufacturerDetails;
@ -80,7 +80,7 @@ public class FSInternetRadioDiscoveryParticipantJavaTest {
String DEFAULT_RADIO_THING_UID = String.format("%s:%s:%s", RADIO_BINDING_ID, RADIO_THING_TYPE_ID, String DEFAULT_RADIO_THING_UID = String.format("%s:%s:%s", RADIO_BINDING_ID, RADIO_THING_TYPE_ID,
DEFAULT_RADIO_SERIAL_NUMBER); DEFAULT_RADIO_SERIAL_NUMBER);
@Before @BeforeEach
public void setUp() { public void setUp() {
discoveryParticipant = new FSInternetRadioDiscoveryParticipant(); discoveryParticipant = new FSInternetRadioDiscoveryParticipant();
} }

View File

@ -13,7 +13,8 @@
package org.openhab.binding.fsinternetradio.test; package org.openhab.binding.fsinternetradio.test;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.isA; import static org.mockito.ArgumentMatchers.isA;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants.*; import static org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants.*;
@ -29,11 +30,10 @@ import org.apache.commons.lang.StringUtils;
import org.eclipse.jdt.annotation.NonNull; import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.HttpClient;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.AfterClass; import org.junit.jupiter.api.AfterAll;
import org.junit.Assert; import org.junit.jupiter.api.BeforeAll;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.BeforeClass; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants; import org.openhab.binding.fsinternetradio.internal.FSInternetRadioBindingConstants;
import org.openhab.binding.fsinternetradio.internal.handler.FSInternetRadioHandler; import org.openhab.binding.fsinternetradio.internal.handler.FSInternetRadioHandler;
@ -124,7 +124,7 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
private static final String DEFAULT_CONFIG_PROPERTY_REFRESH = "1"; private static final String DEFAULT_CONFIG_PROPERTY_REFRESH = "1";
private static final Configuration DEFAULT_COMPLETE_CONFIGURATION = createDefaultConfiguration(); private static final Configuration DEFAULT_COMPLETE_CONFIGURATION = createDefaultConfiguration();
@BeforeClass @BeforeAll
public static void setUpClass() throws Exception { public static void setUpClass() throws Exception {
ServletHolder holder = new ServletHolder(radioServiceDummy); ServletHolder holder = new ServletHolder(radioServiceDummy);
server = new TestServer(DEFAULT_CONFIG_PROPERTY_IP, DEFAULT_CONFIG_PROPERTY_PORT, TIMEOUT, holder); server = new TestServer(DEFAULT_CONFIG_PROPERTY_IP, DEFAULT_CONFIG_PROPERTY_PORT, TIMEOUT, holder);
@ -134,12 +134,12 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
httpClient.start(); httpClient.start();
} }
@Before @BeforeEach
public void setUp() { public void setUp() {
createThePowerChannel(); createThePowerChannel();
} }
@AfterClass @AfterAll
public static void tearDownClass() throws Exception { public static void tearDownClass() throws Exception {
server.stopServer(); server.stopServer();
httpClient.stop(); httpClient.stop();
@ -147,13 +147,13 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
private static @NonNull Channel getChannel(final @NonNull Thing thing, final @NonNull String channelId) { private static @NonNull Channel getChannel(final @NonNull Thing thing, final @NonNull String channelId) {
final Channel channel = thing.getChannel(channelId); final Channel channel = thing.getChannel(channelId);
Assert.assertNotNull(channel); assertNotNull(channel);
return channel; return channel;
} }
private static @NonNull ChannelUID getChannelUID(final @NonNull Thing thing, final @NonNull String channelId) { private static @NonNull ChannelUID getChannelUID(final @NonNull Thing thing, final @NonNull String channelId) {
final ChannelUID channelUID = getChannel(thing, channelId).getUID(); final ChannelUID channelUID = getChannel(thing, channelId).getUID();
Assert.assertNotNull(channelUID); assertNotNull(channelUID);
return channelUID; return channelUID;
} }
@ -290,15 +290,15 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(powerChannelUID, OnOffType.ON); radioHandler.handleCommand(powerChannelUID, OnOffType.ON);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to turn on the radio", assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER)); "We should be able to turn on the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(powerChannelUID, OnOffType.OFF); radioHandler.handleCommand(powerChannelUID, OnOffType.OFF);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to turn off the radio", assertTrue(radioServiceDummy.containsRequestParameter(0, CHANNEL_POWER),
radioServiceDummy.containsRequestParameter(0, CHANNEL_POWER)); "We should be able to turn off the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
@ -308,8 +308,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
*/ */
radioHandler.handleCommand(powerChannelUID, OnOffType.ON); radioHandler.handleCommand(powerChannelUID, OnOffType.ON);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to turn on the radio", assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER)); "We should be able to turn on the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }
@ -333,15 +333,15 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(muteChannelUID, OnOffType.ON); radioHandler.handleCommand(muteChannelUID, OnOffType.ON);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to mute the radio", assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_MUTE),
radioServiceDummy.containsRequestParameter(1, CHANNEL_MUTE)); "We should be able to mute the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(muteChannelUID, OnOffType.OFF); radioHandler.handleCommand(muteChannelUID, OnOffType.OFF);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to unmute the radio", assertTrue(radioServiceDummy.containsRequestParameter(0, CHANNEL_MUTE),
radioServiceDummy.containsRequestParameter(0, CHANNEL_MUTE)); "We should be able to unmute the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
@ -370,8 +370,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("1")); radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("1"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to update the mode channel correctly", assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_MODE),
radioServiceDummy.containsRequestParameter(1, CHANNEL_MODE)); "We should be able to update the mode channel correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
@ -381,8 +381,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
*/ */
radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("3")); radioHandler.handleCommand(modeChannelUID, DecimalType.valueOf("3"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to update the mode channel correctly", assertTrue(radioServiceDummy.containsRequestParameter(3, CHANNEL_MODE),
radioServiceDummy.containsRequestParameter(3, CHANNEL_MODE)); "We should be able to update the mode channel correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }
@ -450,8 +450,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("36")); radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("36"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("The volume should not exceed the maximum value", assertTrue(radioServiceDummy.containsRequestParameter(32, VOLUME),
radioServiceDummy.containsRequestParameter(32, VOLUME)); "The volume should not exceed the maximum value");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
@ -459,8 +459,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(absoluteVolumeChannelUID, IncreaseDecreaseType.INCREASE); radioHandler.handleCommand(absoluteVolumeChannelUID, IncreaseDecreaseType.INCREASE);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("The volume should not be increased above the maximum value", assertTrue(radioServiceDummy.areRequestParametersEmpty(),
radioServiceDummy.areRequestParametersEmpty()); "The volume should not be increased above the maximum value");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
@ -468,16 +468,16 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(absoluteVolumeChannelUID, UpDownType.UP); radioHandler.handleCommand(absoluteVolumeChannelUID, UpDownType.UP);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("The volume should not be increased above the maximum value", assertTrue(radioServiceDummy.areRequestParametersEmpty(),
radioServiceDummy.areRequestParametersEmpty()); "The volume should not be increased above the maximum value");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
// Trying to set a value that is lower than the minimum volume value // Trying to set a value that is lower than the minimum volume value
radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("-10")); radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("-10"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("The volume should not be decreased below 0", assertTrue(radioServiceDummy.containsRequestParameter(0, VOLUME),
radioServiceDummy.containsRequestParameter(0, VOLUME)); "The volume should not be decreased below 0");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
@ -489,8 +489,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
// trying to set the volume // trying to set the volume
radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("15")); radioHandler.handleCommand(absoluteVolumeChannelUID, DecimalType.valueOf("15"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to set the volume correctly", assertTrue(radioServiceDummy.containsRequestParameter(15, VOLUME),
radioServiceDummy.containsRequestParameter(15, VOLUME)); "We should be able to set the volume correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }
@ -586,16 +586,16 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
*/ */
radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("50")); radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("50"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to set the volume correctly using percentages.", assertTrue(radioServiceDummy.containsRequestParameter(16, VOLUME),
radioServiceDummy.containsRequestParameter(16, VOLUME)); "We should be able to set the volume correctly using percentages.");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("15")); radioHandler.handleCommand(percentVolumeChannelUID, PercentType.valueOf("15"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to set the volume correctly using percentages.", assertTrue(radioServiceDummy.containsRequestParameter(4, VOLUME),
radioServiceDummy.containsRequestParameter(4, VOLUME)); "We should be able to set the volume correctly using percentages.");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }
@ -605,31 +605,31 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
// First we have to make sure that the item state is 0 // First we have to make sure that the item state is 0
radioHandler.handleCommand(channelUID, DecimalType.valueOf("0")); radioHandler.handleCommand(channelUID, DecimalType.valueOf("0"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to turn on the radio", assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER)); "We should be able to turn on the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(channelUID, IncreaseDecreaseType.INCREASE); radioHandler.handleCommand(channelUID, IncreaseDecreaseType.INCREASE);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to increase the volume correctly", assertTrue(radioServiceDummy.containsRequestParameter(1, VOLUME),
radioServiceDummy.containsRequestParameter(1, VOLUME)); "We should be able to increase the volume correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(channelUID, IncreaseDecreaseType.DECREASE); radioHandler.handleCommand(channelUID, IncreaseDecreaseType.DECREASE);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to increase the volume correctly", assertTrue(radioServiceDummy.containsRequestParameter(0, VOLUME),
radioServiceDummy.containsRequestParameter(0, VOLUME)); "We should be able to increase the volume correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
// Trying to decrease one more time // Trying to decrease one more time
radioHandler.handleCommand(channelUID, IncreaseDecreaseType.DECREASE); radioHandler.handleCommand(channelUID, IncreaseDecreaseType.DECREASE);
waitForAssert(() -> { waitForAssert(() -> {
assertFalse("We should be able to decrease the volume correctly", assertFalse(radioServiceDummy.containsRequestParameter(0, VOLUME),
radioServiceDummy.containsRequestParameter(0, VOLUME)); "We should be able to decrease the volume correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }
@ -640,30 +640,30 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
// First we have to make sure that the item state is 0 // First we have to make sure that the item state is 0
radioHandler.handleCommand(channelUID, DecimalType.valueOf("0")); radioHandler.handleCommand(channelUID, DecimalType.valueOf("0"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to turn on the radio", assertTrue(radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER),
radioServiceDummy.containsRequestParameter(1, CHANNEL_POWER)); "We should be able to turn on the radio");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(channelUID, UpDownType.UP); radioHandler.handleCommand(channelUID, UpDownType.UP);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to increase the volume correctly", assertTrue(radioServiceDummy.containsRequestParameter(1, VOLUME),
radioServiceDummy.containsRequestParameter(1, VOLUME)); "We should be able to increase the volume correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
radioHandler.handleCommand(channelUID, UpDownType.DOWN); radioHandler.handleCommand(channelUID, UpDownType.DOWN);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to decrease the volume correctly", assertTrue(radioServiceDummy.containsRequestParameter(0, VOLUME),
radioServiceDummy.containsRequestParameter(0, VOLUME)); "We should be able to decrease the volume correctly");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
// Trying to decrease one more time // Trying to decrease one more time
radioHandler.handleCommand(channelUID, UpDownType.DOWN); radioHandler.handleCommand(channelUID, UpDownType.DOWN);
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We shouldn't be able to decrease the volume below 0", assertTrue(radioServiceDummy.areRequestParametersEmpty(),
radioServiceDummy.areRequestParametersEmpty()); "We shouldn't be able to decrease the volume below 0");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }
@ -687,8 +687,8 @@ public class FSInternetRadioHandlerJavaTest extends JavaTest {
radioHandler.handleCommand(presetChannelUID, DecimalType.valueOf("100")); radioHandler.handleCommand(presetChannelUID, DecimalType.valueOf("100"));
waitForAssert(() -> { waitForAssert(() -> {
assertTrue("We should be able to set value to the preset", assertTrue(radioServiceDummy.containsRequestParameter(100, PRESET),
radioServiceDummy.containsRequestParameter(100, PRESET)); "We should be able to set value to the preset");
radioServiceDummy.clearRequestParameters(); radioServiceDummy.clearRequestParameters();
}); });
} }

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.hdpowerview; package org.openhab.binding.hdpowerview;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.openhab.binding.hdpowerview.internal.api.ActuatorClass.*; import static org.openhab.binding.hdpowerview.internal.api.ActuatorClass.*;
import static org.openhab.binding.hdpowerview.internal.api.CoordinateSystem.*; import static org.openhab.binding.hdpowerview.internal.api.CoordinateSystem.*;
@ -28,7 +28,7 @@ import javax.ws.rs.client.ClientBuilder;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.hdpowerview.internal.HDPowerViewWebTargets; import org.openhab.binding.hdpowerview.internal.HDPowerViewWebTargets;
import org.openhab.binding.hdpowerview.internal.HubMaintenanceException; import org.openhab.binding.hdpowerview.internal.HubMaintenanceException;
import org.openhab.binding.hdpowerview.internal.api.CoordinateSystem; import org.openhab.binding.hdpowerview.internal.api.CoordinateSystem;

View File

@ -13,10 +13,10 @@
package org.openhab.binding.heos.internal.json; package org.openhab.binding.heos.internal.json;
import static java.lang.Long.valueOf; import static java.lang.Long.valueOf;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute; import org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute;
import org.openhab.binding.heos.internal.json.dto.HeosEvent; import org.openhab.binding.heos.internal.json.dto.HeosEvent;
import org.openhab.binding.heos.internal.json.dto.HeosEventObject; import org.openhab.binding.heos.internal.json.dto.HeosEventObject;

View File

@ -12,13 +12,13 @@
*/ */
package org.openhab.binding.heos.internal.json; package org.openhab.binding.heos.internal.json;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import static org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute.*; import static org.openhab.binding.heos.internal.json.dto.HeosCommunicationAttribute.*;
import java.util.List; import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.heos.internal.json.dto.HeosCommand; import org.openhab.binding.heos.internal.json.dto.HeosCommand;
import org.openhab.binding.heos.internal.json.dto.HeosCommandGroup; import org.openhab.binding.heos.internal.json.dto.HeosCommandGroup;
import org.openhab.binding.heos.internal.json.dto.HeosErrorCode; import org.openhab.binding.heos.internal.json.dto.HeosErrorCode;

View File

@ -12,13 +12,12 @@
*/ */
package org.openhab.binding.heos.internal.json.dto; package org.openhab.binding.heos.internal.json.dto;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.junit.Assert.assertNotNull;
import static org.openhab.binding.heos.internal.json.dto.HeosCommand.*; import static org.openhab.binding.heos.internal.json.dto.HeosCommand.*;
import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.SYSTEM; import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.SYSTEM;
import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests to validate the functioning of the HeosCommandTuple * Tests to validate the functioning of the HeosCommandTuple

View File

@ -20,8 +20,8 @@ import static org.openhab.binding.homematic.test.util.RpcClientMockImpl.*;
import java.io.IOException; import java.io.IOException;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.communicator.message.RpcRequest; import org.openhab.binding.homematic.internal.communicator.message.RpcRequest;
import org.openhab.binding.homematic.internal.communicator.message.XmlRpcRequest; import org.openhab.binding.homematic.internal.communicator.message.XmlRpcRequest;
import org.openhab.binding.homematic.internal.model.HmChannel; import org.openhab.binding.homematic.internal.model.HmChannel;
@ -36,7 +36,7 @@ public class RpcClientTest extends JavaTest {
private RpcClientMockImpl rpcClient; private RpcClientMockImpl rpcClient;
@Before @BeforeEach
public void setup() throws IOException { public void setup() throws IOException {
this.rpcClient = new RpcClientMockImpl(); this.rpcClient = new RpcClientMockImpl();
} }

View File

@ -17,8 +17,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
import java.io.IOException; import java.io.IOException;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.misc.HomematicClientException; import org.openhab.binding.homematic.internal.misc.HomematicClientException;
import org.openhab.binding.homematic.internal.misc.HomematicConstants; import org.openhab.binding.homematic.internal.misc.HomematicConstants;
import org.openhab.binding.homematic.internal.misc.MiscUtils; import org.openhab.binding.homematic.internal.misc.MiscUtils;
@ -44,7 +44,7 @@ public class ButtonDatapointTest extends JavaTest {
private MockEventReceiver mockEventReceiver; private MockEventReceiver mockEventReceiver;
private final ButtonVirtualDatapointHandler bvdpHandler = new ButtonVirtualDatapointHandler(); private final ButtonVirtualDatapointHandler bvdpHandler = new ButtonVirtualDatapointHandler();
@Before @BeforeEach
public void setup() throws IOException { public void setup() throws IOException {
this.mockEventReceiver = new MockEventReceiver(); this.mockEventReceiver = new MockEventReceiver();
} }

View File

@ -12,7 +12,7 @@
*/ */
package org.openhab.binding.homematic.internal.converter; package org.openhab.binding.homematic.internal.converter;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.openhab.binding.homematic.internal.model.HmChannel; import org.openhab.binding.homematic.internal.model.HmChannel;
import org.openhab.binding.homematic.internal.model.HmDatapoint; import org.openhab.binding.homematic.internal.model.HmDatapoint;
import org.openhab.binding.homematic.internal.model.HmDevice; import org.openhab.binding.homematic.internal.model.HmDevice;
@ -34,7 +34,7 @@ public class BaseConverterTest {
protected final HmDatapoint integerQuantityDp = new HmDatapoint("floatIntegerDp", "", HmValueType.INTEGER, null, protected final HmDatapoint integerQuantityDp = new HmDatapoint("floatIntegerDp", "", HmValueType.INTEGER, null,
false, HmParamsetType.VALUES); false, HmParamsetType.VALUES);
@Before @BeforeEach
public void setup() { public void setup() {
HmChannel stubChannel = new HmChannel("stubChannel", 0); HmChannel stubChannel = new HmChannel("stubChannel", 0);
stubChannel.setDevice(new HmDevice("LEQ123456", HmInterface.RF, "HM-STUB-DEVICE", "", "", "")); stubChannel.setDevice(new HmDevice("LEQ123456", HmInterface.RF, "HM-STUB-DEVICE", "", "", ""));

View File

@ -13,9 +13,9 @@
package org.openhab.binding.homematic.internal.converter; package org.openhab.binding.homematic.internal.converter;
import static org.hamcrest.CoreMatchers.*; import static org.hamcrest.CoreMatchers.*;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.converter.type.AbstractTypeConverter; import org.openhab.binding.homematic.internal.converter.type.AbstractTypeConverter;
import org.openhab.binding.homematic.internal.model.HmDatapoint; import org.openhab.binding.homematic.internal.model.HmDatapoint;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;

View File

@ -14,8 +14,9 @@ package org.openhab.binding.homematic.internal.converter;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.converter.type.AbstractTypeConverter; import org.openhab.binding.homematic.internal.converter.type.AbstractTypeConverter;
import org.openhab.binding.homematic.internal.converter.type.DecimalTypeConverter; import org.openhab.binding.homematic.internal.converter.type.DecimalTypeConverter;
import org.openhab.binding.homematic.internal.converter.type.QuantityTypeConverter; import org.openhab.binding.homematic.internal.converter.type.QuantityTypeConverter;
@ -99,15 +100,15 @@ public class ConvertToBindingTest extends BaseConverterTest {
assertThat(convertedValue, is(42)); assertThat(convertedValue, is(42));
} }
@Test(expected = ConverterException.class) @Test
public void testQuantityTypeConverterFailsToConvertDecimalType() throws ConverterException { public void testQuantityTypeConverterFailsToConvertDecimalType() {
QuantityTypeConverter converter = new QuantityTypeConverter(); QuantityTypeConverter converter = new QuantityTypeConverter();
converter.convertToBinding(new DecimalType(99.9), floatDp); assertThrows(ConverterException.class, () -> converter.convertToBinding(new DecimalType(99.9), floatDp));
} }
@Test(expected = ConverterException.class) @Test
public void testDecimalTypeConverterFailsToConvertQuantityType() throws ConverterException { public void testDecimalTypeConverterFailsToConvertQuantityType() {
DecimalTypeConverter converter = new DecimalTypeConverter(); DecimalTypeConverter converter = new DecimalTypeConverter();
converter.convertToBinding(new QuantityType<>("99.9 %"), floatDp); assertThrows(ConverterException.class, () -> converter.convertToBinding(new QuantityType<>("99.9 %"), floatDp));
} }
} }

View File

@ -15,7 +15,7 @@ package org.openhab.binding.homematic.internal.converter;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.converter.type.DecimalTypeConverter; import org.openhab.binding.homematic.internal.converter.type.DecimalTypeConverter;
import org.openhab.binding.homematic.internal.converter.type.OnOffTypeConverter; import org.openhab.binding.homematic.internal.converter.type.OnOffTypeConverter;
import org.openhab.binding.homematic.internal.converter.type.OpenClosedTypeConverter; import org.openhab.binding.homematic.internal.converter.type.OpenClosedTypeConverter;

View File

@ -21,8 +21,8 @@ import static org.openhab.binding.homematic.test.util.DimmerHelper.createDimmerH
import java.io.IOException; import java.io.IOException;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.communicator.HomematicGateway; import org.openhab.binding.homematic.internal.communicator.HomematicGateway;
import org.openhab.binding.homematic.internal.handler.HomematicBridgeHandler; import org.openhab.binding.homematic.internal.handler.HomematicBridgeHandler;
import org.openhab.binding.homematic.internal.model.HmDevice; import org.openhab.binding.homematic.internal.model.HmDevice;
@ -46,7 +46,7 @@ public class HomematicDeviceDiscoveryServiceTest extends JavaTest {
private HomematicDeviceDiscoveryService homematicDeviceDiscoveryService; private HomematicDeviceDiscoveryService homematicDeviceDiscoveryService;
private HomematicBridgeHandler homematicBridgeHandler; private HomematicBridgeHandler homematicBridgeHandler;
@Before @BeforeEach
public void setup() throws IOException { public void setup() throws IOException {
this.homematicBridgeHandler = mockHomematicBridgeHandler(); this.homematicBridgeHandler = mockHomematicBridgeHandler();
this.homematicDeviceDiscoveryService = new HomematicDeviceDiscoveryService(); this.homematicDeviceDiscoveryService = new HomematicDeviceDiscoveryService();

View File

@ -19,8 +19,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Tests for {@link org.openhab.binding.homematic.internal.handler.SimplePortPool}. * Tests for {@link org.openhab.binding.homematic.internal.handler.SimplePortPool}.
@ -31,7 +31,7 @@ public class SimplePortPoolTest {
private SimplePortPool simplePortPool; private SimplePortPool simplePortPool;
@Before @BeforeEach
public void setup() { public void setup() {
this.simplePortPool = new SimplePortPool(); this.simplePortPool = new SimplePortPool();
} }

View File

@ -17,7 +17,7 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.openhab.binding.homematic.test.util.BridgeHelper.createHomematicBridge; import static org.openhab.binding.homematic.test.util.BridgeHelper.createHomematicBridge;
import static org.openhab.binding.homematic.test.util.DimmerHelper.*; import static org.openhab.binding.homematic.test.util.DimmerHelper.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.homematic.internal.model.HmChannel; import org.openhab.binding.homematic.internal.model.HmChannel;
import org.openhab.binding.homematic.internal.model.HmDatapoint; import org.openhab.binding.homematic.internal.model.HmDatapoint;
import org.openhab.binding.homematic.internal.model.HmDatapointInfo; import org.openhab.binding.homematic.internal.model.HmDatapointInfo;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.hue.internal; package org.openhab.binding.hue.internal;
import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* *

View File

@ -13,7 +13,7 @@
package org.openhab.binding.hue.internal; package org.openhab.binding.hue.internal;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
import java.io.IOException; import java.io.IOException;
@ -23,7 +23,7 @@ import java.util.List;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.openhab.binding.hue.internal.HttpClient.Result; import org.openhab.binding.hue.internal.HttpClient.Result;
import org.openhab.binding.hue.internal.exceptions.ApiException; import org.openhab.binding.hue.internal.exceptions.ApiException;

View File

@ -13,9 +13,10 @@
package org.openhab.binding.hue.internal; package org.openhab.binding.hue.internal;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.*; import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.hue.internal.State.ColorMode; import org.openhab.binding.hue.internal.State.ColorMode;
import org.openhab.binding.hue.internal.handler.LightStateConverter; import org.openhab.binding.hue.internal.handler.LightStateConverter;
import org.openhab.core.library.types.DecimalType; import org.openhab.core.library.types.DecimalType;

View File

@ -13,12 +13,12 @@
package org.openhab.binding.hue.internal; package org.openhab.binding.hue.internal;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat; import static org.hamcrest.MatcherAssert.assertThat;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* @author HJiang - initial contribution * @author HJiang - initial contribution

View File

@ -12,15 +12,15 @@
*/ */
package org.openhab.binding.hue.internal.handler; package org.openhab.binding.hue.internal.handler;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*; import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*; import static org.mockito.Mockito.*;
import static org.openhab.binding.hue.internal.HueBindingConstants.*; import static org.openhab.binding.hue.internal.HueBindingConstants.*;
import java.util.Collections; import java.util.Collections;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.openhab.binding.hue.internal.FullConfig; import org.openhab.binding.hue.internal.FullConfig;
import org.openhab.binding.hue.internal.FullLight; import org.openhab.binding.hue.internal.FullLight;
@ -65,7 +65,7 @@ public class HueLightHandlerTest {
private Gson gson; private Gson gson;
@Before @BeforeEach
public void setUp() { public void setUp() {
gson = new Gson(); gson = new Gson();
} }

View File

@ -12,15 +12,15 @@
*/ */
package org.openhab.binding.icalendar.internal.logic; package org.openhab.binding.icalendar.internal.logic;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.time.Instant; import java.time.Instant;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.jupiter.api.BeforeEach;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.core.library.types.HSBType; import org.openhab.core.library.types.HSBType;
import org.openhab.core.library.types.OnOffType; import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.OpenClosedType; import org.openhab.core.library.types.OpenClosedType;
@ -45,7 +45,7 @@ public class BiweeklyPresentableCalendarTest {
private AbstractPresentableCalendar calendar2; private AbstractPresentableCalendar calendar2;
private AbstractPresentableCalendar calendar3; private AbstractPresentableCalendar calendar3;
@Before @BeforeEach
public void setUp() throws IOException, CalendarException { public void setUp() throws IOException, CalendarException {
calendar = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test.ics")); calendar = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test.ics"));
calendar2 = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test2.ics")); calendar2 = new BiweeklyPresentableCalendar(new FileInputStream("src/test/resources/test2.ics"));

View File

@ -12,11 +12,11 @@
*/ */
package org.openhab.binding.ihc.internal; package org.openhab.binding.ihc.internal;
import static org.junit.Assert.*; import static org.junit.jupiter.api.Assertions.*;
import java.time.Duration; import java.time.Duration;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Test for IHC / ELKO binding * Test for IHC / ELKO binding

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal; package org.openhab.binding.ihc.internal;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
/** /**
* Test for IHC / ELKO binding * Test for IHC / ELKO binding

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSDateValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSDateValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimeValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimeValue;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSEnumValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSEnumValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSFloatingPointValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSFloatingPointValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@ -42,16 +42,18 @@ public class DecimalTypeWSFloatingPointValueConverterTest {
assertEquals(new DecimalType(2.54), type); assertEquals(new DecimalType(2.54), type);
} }
@Test(expected = ConversionException.class) @Test
public void testMinExceed() throws ConversionException { public void testMinExceed() {
WSFloatingPointValue val = new WSFloatingPointValue(12345, 0, -100, 100); WSFloatingPointValue val = new WSFloatingPointValue(12345, 0, -100, 100);
val = convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null)); assertThrows(ConversionException.class,
() -> convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null)));
} }
@Test(expected = ConversionException.class) @Test
public void testMaxExceed() throws ConversionException { public void testMaxExceed() {
WSFloatingPointValue val = new WSFloatingPointValue(12345, 0, -100, 100); WSFloatingPointValue val = new WSFloatingPointValue(12345, 0, -100, 100);
val = convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null)); assertThrows(ConversionException.class,
() -> convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null)));
} }
private WSFloatingPointValue convertFromOHType(WSFloatingPointValue IHCvalue, Type OHval, private WSFloatingPointValue convertFromOHType(WSFloatingPointValue IHCvalue, Type OHval,

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@ -42,16 +42,18 @@ public class DecimalTypeWSIntegerValueConverterTest {
assertEquals(new DecimalType(2), type); assertEquals(new DecimalType(2), type);
} }
@Test(expected = ConversionException.class) @Test
public void testMinExceed() throws ConversionException { public void testMinExceed() {
WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100); WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
val = convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null)); assertThrows(ConversionException.class,
() -> convertFromOHType(val, new DecimalType(-101.5), new ConverterAdditionalInfo(null, false, null)));
} }
@Test(expected = ConversionException.class) @Test
public void testMaxExceed() throws ConversionException { public void testMaxExceed() {
WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100); WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
val = convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null)); assertThrows(ConversionException.class,
() -> convertFromOHType(val, new DecimalType(101.5), new ConverterAdditionalInfo(null, false, null)));
} }
private WSIntegerValue convertFromOHType(WSIntegerValue IHCvalue, Type OHval, private WSIntegerValue convertFromOHType(WSIntegerValue IHCvalue, Type OHval,

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimerValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimerValue;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSWeekdayValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSWeekdayValue;

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@ -12,13 +12,13 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@ -69,15 +69,15 @@ public class OnOffTypeWSIntegerValueConverterTest {
assertEquals(OnOffType.ON, type); assertEquals(OnOffType.ON, type);
} }
@Test(expected = ConversionException.class) @Test
public void testOnLevelledError() throws ConversionException { public void testOnLevelledError() {
WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100); WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
Map<Command, Object> commandLevels = new HashMap<>(); Map<Command, Object> commandLevels = new HashMap<>();
commandLevels.put(OnOffType.ON, "70"); commandLevels.put(OnOffType.ON, "70");
val = convertFromOHType(val, OnOffType.ON, assertThrows(ConversionException.class, () -> convertFromOHType(val, OnOffType.ON,
new ConverterAdditionalInfo(null, false, Collections.unmodifiableMap(commandLevels))); new ConverterAdditionalInfo(null, false, Collections.unmodifiableMap(commandLevels))));
} }
@Test @Test

View File

@ -12,9 +12,9 @@
*/ */
package org.openhab.binding.ihc.internal.converters; package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test; import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException; import org.openhab.binding.ihc.internal.ws.exeptions.ConversionException;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue; import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

Some files were not shown because too many files have changed in this diff Show More