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
478 changed files with 3996 additions and 4419 deletions

View File

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

View File

@@ -12,9 +12,9 @@
*/
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

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSDateValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSResourceValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimeValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSEnumValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSFloatingPointValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@@ -42,16 +42,18 @@ public class DecimalTypeWSFloatingPointValueConverterTest {
assertEquals(new DecimalType(2.54), type);
}
@Test(expected = ConversionException.class)
public void testMinExceed() throws ConversionException {
@Test
public void testMinExceed() {
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)
public void testMaxExceed() throws ConversionException {
@Test
public void testMaxExceed() {
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,

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@@ -42,16 +42,18 @@ public class DecimalTypeWSIntegerValueConverterTest {
assertEquals(new DecimalType(2), type);
}
@Test(expected = ConversionException.class)
public void testMinExceed() throws ConversionException {
@Test
public void testMinExceed() {
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)
public void testMaxExceed() throws ConversionException {
@Test
public void testMaxExceed() {
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,

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSResourceValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSTimerValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSResourceValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSWeekdayValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,13 +12,13 @@
*/
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.HashMap;
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.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;
@@ -69,15 +69,15 @@ public class OnOffTypeWSIntegerValueConverterTest {
assertEquals(OnOffType.ON, type);
}
@Test(expected = ConversionException.class)
public void testOnLevelledError() throws ConversionException {
@Test
public void testOnLevelledError() {
WSIntegerValue val = new WSIntegerValue(12345, 0, -100, 100);
Map<Command, Object> commandLevels = new HashMap<>();
commandLevels.put(OnOffType.ON, "70");
val = convertFromOHType(val, OnOffType.ON,
new ConverterAdditionalInfo(null, false, Collections.unmodifiableMap(commandLevels)));
assertThrows(ConversionException.class, () -> convertFromOHType(val, OnOffType.ON,
new ConverterAdditionalInfo(null, false, Collections.unmodifiableMap(commandLevels))));
}
@Test

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,11 +12,11 @@
*/
package org.openhab.binding.ihc.internal.converters;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
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.projectfile.IhcEnumValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSEnumValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSBooleanValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,9 +12,9 @@
*/
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.resourcevalues.WSIntegerValue;
import org.openhab.binding.ihc.internal.ws.resourcevalues.WSResourceValue;

View File

@@ -12,14 +12,14 @@
*/
package org.openhab.binding.ihc.internal.ws;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.Mockito.*;
import java.io.UnsupportedEncodingException;
import java.net.SocketTimeoutException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.ArgumentMatchers;
import org.openhab.binding.ihc.internal.ws.datatypes.WSFile;
import org.openhab.binding.ihc.internal.ws.datatypes.WSProjectInfo;
@@ -34,7 +34,7 @@ public class IhcClientTest {
private IhcClient ihcClient;
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcClient = spy(new IhcClient("test1", "test2", "test3"));
WSProjectInfo projectInfo = new WSProjectInfo();

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.ihc.internal.ws;
import static org.junit.Assert.fail;
import static org.junit.jupiter.api.Assertions.*;
import java.io.BufferedReader;
import java.io.IOException;

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.ihc.internal.ws.services;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
@@ -21,8 +21,8 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
import org.openhab.binding.ihc.internal.ws.datatypes.WSRFDevice;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -42,7 +42,7 @@ public class IhcAirlinkManagementServiceTest {
private String query;
private final int timeout = 100;
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcAirlinkManagementService = spy(new IhcAirlinkManagementService(host, timeout, new IhcConnectionPool()));

View File

@@ -12,14 +12,14 @@
*/
package org.openhab.binding.ihc.internal.ws.services;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
import java.net.SocketTimeoutException;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
import org.openhab.binding.ihc.internal.ws.datatypes.WSLoginResult;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -37,7 +37,7 @@ public class IhcAuthenticationServiceTest {
private final String url = "https://1.1.1.1/ws/AuthenticationService";
private final int timeout = 100;
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcAuthenticationService = spy(new IhcAuthenticationService(host, timeout, new IhcConnectionPool()));

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.ihc.internal.ws.services;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
@@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
import org.openhab.binding.ihc.internal.ws.datatypes.WSSystemInfo;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -43,7 +43,7 @@ public class IhcConfigurationServiceTest {
private Map<String, String> requestProps = new HashMap<>();
private final int timeout = 100;
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcConfigurationService = spy(new IhcConfigurationService(host, timeout, new IhcConnectionPool()));
requestProps.clear();

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.ihc.internal.ws.services;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
@@ -21,8 +21,8 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.IhcClient;
import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
import org.openhab.binding.ihc.internal.ws.datatypes.WSControllerState;
@@ -45,7 +45,7 @@ public class IhcControllerServiceTest {
private String query;
private final int timeout = 100;
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcControllerService = spy(new IhcControllerService(host, timeout, new IhcConnectionPool()));
@@ -138,6 +138,6 @@ public class IhcControllerServiceTest {
final byte[] expectedResult = "LvVF4VWSi0WqRKps7lGH6U....OBCl1gwKGbvYM1SDh".getBytes();
final WSFile result = ihcControllerService.getProjectSegment(1, 1001, 2002);
assertTrue("Result bytes doesn't match to expected bytes", Arrays.equals(expectedResult, result.getData()));
assertTrue(Arrays.equals(expectedResult, result.getData()), "Result bytes doesn't match to expected bytes");
}
}

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.ihc.internal.ws.services;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.*;
import static org.mockito.Mockito.*;
@@ -20,8 +20,8 @@ import java.net.SocketTimeoutException;
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;
import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
import org.openhab.binding.ihc.internal.ws.http.IhcConnectionPool;
@@ -46,7 +46,7 @@ public class IhcResourceInteractionServiceTest {
private final String host = "1.1.1.1";
private final String url = "https://1.1.1.1/ws/ResourceInteractionService";
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcResourceInteractionService = spy(new IhcResourceInteractionService(host, 0, new IhcConnectionPool()));

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.ihc.internal.ws.services;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
@@ -22,8 +22,8 @@ import java.time.format.DateTimeFormatter;
import java.util.HashMap;
import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.ihc.internal.ws.ResourceFileUtils;
import org.openhab.binding.ihc.internal.ws.datatypes.WSTimeManagerSettings;
import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
@@ -42,7 +42,7 @@ public class IhcTimeServiceTest {
private Map<String, String> requestProps = new HashMap<>();
private final int timeout = 100;
@Before
@BeforeEach
public void setUp() throws IhcExecption, SocketTimeoutException {
ihcTimeService = spy(new IhcTimeService(host, timeout, new IhcConnectionPool()));