Migrate tests to JUnit 5 (#8519)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -20,8 +20,8 @@ import static org.openhab.binding.homematic.test.util.RpcClientMockImpl.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.homematic.internal.communicator.message.RpcRequest;
|
||||
import org.openhab.binding.homematic.internal.communicator.message.XmlRpcRequest;
|
||||
import org.openhab.binding.homematic.internal.model.HmChannel;
|
||||
@@ -36,7 +36,7 @@ public class RpcClientTest extends JavaTest {
|
||||
|
||||
private RpcClientMockImpl rpcClient;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
this.rpcClient = new RpcClientMockImpl();
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.homematic.internal.misc.HomematicClientException;
|
||||
import org.openhab.binding.homematic.internal.misc.HomematicConstants;
|
||||
import org.openhab.binding.homematic.internal.misc.MiscUtils;
|
||||
@@ -44,7 +44,7 @@ public class ButtonDatapointTest extends JavaTest {
|
||||
private MockEventReceiver mockEventReceiver;
|
||||
private final ButtonVirtualDatapointHandler bvdpHandler = new ButtonVirtualDatapointHandler();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
this.mockEventReceiver = new MockEventReceiver();
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
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.HmDatapoint;
|
||||
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,
|
||||
false, HmParamsetType.VALUES);
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
HmChannel stubChannel = new HmChannel("stubChannel", 0);
|
||||
stubChannel.setDevice(new HmDevice("LEQ123456", HmInterface.RF, "HM-STUB-DEVICE", "", "", ""));
|
||||
|
||||
@@ -13,9 +13,9 @@
|
||||
package org.openhab.binding.homematic.internal.converter;
|
||||
|
||||
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.model.HmDatapoint;
|
||||
import org.openhab.core.library.types.DecimalType;
|
||||
|
||||
@@ -14,8 +14,9 @@ package org.openhab.binding.homematic.internal.converter;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
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.DecimalTypeConverter;
|
||||
import org.openhab.binding.homematic.internal.converter.type.QuantityTypeConverter;
|
||||
@@ -99,15 +100,15 @@ public class ConvertToBindingTest extends BaseConverterTest {
|
||||
assertThat(convertedValue, is(42));
|
||||
}
|
||||
|
||||
@Test(expected = ConverterException.class)
|
||||
public void testQuantityTypeConverterFailsToConvertDecimalType() throws ConverterException {
|
||||
@Test
|
||||
public void testQuantityTypeConverterFailsToConvertDecimalType() {
|
||||
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)
|
||||
public void testDecimalTypeConverterFailsToConvertQuantityType() throws ConverterException {
|
||||
@Test
|
||||
public void testDecimalTypeConverterFailsToConvertQuantityType() {
|
||||
DecimalTypeConverter converter = new DecimalTypeConverter();
|
||||
converter.convertToBinding(new QuantityType<>("99.9 %"), floatDp);
|
||||
assertThrows(ConverterException.class, () -> converter.convertToBinding(new QuantityType<>("99.9 %"), floatDp));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ package org.openhab.binding.homematic.internal.converter;
|
||||
import static org.hamcrest.CoreMatchers.instanceOf;
|
||||
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.OnOffTypeConverter;
|
||||
import org.openhab.binding.homematic.internal.converter.type.OpenClosedTypeConverter;
|
||||
|
||||
@@ -21,8 +21,8 @@ import static org.openhab.binding.homematic.test.util.DimmerHelper.createDimmerH
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.homematic.internal.communicator.HomematicGateway;
|
||||
import org.openhab.binding.homematic.internal.handler.HomematicBridgeHandler;
|
||||
import org.openhab.binding.homematic.internal.model.HmDevice;
|
||||
@@ -46,7 +46,7 @@ public class HomematicDeviceDiscoveryServiceTest extends JavaTest {
|
||||
private HomematicDeviceDiscoveryService homematicDeviceDiscoveryService;
|
||||
private HomematicBridgeHandler homematicBridgeHandler;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() throws IOException {
|
||||
this.homematicBridgeHandler = mockHomematicBridgeHandler();
|
||||
this.homematicDeviceDiscoveryService = new HomematicDeviceDiscoveryService();
|
||||
|
||||
@@ -19,8 +19,8 @@ import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link org.openhab.binding.homematic.internal.handler.SimplePortPool}.
|
||||
@@ -31,7 +31,7 @@ public class SimplePortPoolTest {
|
||||
|
||||
private SimplePortPool simplePortPool;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setup() {
|
||||
this.simplePortPool = new SimplePortPool();
|
||||
}
|
||||
|
||||
@@ -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.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.HmDatapoint;
|
||||
import org.openhab.binding.homematic.internal.model.HmDatapointInfo;
|
||||
|
||||
Reference in New Issue
Block a user