]> git.basschouten.com Git - openhab-addons.git/blob
7446fad3a9518bd40fee2a53680b7b678d02313e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.omnikinverter.internal.test;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import java.io.File;
18 import java.io.IOException;
19 import java.nio.file.Files;
20
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.omnikinverter.internal.OmnikInverterMessage;
24
25 /**
26  * @author Hans van den Bogert - Initial contribution
27  */
28 public class OmnikInverterMessageTest {
29
30     private OmnikInverterMessage message;
31
32     @BeforeEach
33     public void setUp() throws IOException {
34         File file = new File("src/test/resources/omnik.output");
35         message = new OmnikInverterMessage(Files.readAllBytes(file.toPath()));
36     }
37
38     @Test
39     public void testGetPower() {
40         assertEquals(137.0, message.getPower(), 0.01);
41     }
42
43     @Test
44     public void testGetPowerAC1() {
45         assertEquals(137.0, message.getPowerAC1(), 0.01);
46     }
47
48     @Test
49     public void testGetPowerAC2() {
50         assertEquals(-1.0, message.getPowerAC2(), 0.01);
51     }
52
53     @Test
54     public void testGetPowerAC3() {
55         assertEquals(-1.0, message.getPowerAC3(), 0.01);
56     }
57
58     @Test
59     public void testGetVoltageAC1() {
60         assertEquals(236.0, message.getVoltageAC1(), 0.01);
61     }
62
63     @Test
64     public void testGetVoltageAC2() {
65         assertEquals(-0.1, message.getVoltageAC2(), 0.01);
66     }
67
68     @Test
69     public void testGetVoltageAC3() {
70         assertEquals(-0.1, message.getVoltageAC3(), 0.01);
71     }
72
73     @Test
74     public void testGetCurrentAC1() {
75         assertEquals(0.5, message.getCurrentAC1(), 0.01);
76     }
77
78     @Test
79     public void testGetCurrentAC2() {
80         assertEquals(-0.1, message.getCurrentAC2(), 0.01);
81     }
82
83     @Test
84     public void testGetCurrentAC3() {
85         assertEquals(-0.1, message.getCurrentAC3(), 0.01);
86     }
87
88     @Test
89     public void testGetFrequencyAC1() {
90         assertEquals(50.06, message.getFrequencyAC1(), 0.01);
91     }
92
93     @Test
94     public void testGetFrequencyAC2() {
95         assertEquals(-0.01, message.getFrequencyAC2(), 0.01);
96     }
97
98     @Test
99     public void testGetFrequencyAC3() {
100         assertEquals(-0.01, message.getFrequencyAC3(), 0.01);
101     }
102
103     @Test
104     public void testGetCurrentPV1() {
105         assertEquals(0.5, message.getCurrentPV1(), 0.01);
106     }
107
108     @Test
109     public void testGetCurrentPV2() {
110         assertEquals(0.6, message.getCurrentPV2(), 0.01);
111     }
112
113     @Test
114     public void testGetCurrentPV3() {
115         assertEquals(-0.1, message.getCurrentPV3(), 0.01);
116     }
117
118     @Test
119     public void testGetVoltagePV1() {
120         assertEquals(160.0, message.getVoltagePV1(), 0.01);
121     }
122
123     @Test
124     public void testGetVoltagePV2() {
125         assertEquals(131.9, message.getVoltagePV2(), 0.01);
126     }
127
128     @Test
129     public void testGetVoltagePV3() {
130         assertEquals(-0.1, message.getVoltagePV3(), 0.01);
131     }
132
133     @Test
134     public void testGetTotalEnergy() {
135         assertEquals(12412.7, message.getTotalEnergy(), 0.01);
136     }
137
138     @Test
139     public void testGetEnergyToday() {
140         assertEquals(11.13, message.getEnergyToday(), 0.01);
141     }
142
143     @Test
144     public void testGetTemperature() {
145         assertEquals(31.7, message.getTemperature(), 0.01);
146     }
147
148     @Test
149     public void testGetHoursTotal() {
150         assertEquals(17693, message.getHoursTotal(), 0.01);
151     }
152 }