Migrate tests to JUnit 5 (#8519)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -13,10 +13,9 @@
|
||||
package org.openhab.binding.dwdunwetter;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.mockito.MockitoAnnotations.initMocks;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.List;
|
||||
@@ -26,10 +25,14 @@ import javax.xml.parsers.DocumentBuilderFactory;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.mockito.junit.jupiter.MockitoSettings;
|
||||
import org.mockito.quality.Strictness;
|
||||
import org.openhab.binding.dwdunwetter.internal.DwdUnwetterBindingConstants;
|
||||
import org.openhab.binding.dwdunwetter.internal.handler.DwdUnwetterHandler;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
@@ -51,19 +54,17 @@ import org.w3c.dom.NodeList;
|
||||
*
|
||||
* @author Martin Koehler - Initial contribution
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
@MockitoSettings(strictness = Strictness.WARN)
|
||||
public class DwdUnwetterHandlerTest extends JavaTest {
|
||||
|
||||
private ThingHandler handler;
|
||||
|
||||
@Mock
|
||||
private ThingHandlerCallback callback;
|
||||
private @Mock ThingHandlerCallback callback;
|
||||
private @Mock Thing thing;
|
||||
|
||||
@Mock
|
||||
private Thing thing;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
initMocks(this);
|
||||
handler = new DwdUnwetterHandler(thing);
|
||||
handler.setCallback(callback);
|
||||
// mock getConfiguration to prevent NPEs
|
||||
|
||||
@@ -13,12 +13,12 @@
|
||||
package org.openhab.binding.dwdunwetter.internal.data;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Tests for {@link DwdWarningCache}
|
||||
@@ -29,7 +29,7 @@ public class DwdWarningCacheTest {
|
||||
|
||||
private DwdWarningCache cache;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
cache = new DwdWarningCache();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
package org.openhab.binding.dwdunwetter.internal.data;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
@@ -23,8 +23,8 @@ import java.io.StringWriter;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.ZoneId;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.core.library.types.DateTimeType;
|
||||
import org.openhab.core.library.types.OnOffType;
|
||||
import org.openhab.core.types.UnDefType;
|
||||
@@ -47,7 +47,7 @@ public class DwdWarningsDataTest {
|
||||
private TestDataProvider testDataProvider;
|
||||
private DwdWarningsData warningsData;
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() throws IOException {
|
||||
this.testDataProvider = new TestDataProvider();
|
||||
loadXmlFromFile();
|
||||
|
||||
Reference in New Issue
Block a user