package org.openhab.transform.scale.internal;
import static org.junit.jupiter.api.Assertions.*;
-import static org.mockito.ArgumentMatchers.anyString;
-import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.*;
import java.io.File;
import java.io.IOException;
@Test
public void testTransformByScale() throws TransformationException {
// need to be sure we'll have the german version
- String existingscale = "scale/humidex_de.scale";
+ String existingscale = "scale" + File.separator + "humidex_de.scale";
String source = "10";
String transformedResponse = processor.transform(existingscale, source);
assertEquals("nicht wesentlich", transformedResponse);
- existingscale = "scale/limits.scale";
+ existingscale = "scale" + File.separator + "limits.scale";
source = "10";
transformedResponse = processor.transform(existingscale, source);
assertEquals("middle", transformedResponse);
@Test
public void testTransformByScaleLimits() throws TransformationException {
- String existingscale = "scale/limits.scale";
+ String existingscale = "scale" + File.separator + "limits.scale";
// Testing upper bound opened range
String source = "500";
assertEquals("low", transformedResponse);
// Testing unfinite up and down range
- existingscale = "scale/catchall.scale";
+ existingscale = "scale" + File.separator + "catchall.scale";
source = "-10";
transformedResponse = processor.transform(existingscale, source);
assertEquals("catchall", transformedResponse);
public void testTransformByScaleUndef() throws TransformationException {
// check that for undefined/non numeric value we return empty string
// Issue #1107
- String existingscale = "scale/humidex_fr.scale";
+ String existingscale = "scale" + File.separator + "humidex_fr.scale";
String source = "-";
assertThrows(TransformationException.class, () -> processor.transform(existingscale, source));
}
public void testTransformByScaleErrorInBounds() throws TransformationException {
// the tested file contains inputs that generate a conversion error of the bounds
// of range
- String existingscale = "scale/erroneous.scale";
+ String existingscale = "scale" + File.separator + "erroneous.scale";
String source = "15";
try {
@SuppressWarnings("unused")
@Test
public void testTransformByScaleErrorInValue() throws TransformationException {
// checks that an error is raised when trying to scale an erroneous value
- String existingscale = "scale/evaluationorder.scale";
+ String existingscale = "scale" + File.separator + "evaluationorder.scale";
String source = "azerty";
assertThrows(TransformationException.class, () -> processor.transform(existingscale, source));
}
@Test
public void testEvaluationOrder() throws TransformationException {
// Ensures that only first matching scale as presented in the file is taken in account
- String evaluationOrder = "scale/evaluationorder.scale";
+ String evaluationOrder = "scale" + File.separator + "evaluationorder.scale";
// This value matches two lines of the scale file
String source = "12";
@Test
public void testTransformQuantityType() throws TransformationException {
QuantityType<Dimensionless> airQuality = new QuantityType<>("992 ppm");
- String aqScaleFile = "scale/netatmo_aq.scale";
+ String aqScaleFile = "scale" + File.separator + "netatmo_aq.scale";
String expected = "Correcte (992 ppm) !";
String transformedResponse = processor.transform(aqScaleFile, airQuality.toString());
@Test
public void testCatchNonNumericValue() throws TransformationException {
// checks that an error is raised when trying to scale an erroneous value
- String existingscale = "scale/catchnonnumeric.scale";
+ String existingscale = "scale" + File.separator + "catchnonnumeric.scale";
String source = "azerty";
String transformedResponse = processor.transform(existingscale, source);
assertEquals("Non Numeric", transformedResponse);
@Test
public void testTransformAndFormat() throws TransformationException {
- String existingscale = "scale/netatmo_aq.scale";
+ String existingscale = "scale" + File.separator + "netatmo_aq.scale";
String source = "992";
String transformedResponse = processor.transform(existingscale, source);
assertEquals("Correcte (992) !", transformedResponse);
@Test
public void testValueExceedsRange() throws TransformationException {
- String existingscale = "scale/humidex.scale";
+ String existingscale = "scale" + File.separator + "humidex.scale";
String source = "200";
assertThrows(TransformationException.class, () -> processor.transform(existingscale, source));
}