]> git.basschouten.com Git - openhab-addons.git/blob
30480e39e7ec78f9f79e6efca9ecb7835ccbbd04
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.modbus.internal;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.util.List;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21
22 /**
23  * @author Jimmy Tanagra - Initial contribution
24  */
25 @NonNullByDefault
26 public class ModbusTransformationTest {
27     @Test
28     public void testTransformationEmpty() {
29         ModbusTransformation transformation = new ModbusTransformation(List.of(""));
30         assertFalse(transformation.isIdentityTransform());
31         assertEquals("", transformation.transform("xx"));
32     }
33
34     @Test
35     public void testTransformationNull() {
36         ModbusTransformation transformation = new ModbusTransformation(null);
37         assertFalse(transformation.isIdentityTransform());
38         assertEquals("", transformation.transform("xx"));
39     }
40
41     @Test
42     public void testTransformationDefault() {
43         ModbusTransformation transformation = new ModbusTransformation(List.of("deFault"));
44         assertTrue(transformation.isIdentityTransform());
45         assertEquals("xx", transformation.transform("xx"));
46     }
47
48     @Test
49     public void testTransformationConstant() {
50         ModbusTransformation transformation = new ModbusTransformation(List.of("constant"));
51         assertFalse(transformation.isIdentityTransform());
52         assertEquals("constant", transformation.transform("xx"));
53     }
54 }