]> git.basschouten.com Git - openhab-addons.git/blob
141ccdac18c893d7ff2d84bddd280143f84764ea
[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.yamahareceiver.internal.protocol.xml;
14
15 import static org.junit.jupiter.api.Assertions.assertTrue;
16 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Feature.*;
17 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Zone.*;
18
19 import java.io.IOException;
20 import java.util.Arrays;
21
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.yamahareceiver.internal.protocol.ReceivedMessageParseException;
24 import org.openhab.binding.yamahareceiver.internal.state.DeviceInformationState;
25
26 /**
27  * Unit test for {@link DeviceInformationXML}.
28  *
29  * @author Tomasz Maruszak - Initial contribution
30  */
31 public class DeviceInformationXMLTest extends AbstractXMLProtocolTest {
32
33     private DeviceInformationState state;
34
35     private DeviceInformationXML subject;
36
37     @Override
38     public void onSetUp() {
39         state = new DeviceInformationState();
40         subject = new DeviceInformationXML(con, state);
41     }
42
43     @Test
44     public void when_HTR4069_then_detects_featureZoneB_and_addsZone2()
45             throws IOException, ReceivedMessageParseException {
46         // arrange
47         ctx.prepareForModel("HTR-4069");
48
49         // act
50         subject.update();
51
52         // assert
53         assertTrue(state.features.contains(ZONE_B), "ZONE_B detected");
54         assertTrue(state.zones.contains(Zone_2), "Zone_2 added");
55     }
56
57     @Test
58     public void when_RXV3900_then_detects_features_and_zones_from_descriptor()
59             throws IOException, ReceivedMessageParseException {
60         // arrange
61         ctx.prepareForModel("RX-V3900");
62
63         // act
64         subject.update();
65
66         // assert
67         assertTrue(state.zones.containsAll(Arrays.asList(Main_Zone, Zone_2, Zone_3)), "Zones detected");
68         assertTrue(state.features.containsAll(Arrays.asList(TUNER, BLUETOOTH)), "Features detected");
69     }
70 }