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,10 +12,10 @@
*/
package org.openhab.binding.max.internal.command;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Tests cases for {@link FCommand}.

View File

@@ -12,13 +12,13 @@
*/
package org.openhab.binding.max.internal.command;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.device.Device;
import org.openhab.binding.max.internal.device.DeviceConfiguration;
import org.openhab.binding.max.internal.device.RoomInformation;

View File

@@ -12,13 +12,13 @@
*/
package org.openhab.binding.max.internal.command;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.nio.charset.StandardCharsets;
import java.util.Base64;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.Utils;
import org.openhab.binding.max.internal.device.ThermostatModeType;

View File

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

View File

@@ -12,12 +12,12 @@
*/
package org.openhab.binding.max.internal.command;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Base64;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.Utils;
/**

View File

@@ -12,10 +12,10 @@
*/
package org.openhab.binding.max.internal.command;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Tests cases for {@link ZCommand}.

View File

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

View File

@@ -12,12 +12,12 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.device.DeviceConfiguration;
import org.openhab.binding.max.internal.device.DeviceType;
@@ -35,7 +35,7 @@ public class ConfigurationTest {
private final CMessage message = new CMessage(RAW_DATA);
private @Nullable DeviceConfiguration configuration;
@Before
@BeforeEach
public void before() {
configuration = DeviceConfiguration.create(message);
}

View File

@@ -12,10 +12,10 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Tests cases for {@link FMessage}.

View File

@@ -12,14 +12,14 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.util.Date;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.Utils;
/**

View File

@@ -12,7 +12,7 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.Collection;
@@ -21,8 +21,8 @@ import java.util.List;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Before;
import org.junit.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.device.Device;
import org.openhab.binding.max.internal.device.DeviceConfiguration;
import org.openhab.binding.max.internal.device.DeviceInformation;
@@ -46,7 +46,7 @@ public class LMessageTest {
private final LMessage message = new LMessage(RAWDATA);
private final List<DeviceConfiguration> configurations = new ArrayList<>();
@Before
@BeforeEach
public void setUp() {
createTestDevices();
}
@@ -90,10 +90,10 @@ public class LMessageTest {
@Test
public void allDevicesCreatedFromMessage() {
Collection<? extends Device> devices = message.getDevices(configurations);
assertEquals("Incorrect number of devices created", testDevices.size(), devices.size());
assertEquals(testDevices.size(), devices.size(), "Incorrect number of devices created");
for (Device device : devices) {
assertTrue("Unexpected device created: " + device.getRFAddress(),
testDevices.containsKey(device.getRFAddress()));
assertTrue(testDevices.containsKey(device.getRFAddress()),
"Unexpected device created: " + device.getRFAddress());
}
}
@@ -101,7 +101,7 @@ public class LMessageTest {
public void isCorrectErrorState() {
for (Device device : message.getDevices(configurations)) {
Device testDevice = testDevices.get(device.getRFAddress());
assertEquals("Error set incorrectly in Device", testDevice.isError(), device.isError());
assertEquals(testDevice.isError(), device.isError(), "Error set incorrectly in Device");
}
}
}

View File

@@ -12,12 +12,12 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.List;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.device.DeviceInformation;
import org.openhab.binding.max.internal.device.DeviceType;
import org.openhab.binding.max.internal.device.RoomInformation;

View File

@@ -12,9 +12,10 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.exceptions.IncompleteMessageException;
import org.openhab.binding.max.internal.exceptions.IncorrectMultilineIndexException;
import org.openhab.binding.max.internal.exceptions.MessageIsWaitingException;
@@ -31,12 +32,12 @@ public class MessageProcessorTest {
private final MessageProcessor processor = new MessageProcessor();
private void commonMessageTest(String line, Message expectedMessage) throws Exception {
Assert.assertTrue(this.processor.addReceivedLine(line));
Assert.assertTrue(this.processor.isMessageAvailable());
assertTrue(this.processor.addReceivedLine(line));
assertTrue(this.processor.isMessageAvailable());
Message message = this.processor.pull();
Assert.assertNotNull(message);
Assert.assertEquals(message.getClass().getName(), expectedMessage.getClass().getName());
Assert.assertEquals(expectedMessage.getPayload(), message.getPayload());
assertNotNull(message);
assertEquals(message.getClass().getName(), expectedMessage.getClass().getName());
assertEquals(expectedMessage.getPayload(), message.getPayload());
}
@Test
@@ -101,12 +102,12 @@ public class MessageProcessorTest {
String expectedString = line1 + line2_part2;
MMessage expectedMessage = new MMessage(expectedString);
Assert.assertFalse(this.processor.addReceivedLine(line1));
Assert.assertTrue(this.processor.addReceivedLine(line2));
assertFalse(this.processor.addReceivedLine(line1));
assertTrue(this.processor.addReceivedLine(line2));
Message message = this.processor.pull();
Assert.assertNotNull(message);
Assert.assertEquals(message.getClass().getName(), MMessage.class.getName());
Assert.assertEquals(expectedMessage.getPayload(), message.getPayload());
assertNotNull(message);
assertEquals(message.getClass().getName(), MMessage.class.getName());
assertEquals(expectedMessage.getPayload(), message.getPayload());
}
@Test
@@ -116,16 +117,16 @@ public class MessageProcessorTest {
try {
this.processor.addReceivedLine(line2);
Assert.fail("Expected exception was not thrown.");
fail("Expected exception was not thrown.");
} catch (IncorrectMultilineIndexException e) {
// OK, correct Exception was thrown
}
try {
this.processor.reset();
Assert.assertFalse(this.processor.addReceivedLine(line1));
assertFalse(this.processor.addReceivedLine(line1));
this.processor.addReceivedLine(line2);
Assert.fail("Expected exception was not thrown.");
fail("Expected exception was not thrown.");
} catch (IncorrectMultilineIndexException e) {
// OK, correct Exception was thrown
}
@@ -137,20 +138,20 @@ public class MessageProcessorTest {
String line2 = "M:00,01,VgIBAQpXb2huemltbWVyAAAAAQMQV6lMRVEwOTgyMTU2DldhbmR0aGVybW9zdGF0AQE=";
try {
Assert.assertTrue(this.processor.addReceivedLine(line1));
assertTrue(this.processor.addReceivedLine(line1));
this.processor.addReceivedLine(line2);
Assert.fail("Expected exception was not thrown.");
fail("Expected exception was not thrown.");
} catch (MessageIsWaitingException e) {
// OK, correct Exception was thrown
}
Message message = this.processor.pull();
Assert.assertNotNull(message);
Assert.assertEquals(message.getClass().getName(), HMessage.class.getName());
assertNotNull(message);
assertEquals(message.getClass().getName(), HMessage.class.getName());
this.processor.addReceivedLine(line2);
message = this.processor.pull();
Assert.assertNotNull(message);
Assert.assertEquals(message.getClass().getName(), MMessage.class.getName());
assertNotNull(message);
assertEquals(message.getClass().getName(), MMessage.class.getName());
}
@Test
@@ -159,9 +160,9 @@ public class MessageProcessorTest {
String line2 = "H:KHA0007199,081dd4,0113,00000000,0d524351,10,30,0f0407,1130,03,0000";
try {
Assert.assertFalse(this.processor.addReceivedLine(line1));
assertFalse(this.processor.addReceivedLine(line1));
this.processor.addReceivedLine(line2);
Assert.fail("Expected exception was not thrown.");
fail("Expected exception was not thrown.");
} catch (IncompleteMessageException e) {
// OK, correct Exception was thrown
}
@@ -172,8 +173,8 @@ public class MessageProcessorTest {
String rawData = "X:0ff1bc,EQ/xvAQJEAJMRVEwNzk0MDA3";
try {
Assert.assertFalse(this.processor.addReceivedLine(rawData));
Assert.fail("Expected exception was not thrown.");
assertFalse(this.processor.addReceivedLine(rawData));
fail("Expected exception was not thrown.");
} catch (UnsupportedMessageTypeException e) {
// OK, correct Exception was thrown
}
@@ -187,7 +188,7 @@ public class MessageProcessorTest {
try {
this.processor.pull();
Assert.fail("Expected exception was not thrown.");
fail("Expected exception was not thrown.");
} catch (NoMessageAvailableException e) {
// OK, correct Exception was thrown
}
@@ -199,7 +200,7 @@ public class MessageProcessorTest {
try {
this.processor.addReceivedLine(line1);
Assert.fail("Expected exception was not thrown.");
fail("Expected exception was not thrown.");
} catch (UnprocessableMessageException e) {
// OK, correct Exception was thrown
}

View File

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

View File

@@ -12,10 +12,10 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
/**
* Tests cases for {@link FMessage}.

View File

@@ -12,12 +12,12 @@
*/
package org.openhab.binding.max.internal.message;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.util.Date;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.openhab.binding.max.internal.Utils;
/**