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.vdr.internal;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.binding.vdr.internal.svdrp.SVDRPChannel;
20 import org.openhab.binding.vdr.internal.svdrp.SVDRPDiskStatus;
21 import org.openhab.binding.vdr.internal.svdrp.SVDRPException;
22 import org.openhab.binding.vdr.internal.svdrp.SVDRPParseResponseException;
25 * Specific unit tests to check if {@link SVDRPDiskStatus} parses SVDRP responses correctly
27 * @author Matthias Klocke - Initial contribution
31 public class SVDRPDiskStatusTest {
33 private final String diskStatusResponseOk = "411266MB 30092MB 92%";
34 private final String diskStatusResponseParseError1 = "411266MB 30092MB 92%";
35 private final String diskStatusResponseParseError2 = "411266MB 30092 92%";
36 private final String diskStatusResponseParseError3 = "42b3MB 30092MB 92%";
39 public void testParseDiskStatus() throws SVDRPException {
40 SVDRPDiskStatus diskStatus = SVDRPDiskStatus.parse(diskStatusResponseOk);
41 assertEquals(411266, diskStatus.getMegaBytesTotal());
42 assertEquals(30092, diskStatus.getMegaBytesFree());
43 assertEquals(92, diskStatus.getPercentUsed());
47 public void testParseExceptionDiskStatus() {
48 assertThrows(SVDRPParseResponseException.class, () -> {
49 SVDRPChannel.parse(diskStatusResponseParseError1);
51 assertThrows(SVDRPParseResponseException.class, () -> {
52 SVDRPChannel.parse(diskStatusResponseParseError2);
54 assertThrows(SVDRPParseResponseException.class, () -> {
55 SVDRPChannel.parse(diskStatusResponseParseError3);