2 * Copyright (c) 2010-2023 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.omnikinverter.internal.test;
15 import static org.junit.jupiter.api.Assertions.*;
18 import java.io.IOException;
19 import java.nio.file.Files;
21 import org.junit.jupiter.api.BeforeEach;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.omnikinverter.internal.OmnikInverterMessage;
26 * @author Hans van den Bogert - Initial contribution
28 public class OmnikInverterMessageTest {
30 private OmnikInverterMessage message;
33 public void setUp() throws IOException {
34 File file = new File("src/test/resources/omnik.output");
35 message = new OmnikInverterMessage(Files.readAllBytes(file.toPath()));
39 public void testGetPower() {
40 assertEquals(137.0, message.getPower(), 0.01);
44 public void testGetPowerAC1() {
45 assertEquals(137.0, message.getPowerAC1(), 0.01);
49 public void testGetPowerAC2() {
50 assertEquals(-1.0, message.getPowerAC2(), 0.01);
54 public void testGetPowerAC3() {
55 assertEquals(-1.0, message.getPowerAC3(), 0.01);
59 public void testGetCurrentPV1() {
60 assertEquals(0.5, message.getCurrentPV1(), 0.01);
64 public void testGetCurrentPV2() {
65 assertEquals(0.6, message.getCurrentPV2(), 0.01);
69 public void testGetCurrentPV3() {
70 assertEquals(-0.1, message.getCurrentPV3(), 0.01);
74 public void testGetVoltagePV1() {
75 assertEquals(160.0, message.getVoltagePV1(), 0.01);
79 public void testGetVoltagePV2() {
80 assertEquals(131.9, message.getVoltagePV2(), 0.01);
84 public void testGetVoltagePV3() {
85 assertEquals(-0.1, message.getVoltagePV3(), 0.01);
89 public void testGetTotalEnergy() {
90 assertEquals(12412.7, message.getTotalEnergy(), 0.01);
94 public void testGetEnergyToday() {
95 assertEquals(11.13, message.getEnergyToday(), 0.01);