2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.modbus.internal;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
23 * @author Jimmy Tanagra - Initial contribution
26 public class ModbusTransformationTest {
28 public void testTransformationEmpty() {
29 ModbusTransformation transformation = new ModbusTransformation(List.of(""));
30 assertFalse(transformation.isIdentityTransform());
31 assertEquals("", transformation.transform("xx"));
35 public void testTransformationNull() {
36 ModbusTransformation transformation = new ModbusTransformation(null);
37 assertFalse(transformation.isIdentityTransform());
38 assertEquals("", transformation.transform("xx"));
42 public void testTransformationDefault() {
43 ModbusTransformation transformation = new ModbusTransformation(List.of("deFault"));
44 assertTrue(transformation.isIdentityTransform());
45 assertEquals("xx", transformation.transform("xx"));
49 public void testTransformationConstant() {
50 ModbusTransformation transformation = new ModbusTransformation(List.of("constant"));
51 assertFalse(transformation.isIdentityTransform());
52 assertEquals("constant", transformation.transform("xx"));