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

@@ -21,7 +21,6 @@
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
/**
* Type adapter for jsr310 {@link LocalTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
*/
public class LocalTimeTypeAdapter extends TemporalTypeAdapter<LocalTime> {
public LocalTimeTypeAdapter() {
super(LocalTime::parse);
}
public LocalTimeTypeAdapter() {
super(LocalTime::parse);
}
}

View File

@@ -21,7 +21,6 @@
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
import java.time.OffsetDateTime;
import java.time.format.DateTimeFormatter;
/**
* Type adapter for jsr310 {@link OffsetDateTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
*/
public class OffsetDateTimeTypeAdapter extends DateTimeTypeAdapter<OffsetDateTime> {
public OffsetDateTimeTypeAdapter() {
super(OffsetDateTime::parse);
}
public OffsetDateTimeTypeAdapter() {
super(OffsetDateTime::parse);
}
}

View File

@@ -21,7 +21,6 @@
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
import java.time.OffsetTime;
import java.time.format.DateTimeFormatter;
/**
* Type adapter for jsr310 {@link OffsetTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
*/
public class OffsetTimeTypeAdapter extends TemporalTypeAdapter<OffsetTime> {
public OffsetTimeTypeAdapter() {
super(OffsetTime::parse);
}
public OffsetTimeTypeAdapter() {
super(OffsetTime::parse);
}
}

View File

@@ -21,7 +21,6 @@
package org.openhab.binding.lametrictime.api.common.impl.typeadapters.imported;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
/**
* Type adapter for jsr310 {@link ZonedDateTime} class.
@@ -30,7 +29,7 @@ import java.time.format.DateTimeFormatter;
*/
public class ZonedDateTimeTypeAdapter extends DateTimeTypeAdapter<ZonedDateTime> {
public ZonedDateTimeTypeAdapter() {
super(ZonedDateTime::parse);
}
public ZonedDateTimeTypeAdapter() {
super(ZonedDateTime::parse);
}
}

View File

@@ -15,9 +15,9 @@
*/
package org.openhab.binding.lametrictime.api.impl;
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.lametrictime.api.test.AbstractTest;
public class FileIconTest extends AbstractTest

View File

@@ -15,6 +15,8 @@
*/
package org.openhab.binding.lametrictime.api.local.impl;
import static org.junit.jupiter.api.Assertions.assertThrows;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -22,9 +24,9 @@ import java.io.InputStream;
import java.util.Arrays;
import java.util.Properties;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.local.ApplicationActionException;
import org.openhab.binding.lametrictime.api.local.ApplicationActivationException;
import org.openhab.binding.lametrictime.api.local.ApplicationNotFoundException;
@@ -62,14 +64,14 @@ import org.openhab.binding.lametrictime.api.test.TestUtil;
* integration-test'.
* </p>
*/
@Ignore
@Disabled
public class LaMetricTimeLocalImplIT {
private static final String PROP_HOST = "host";
private static final String PROP_API_KEY = "apiKey";
private static LaMetricTimeLocalImpl local;
@BeforeClass
@BeforeAll
public static void setup() throws IOException {
File file = TestUtil.getTestDataPath(LaMetricTimeLocalImplIT.class, "device.properties").toFile();
if (!file.exists()) {
@@ -126,9 +128,9 @@ public class LaMetricTimeLocalImplIT {
local.getNotifications();
}
@Test(expected = NotificationNotFoundException.class)
public void testGetInvalidNotification() throws NotificationNotFoundException {
local.getNotification("invalid");
@Test
public void testGetInvalidNotification() {
assertThrows(NotificationNotFoundException.class, () -> local.getNotification("invalid"));
}
@Test
@@ -202,9 +204,9 @@ public class LaMetricTimeLocalImplIT {
local.getApplication(CoreApps.weather().getPackageName());
}
@Test(expected = ApplicationNotFoundException.class)
public void testGetInvalidApplication() throws ApplicationNotFoundException {
local.getApplication("invalid");
@Test
public void testGetInvalidApplication() {
assertThrows(ApplicationNotFoundException.class, () -> local.getApplication("invalid"));
}
@Test

View File

@@ -15,15 +15,15 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import java.util.Iterator;
import java.util.SortedMap;
import java.util.TreeMap;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -33,7 +33,7 @@ public class ActionTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,15 +15,15 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.*;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import java.util.Iterator;
import java.util.SortedMap;
import java.util.TreeMap;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -33,7 +33,7 @@ public class ApplicationTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,12 +15,12 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -30,7 +30,7 @@ public class AudioTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,12 +15,12 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -30,7 +30,7 @@ public class BluetoothTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,13 +15,13 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import java.util.Arrays;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -31,7 +31,7 @@ public class FrameTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,12 +15,12 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -30,7 +30,7 @@ public class GoalDataTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,45 +15,40 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import java.util.TreeMap;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
import com.google.gson.Gson;
public class UpdateActionTest extends AbstractTest
{
public class UpdateActionTest extends AbstractTest {
private static Gson gson;
@BeforeClass
public static void setUpBeforeClass()
{
@BeforeAll
public static void setUpBeforeClass() {
gson = GsonGenerator.create(true);
}
@Test
@SuppressWarnings("serial")
public void testSerialize() throws Exception
{
public void testSerialize() throws Exception {
UpdateAction action = new UpdateAction().withId("countdown.configure")
// @formatter:off
// @formatter:off
.withParameters(new TreeMap<String, Parameter>(){{put("duration", new IntegerParameter().withValue(30));}});
// @formatter:on
assertEquals(readJson("update-action.json"), gson.toJson(action));
}
@Test(expected = UnsupportedOperationException.class)
public void testDeserialize() throws Exception
{
try (FileReader reader = new FileReader(getTestDataFile("update-action.json")))
{
gson.fromJson(reader, UpdateAction.class);
@Test
public void testDeserialize() throws Exception {
try (FileReader reader = new FileReader(getTestDataFile("update-action.json"))) {
assertThrows(UnsupportedOperationException.class, () -> gson.fromJson(reader, UpdateAction.class));
}
}
}

View File

@@ -15,13 +15,13 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileReader;
import java.util.HashMap;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -32,7 +32,7 @@ public class WidgetTest extends AbstractTest
{
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass()
{
gson = GsonGenerator.create(true);

View File

@@ -15,15 +15,15 @@
*/
package org.openhab.binding.lametrictime.api.local.model;
import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.*;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.openhab.binding.lametrictime.api.common.impl.GsonGenerator;
import org.openhab.binding.lametrictime.api.test.AbstractTest;
@@ -32,7 +32,7 @@ import com.google.gson.Gson;
public class WidgetUpdatesTest extends AbstractTest {
private static Gson gson;
@BeforeClass
@BeforeAll
public static void setUpBeforeClass() {
gson = GsonGenerator.create(true);
}

View File

@@ -15,32 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.openhab.binding.lametrictime.api.model.enums.BrightnessMode;
import org.junit.jupiter.api.Test;
public class BrightnessModeTest
{
public class BrightnessModeTest {
@Test
public void testConversion()
{
for (BrightnessMode value : BrightnessMode.values())
{
public void testConversion() {
for (BrightnessMode value : BrightnessMode.values()) {
assertEquals(value, BrightnessMode.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(BrightnessMode.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(BrightnessMode.toEnum(null));
}
}

View File

@@ -15,32 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.openhab.binding.lametrictime.api.model.enums.DisplayType;
import org.junit.jupiter.api.Test;
public class DisplayTypeTest
{
public class DisplayTypeTest {
@Test
public void testConversion()
{
for (DisplayType value : DisplayType.values())
{
public void testConversion() {
for (DisplayType value : DisplayType.values()) {
assertEquals(value, DisplayType.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(DisplayType.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(DisplayType.toEnum(null));
}
}

View File

@@ -15,32 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.openhab.binding.lametrictime.api.model.enums.IconType;
import org.junit.jupiter.api.Test;
public class IconTypeTest
{
public class IconTypeTest {
@Test
public void testConversion()
{
for (IconType value : IconType.values())
{
public void testConversion() {
for (IconType value : IconType.values()) {
assertEquals(value, IconType.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(IconType.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(IconType.toEnum(null));
}
}

View File

@@ -15,31 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class IpModeTest
{
public class IpModeTest {
@Test
public void testConversion()
{
for (IpMode value : IpMode.values())
{
public void testConversion() {
for (IpMode value : IpMode.values()) {
assertEquals(value, IpMode.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(IpMode.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(IpMode.toEnum(null));
}
}

View File

@@ -15,32 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.openhab.binding.lametrictime.api.model.enums.Priority;
import org.junit.jupiter.api.Test;
public class PriorityTest
{
public class PriorityTest {
@Test
public void testConversion()
{
for (Priority value : Priority.values())
{
public void testConversion() {
for (Priority value : Priority.values()) {
assertEquals(value, Priority.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(Priority.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(Priority.toEnum(null));
}
}

View File

@@ -15,32 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.openhab.binding.lametrictime.api.model.enums.SoundCategory;
import org.junit.jupiter.api.Test;
public class SoundCategoryTest
{
public class SoundCategoryTest {
@Test
public void testConversion()
{
for (SoundCategory value : SoundCategory.values())
{
public void testConversion() {
for (SoundCategory value : SoundCategory.values()) {
assertEquals(value, SoundCategory.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(SoundCategory.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(SoundCategory.toEnum(null));
}
}

View File

@@ -15,32 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.openhab.binding.lametrictime.api.model.enums.Sound;
import org.junit.jupiter.api.Test;
public class SoundTest
{
public class SoundTest {
@Test
public void testConversion()
{
for (Sound value : Sound.values())
{
public void testConversion() {
for (Sound value : Sound.values()) {
assertEquals(value, Sound.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(Sound.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(Sound.toEnum(null));
}
}

View File

@@ -15,31 +15,25 @@
*/
package org.openhab.binding.lametrictime.api.model.enums;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.*;
import org.junit.Test;
import org.junit.jupiter.api.Test;
public class WifiEncryptionTest
{
public class WifiEncryptionTest {
@Test
public void testConversion()
{
for (WifiEncryption value : WifiEncryption.values())
{
public void testConversion() {
for (WifiEncryption value : WifiEncryption.values()) {
assertEquals(value, WifiEncryption.toEnum(value.toRaw()));
}
}
@Test
public void testInvalidRawValue()
{
public void testInvalidRawValue() {
assertNull(WifiEncryption.toEnum("invalid raw value"));
}
@Test
public void testNullRawValue()
{
public void testNullRawValue() {
assertNull(WifiEncryption.toEnum(null));
}
}