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.yamahareceiver.internal.protocol.xml;
15 import static org.junit.jupiter.api.Assertions.*;
16 import static org.openhab.binding.yamahareceiver.internal.YamahaReceiverBindingConstants.Inputs.*;
17 import static org.openhab.binding.yamahareceiver.internal.protocol.xml.XMLConstants.Commands.ZONE_INPUT_QUERY;
19 import org.junit.jupiter.api.Test;
22 * Unit test for {@link InputConverterXML}.
24 * @author Tomasz Maruszak - Initial contribution
26 public class InputConverterXMLTest extends AbstractXMLProtocolTest {
28 private InputConverterXML subject;
31 protected void onSetUp() throws Exception {
34 ctx.prepareForModel("HTR-4069");
35 ctx.respondWith(String.format("<Main_Zone>%s</Main_Zone>", ZONE_INPUT_QUERY),
36 "Main_Zone_Input_Input_Sel_Item.xml");
40 public void when_noMapping_fromStateName_returnsCanonicalNames() {
42 subject = new InputConverterXML(con, "");
45 String hdmi1 = subject.fromStateName("HDMI1");
46 String hdmi2 = subject.fromStateName("HDMI2");
47 String av1 = subject.fromStateName("AV1");
48 String av2 = subject.fromStateName("AV2");
49 String audio1 = subject.fromStateName("AUDIO1");
50 String audio2 = subject.fromStateName("AUDIO2");
51 String bluetooth = subject.fromStateName(INPUT_BLUETOOTH);
52 String usb = subject.fromStateName(INPUT_USB);
53 String tuner = subject.fromStateName(INPUT_TUNER);
54 String netRadio = subject.fromStateName(INPUT_NET_RADIO);
55 String server = subject.fromStateName(INPUT_SERVER);
56 String multiCastLink = subject.fromStateName(INPUT_MUSIC_CAST_LINK);
57 String spotify = subject.fromStateName(INPUT_SPOTIFY);
60 assertEquals("HDMI1", hdmi1);
61 assertEquals("HDMI2", hdmi2);
62 assertEquals("AV1", av1);
63 assertEquals("AV2", av2);
64 assertEquals("AUDIO1", audio1);
65 assertEquals("AUDIO2", audio2);
66 assertEquals("Bluetooth", bluetooth);
67 assertEquals("USB", usb);
68 assertEquals("TUNER", tuner);
69 assertEquals("NET RADIO", netRadio);
70 assertEquals("SERVER", server);
71 assertEquals("MusicCast Link", multiCastLink);
72 assertEquals("Spotify", spotify);
76 public void when_mapping_fromStateName_takesUserMappingAboveAll() {
78 subject = new InputConverterXML(con, "HDMI1=HDMI 1,Bluetooth=BLUETOOTH");
81 String hdmi1 = subject.fromStateName("HDMI1");
82 String bluetooth = subject.fromStateName(INPUT_BLUETOOTH);
85 assertEquals("HDMI 1", hdmi1);
86 assertEquals("BLUETOOTH", bluetooth);