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,14 +12,15 @@
*/
package org.openhab.binding.enigma2.actions;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.*;
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.enigma2.handler.Enigma2Handler;
import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
@@ -37,7 +38,7 @@ public class Enigma2ActionsTest {
private Enigma2Handler enigma2Handler;
public static final String SOME_TEXT = "some Text";
@Before
@BeforeEach
public void setUp() {
enigma2Handler = mock(Enigma2Handler.class);
enigma2Actions = new Enigma2Actions();
@@ -109,9 +110,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendRcCommand("KEY_1");
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testSendRcCommandStaticWithException() {
Enigma2Actions.sendRcCommand(null, "KEY_1");
assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendRcCommand(null, "KEY_1"));
}
@Test
@@ -126,9 +127,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendInfo(10, SOME_TEXT);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testSendInfoStaticWithException() {
Enigma2Actions.sendInfo(null, SOME_TEXT);
assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendInfo(null, SOME_TEXT));
}
@Test
@@ -143,9 +144,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendError(10, SOME_TEXT);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testSendErrorStaticWithException() {
Enigma2Actions.sendError(null, SOME_TEXT);
assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendError(null, SOME_TEXT));
}
@Test
@@ -160,9 +161,9 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendWarning(10, SOME_TEXT);
}
@Test(expected = IllegalArgumentException.class)
@Test
public void testSendWarningStaticWithException() {
Enigma2Actions.sendWarning(null, SOME_TEXT);
assertThrows(IllegalArgumentException.class, () -> Enigma2Actions.sendWarning(null, SOME_TEXT));
}
@Test
@@ -177,8 +178,8 @@ public class Enigma2ActionsTest {
verify(enigma2Handler).sendQuestion(10, SOME_TEXT);
}
@Test(expected = IllegalArgumentException.class)
@Test
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;
import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.*;
import java.time.LocalDateTime;
@@ -23,15 +23,20 @@ import java.util.Optional;
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.enigma2.actions.Enigma2Actions;
import org.openhab.binding.enigma2.internal.Enigma2BindingConstants;
import org.openhab.binding.enigma2.internal.Enigma2Client;
import org.openhab.binding.enigma2.internal.Enigma2Configuration;
import org.openhab.binding.enigma2.internal.Enigma2RemoteKey;
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.Thing;
import org.openhab.core.thing.binding.ThingHandlerCallback;
@@ -58,7 +63,7 @@ public class Enigma2HandlerTest {
@Nullable
private ThingHandlerCallback callback;
@Before
@BeforeEach
public void setUp() {
enigma2Client = mock(Enigma2Client.class);
thing = mock(Thing.class);

View File

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

View File

@@ -13,15 +13,14 @@
package org.openhab.binding.enigma2.internal;
import static org.eclipse.jdt.annotation.Checks.requireNonNull;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
import static org.mockito.Mockito.*;
import static org.openhab.binding.enigma2.internal.Enigma2BindingConstants.THING_TYPE_DEVICE;
import org.eclipse.jdt.annotation.NonNullByDefault;
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.thing.Thing;
import org.openhab.core.thing.ThingTypeUID;

View File

@@ -12,11 +12,11 @@
*/
package org.openhab.binding.enigma2.internal;
import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
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}.

View File

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