Migrate tests to JUnit 5 (#8519)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@@ -12,16 +12,13 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.dto;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.sensibo.internal.dto.poddetails.AcStateDTO;
|
||||
import org.openhab.binding.sensibo.internal.dto.poddetails.MeasurementDTO;
|
||||
import org.openhab.binding.sensibo.internal.dto.poddetails.ModeCapabilityDTO;
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.dto;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.sensibo.internal.dto.pods.PodDTO;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.dto;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.sensibo.internal.dto.setacstateproperty.SetAcStatePropertyRequest;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,11 +12,11 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.dto;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.sensibo.internal.dto.setacstateproperty.SetAcStatePropertyReponse;
|
||||
|
||||
/**
|
||||
|
||||
@@ -12,13 +12,11 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.dto;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.sensibo.internal.dto.poddetails.AcStateDTO;
|
||||
import org.openhab.binding.sensibo.internal.dto.settimer.SetTimerRequest;
|
||||
|
||||
|
||||
@@ -12,11 +12,8 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.handler;
|
||||
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.get;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static com.github.tomakehurst.wiremock.client.WireMock.*;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@@ -25,44 +22,49 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.eclipse.jetty.client.HttpClient;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.openhab.binding.sensibo.internal.config.SensiboAccountConfiguration;
|
||||
import org.openhab.binding.sensibo.internal.model.SensiboSky;
|
||||
import org.openhab.core.config.core.Configuration;
|
||||
import org.openhab.core.thing.Bridge;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
|
||||
import com.github.tomakehurst.wiremock.WireMockServer;
|
||||
import com.github.tomakehurst.wiremock.client.WireMock;
|
||||
import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
||||
import com.github.tomakehurst.wiremock.junit.WireMockRule;
|
||||
|
||||
/**
|
||||
* @author Arne Seime - Initial contribution
|
||||
*/
|
||||
@ExtendWith(MockitoExtension.class)
|
||||
public class SensiboAccountHandlerTest {
|
||||
@Rule
|
||||
public WireMockRule wireMockRule = new WireMockRule(WireMockConfiguration.options().dynamicPort());
|
||||
|
||||
@Mock
|
||||
private Bridge sensiboAccountMock;
|
||||
private WireMockServer wireMockServer;
|
||||
|
||||
private HttpClient httpClient;
|
||||
@Mock
|
||||
private Configuration configuration;
|
||||
|
||||
@Before
|
||||
private @Mock Configuration configuration;
|
||||
private @Mock Bridge sensiboAccountMock;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() throws Exception {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
wireMockServer = new WireMockServer(WireMockConfiguration.options().dynamicPort());
|
||||
wireMockServer.start();
|
||||
|
||||
int port = wireMockServer.port();
|
||||
WireMock.configureFor("localhost", port);
|
||||
|
||||
httpClient = new HttpClient();
|
||||
httpClient.start();
|
||||
SensiboAccountHandler.API_ENDPOINT = "http://localhost:" + wireMockRule.port() + "/api"; // https://home.sensibo.com/api/v2
|
||||
|
||||
SensiboAccountHandler.API_ENDPOINT = "http://localhost:" + port + "/api"; // https://home.sensibo.com/api/v2
|
||||
}
|
||||
|
||||
@After
|
||||
@AfterEach
|
||||
public void shutdown() throws Exception {
|
||||
httpClient.stop();
|
||||
}
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
*/
|
||||
package org.openhab.binding.sensibo.internal.handler;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.Mockito;
|
||||
|
||||
Reference in New Issue
Block a user