]> git.basschouten.com Git - openhab-addons.git/blob
20591cf5e76655f85fbb1f5fd848f7acef377f5c
[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.vdr.internal;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
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.SVDRPException;
21 import org.openhab.binding.vdr.internal.svdrp.SVDRPParseResponseException;
22
23 /**
24  * Specific unit tests to check if {@link SVDRPChannel} parses SVDRP responses correctly
25  *
26  * @author Matthias Klocke - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class SVDRPChannelTest {
31
32     private final String channelResponseOk = "3 WDR HD Bielefeld";
33     private final String channelResponseParseError = "250WDR HD Bielefeld";
34
35     @Test
36     public void testParseChannelData() throws SVDRPException {
37         SVDRPChannel channel = SVDRPChannel.parse(channelResponseOk);
38         assertEquals("WDR HD Bielefeld", channel.getName());
39         assertEquals(3, channel.getNumber());
40     }
41
42     @Test
43     public void testParseExceptionChannelData() {
44         assertThrows(SVDRPParseResponseException.class, () -> {
45             SVDRPChannel.parse(channelResponseParseError);
46         });
47     }
48 }