Migrate tests to JUnit 5 (#8519)
Signed-off-by: Wouter Born <github@maindrain.net>
This commit is contained in:
@@ -12,12 +12,12 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ConditionHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
@@ -47,11 +47,11 @@ public class ConditionHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("Temperature", QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature());
|
||||
assertEquals("Humidity", QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity());
|
||||
assertEquals("Pressure", QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure());
|
||||
assertEquals("Pressure Sea", QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea());
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(22.7, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
|
||||
assertEquals(QuantityType.valueOf(61.0, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
|
||||
assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
|
||||
assertEquals(QuantityType.valueOf(-1, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -70,11 +70,11 @@ public class ConditionHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/condition-result-plus-pressure.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("Temperature", QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature());
|
||||
assertEquals("Humidity", QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity());
|
||||
assertEquals("Pressure", QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure());
|
||||
assertEquals("Pressure Sea", QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea());
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(21.5, SIUnits.CELSIUS), condHandler.getTemperature(), "Temperature");
|
||||
assertEquals(QuantityType.valueOf(58.5, SmartHomeUnits.PERCENT), condHandler.getHumidity(), "Humidity");
|
||||
assertEquals(QuantityType.valueOf(100200.0, SIUnits.PASCAL), condHandler.getPressure(), "Pressure");
|
||||
assertEquals(QuantityType.valueOf(101968.7, SIUnits.PASCAL), condHandler.getPressureSea(), "Pressure Sea");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -93,7 +93,7 @@ public class ConditionHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = condHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
|
||||
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class ConditionHandlerTest {
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
UpdateStatus result = condHandler.updateChannels("[]");
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
|
||||
assertEquals(UpdateStatus.VALUE_EMPTY, result, "Valid update");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -124,6 +124,6 @@ public class ConditionHandlerTest {
|
||||
|
||||
ConditionHandlerExtension condHandler = new ConditionHandlerExtension(t);
|
||||
UpdateStatus result = condHandler.updateChannels(null);
|
||||
assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
|
||||
assertEquals(UpdateStatus.CONNECTION_ERROR, result, "Valid update");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
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.luftdateninfo.internal.dto.SensorData;
|
||||
import org.openhab.binding.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
|
||||
@@ -39,7 +39,7 @@ public class DTOTest {
|
||||
Gson gson = new Gson();
|
||||
SensorData[] valueArray = gson.fromJson(result, SensorData[].class);
|
||||
// System.out.println(valueArray.length);
|
||||
assertEquals("Array size", 2, valueArray.length);
|
||||
assertEquals(2, valueArray.length, "Array size");
|
||||
|
||||
SensorData d = valueArray[0];
|
||||
// Assure latest data is taken
|
||||
@@ -52,9 +52,9 @@ public class DTOTest {
|
||||
assertNotNull(d);
|
||||
sensorDataVaueList.forEach(v -> {
|
||||
if (v.getValueType().equals(HTTPHandler.TEMPERATURE)) {
|
||||
assertEquals("Temperature", "22.70", v.getValue());
|
||||
assertEquals("22.70", v.getValue(), "Temperature");
|
||||
} else if (v.getValueType().equals(HTTPHandler.HUMIDITY)) {
|
||||
assertEquals("Humidity", "61.00", v.getValue());
|
||||
assertEquals("61.00", v.getValue(), "Humidity");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class DTOTest {
|
||||
Gson gson = new Gson();
|
||||
SensorData[] valueArray = gson.fromJson(result, SensorData[].class);
|
||||
// System.out.println(valueArray.length);
|
||||
assertEquals("Array size", 2, valueArray.length);
|
||||
assertEquals(2, valueArray.length, "Array size");
|
||||
|
||||
SensorData d = valueArray[0];
|
||||
// Assure latest data is taken
|
||||
|
||||
@@ -12,14 +12,14 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
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.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
@@ -37,7 +37,7 @@ public class HTTPHandlerEvalTest {
|
||||
private @Nullable List<SensorDataValue> noise;
|
||||
private HTTPHandler http = new HTTPHandler();
|
||||
|
||||
@Before
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
String conditionsStr = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
assertNotNull(conditionsStr);
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
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.luftdateninfo.internal.dto.SensorDataValue;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.HTTPHandler;
|
||||
import org.openhab.binding.luftdateninfo.internal.util.FileReader;
|
||||
@@ -57,9 +57,9 @@ public class HTTPHandlerValueTest {
|
||||
|
||||
private void testSensorValue(SensorDataValue s) {
|
||||
if (s.getValueType().equals(HTTPHandler.TEMPERATURE)) {
|
||||
assertEquals("Temperature resource 1", "22.70", s.getValue());
|
||||
assertEquals("22.70", s.getValue(), "Temperature resource 1");
|
||||
} else if (s.getValueType().equals(HTTPHandler.HUMIDITY)) {
|
||||
assertEquals("Humidity resource 1", "61.00", s.getValue());
|
||||
assertEquals("61.00", s.getValue(), "Humidity resource 1");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.NoiseHandlerExtension;
|
||||
import org.openhab.binding.luftdateninfo.internal.mock.ThingMock;
|
||||
@@ -46,13 +46,13 @@ public class NoiseHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = noiseHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("Noise EQ", QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseEQCache());
|
||||
assertEquals("Noise Min", QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMinCache());
|
||||
assertEquals("Noise Max", QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMaxCache());
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(51.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
|
||||
"Noise EQ");
|
||||
assertEquals(QuantityType.valueOf(47.2, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
|
||||
"Noise Min");
|
||||
assertEquals(QuantityType.valueOf(57.0, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
|
||||
"Noise Max");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -71,13 +71,13 @@ public class NoiseHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/condition-result-no-pressure.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = noiseHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseEQCache());
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMinCache());
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL),
|
||||
noiseHandler.getNoiseMaxCache());
|
||||
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseEQCache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMinCache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.DECIBEL), noiseHandler.getNoiseMaxCache(),
|
||||
"Values undefined");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -94,7 +94,7 @@ public class NoiseHandlerTest {
|
||||
|
||||
NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
|
||||
UpdateStatus result = noiseHandler.updateChannels("[]");
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
|
||||
assertEquals(UpdateStatus.VALUE_EMPTY, result, "Valid update");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -108,6 +108,6 @@ public class NoiseHandlerTest {
|
||||
|
||||
NoiseHandlerExtension noiseHandler = new NoiseHandlerExtension(t);
|
||||
UpdateStatus result = noiseHandler.updateChannels(null);
|
||||
assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
|
||||
assertEquals(UpdateStatus.CONNECTION_ERROR, result, "Valid update");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.NumberUtils;
|
||||
|
||||
/**
|
||||
@@ -30,32 +30,32 @@ public class NumberTest {
|
||||
public void testRoundingUp() {
|
||||
double d1 = 1.95;
|
||||
double d1r2 = NumberUtils.round(d1, 2);
|
||||
assertEquals("Double 1.95, 2 places ", "1.95", Double.toString(d1r2));
|
||||
assertEquals("1.95", Double.toString(d1r2), "Double 1.95, 2 places");
|
||||
// System.out.println("D1R2 " + d1r2);
|
||||
double d1r1 = NumberUtils.round(d1, 1);
|
||||
// System.out.println("D1R1 " + d1r1);
|
||||
assertEquals("Double 1.95, 1 place ", "2.0", Double.toString(d1r1));
|
||||
assertEquals("2.0", Double.toString(d1r1), "Double 1.95, 1 place");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRoundingDown() {
|
||||
double d1 = 1.94;
|
||||
double d1r2 = NumberUtils.round(d1, 2);
|
||||
assertEquals("Double 1.94, 2 places ", "1.94", Double.toString(d1r2));
|
||||
assertEquals("1.94", Double.toString(d1r2), "Double 1.94, 2 places");
|
||||
// System.out.println("D1R2 " + d1r2);
|
||||
double d1r1 = NumberUtils.round(d1, 1);
|
||||
// System.out.println("D1R1 " + d1r1);
|
||||
assertEquals("Double 1.94, 1 place ", "1.9", Double.toString(d1r1));
|
||||
assertEquals("1.9", Double.toString(d1r1), "Double 1.94, 1 place");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStringNumbers() {
|
||||
String d1 = "1.94";
|
||||
double d1r2 = NumberUtils.round(d1, 2);
|
||||
assertEquals("Double 1.94, 2 places ", "1.94", Double.toString(d1r2));
|
||||
assertEquals("1.94", Double.toString(d1r2), "Double 1.94, 2 places");
|
||||
// System.out.println("D1R2 " + d1r2);
|
||||
double d1r1 = NumberUtils.round(d1, 1);
|
||||
// System.out.println("D1R1 " + d1r1);
|
||||
assertEquals("Double 1.94, 1 place ", "1.9", Double.toString(d1r1));
|
||||
assertEquals("1.9", Double.toString(d1r1), "Double 1.94, 1 place");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.ConfigStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.LifecycleStatus;
|
||||
import org.openhab.binding.luftdateninfo.internal.handler.BaseSensorHandler.UpdateStatus;
|
||||
@@ -64,7 +64,7 @@ public class PMHandlerTest {
|
||||
* Test if config status is 0 = CONFIG_OK for valid configuration. Take real int for comparison instead of
|
||||
* BaseHandler constants - in case of change test needs to be adapted
|
||||
*/
|
||||
assertEquals("Handler Configuration status", ConfigStatus.OK, pmHandler.getConfigStatus());
|
||||
assertEquals(ConfigStatus.OK, pmHandler.getConfigStatus(), "Handler Configuration status");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -93,7 +93,7 @@ public class PMHandlerTest {
|
||||
* Test if config status is 3 = CONFIG_SENSOR_NUMBER for invalid configuration with non-number sensorid. Take
|
||||
* real int for comparison instead of BaseHandler constants - in case of change test needs to be adapted
|
||||
*/
|
||||
assertEquals("Handler Configuration status", ConfigStatus.SENSOR_ID_NEGATIVE, pmHandler.getConfigStatus());
|
||||
assertEquals(ConfigStatus.SENSOR_ID_NEGATIVE, pmHandler.getConfigStatus(), "Handler Configuration status");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -110,11 +110,11 @@ public class PMHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/pm-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = pmHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.OK, result);
|
||||
assertEquals("PM25", QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM25Cache());
|
||||
assertEquals("PM100", QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM100Cache());
|
||||
assertEquals(UpdateStatus.OK, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(2.9, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
|
||||
"PM25");
|
||||
assertEquals(QuantityType.valueOf(5.2, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
|
||||
"PM100");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -133,11 +133,11 @@ public class PMHandlerTest {
|
||||
String pmJson = FileReader.readFileInString("src/test/resources/noise-result.json");
|
||||
if (pmJson != null) {
|
||||
UpdateStatus result = pmHandler.updateChannels(pmJson);
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_ERROR, result);
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM25Cache());
|
||||
assertEquals("Values undefined", QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE),
|
||||
pmHandler.getPM100Cache());
|
||||
assertEquals(UpdateStatus.VALUE_ERROR, result, "Valid update");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM25Cache(),
|
||||
"Values undefined");
|
||||
assertEquals(QuantityType.valueOf(-1, SmartHomeUnits.MICROGRAM_PER_CUBICMETRE), pmHandler.getPM100Cache(),
|
||||
"Values undefined");
|
||||
} else {
|
||||
assertTrue(false);
|
||||
}
|
||||
@@ -154,7 +154,7 @@ public class PMHandlerTest {
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
UpdateStatus result = pmHandler.updateChannels("[]");
|
||||
assertEquals("Valid update", UpdateStatus.VALUE_EMPTY, result);
|
||||
assertEquals(UpdateStatus.VALUE_EMPTY, result, "Valid update");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -168,6 +168,6 @@ public class PMHandlerTest {
|
||||
|
||||
PMHandlerExtension pmHandler = new PMHandlerExtension(t);
|
||||
UpdateStatus result = pmHandler.updateChannels(null);
|
||||
assertEquals("Valid update", UpdateStatus.CONNECTION_ERROR, result);
|
||||
assertEquals(UpdateStatus.CONNECTION_ERROR, result, "Valid update");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,13 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.util;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeParseException;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.junit.Test;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.openhab.binding.luftdateninfo.internal.utils.DateTimeUtils;
|
||||
|
||||
/**
|
||||
@@ -34,12 +34,12 @@ public class DateTimeTest {
|
||||
String jsonDateString = "2020-08-14 14:53:21";
|
||||
try {
|
||||
LocalDateTime dt = LocalDateTime.from(DateTimeUtils.DTF.parse(jsonDateString));
|
||||
assertEquals("Day ", 14, dt.getDayOfMonth());
|
||||
assertEquals("Month ", 8, dt.getMonthValue());
|
||||
assertEquals("Year ", 2020, dt.getYear());
|
||||
assertEquals(14, dt.getDayOfMonth(), "Day");
|
||||
assertEquals(8, dt.getMonthValue(), "Month");
|
||||
assertEquals(2020, dt.getYear(), "Year");
|
||||
|
||||
String s = dt.format(DateTimeUtils.DTF);
|
||||
assertEquals("String ", jsonDateString, s);
|
||||
assertEquals(jsonDateString, s, "String");
|
||||
} catch (DateTimeParseException e) {
|
||||
assertFalse(true);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
package org.openhab.binding.luftdateninfo.internal.util;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
Reference in New Issue
Block a user