]> git.basschouten.com Git - openhab-addons.git/blob
0e6acdd6f904e959fac64b1c23cd556dcdb7ecd9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.heos.internal.json.dto;
14
15 import static org.junit.Assert.assertEquals;
16 import static org.junit.Assert.assertNotNull;
17 import static org.openhab.binding.heos.internal.json.dto.HeosCommand.*;
18 import static org.openhab.binding.heos.internal.json.dto.HeosCommandGroup.SYSTEM;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.Test;
22
23 /**
24  * Tests to validate the functioning of the HeosCommandTuple
25  *
26  * @author Martin van Wingerden - Initial Contribution
27  */
28 @NonNullByDefault
29 public class HeosCommandTupleTest {
30     @Test
31     public void system() {
32         assertMatches("system/check_account", SYSTEM, CHECK_ACCOUNT);
33         assertMatches("system/sign_in", SYSTEM, SIGN_IN);
34         assertMatches("system/sign_out", SYSTEM, SIGN_OUT);
35         assertMatches("system/register_for_change_events", SYSTEM, REGISTER_FOR_CHANGE_EVENTS);
36         assertMatches("system/heart_beat", SYSTEM, HEART_BEAT);
37         assertMatches("system/prettify_json_response", SYSTEM, PRETTIFY_JSON_RESPONSE);
38     }
39
40     @Test
41     public void browse() {
42         assertMatches("browse/browse", HeosCommandGroup.BROWSE, HeosCommand.BROWSE);
43         assertMatches("browse/get_music_sources", HeosCommandGroup.BROWSE, HeosCommand.GET_MUSIC_SOURCES);
44         assertMatches("browse/get_source_info", HeosCommandGroup.BROWSE, HeosCommand.GET_SOURCE_INFO);
45         assertMatches("browse/get_search_criteria", HeosCommandGroup.BROWSE, HeosCommand.GET_SEARCH_CRITERIA);
46         assertMatches("browse/search", HeosCommandGroup.BROWSE, HeosCommand.SEARCH);
47         assertMatches("browse/play_stream", HeosCommandGroup.BROWSE, HeosCommand.PLAY_STREAM);
48         assertMatches("browse/play_preset", HeosCommandGroup.BROWSE, HeosCommand.PLAY_PRESET);
49         assertMatches("browse/play_input", HeosCommandGroup.BROWSE, HeosCommand.PLAY_INPUT);
50         assertMatches("browse/play_stream", HeosCommandGroup.BROWSE, HeosCommand.PLAY_STREAM);
51         assertMatches("browse/add_to_queue", HeosCommandGroup.BROWSE, HeosCommand.ADD_TO_QUEUE);
52         assertMatches("browse/rename_playlist", HeosCommandGroup.BROWSE, HeosCommand.RENAME_PLAYLIST);
53         assertMatches("browse/delete_playlist", HeosCommandGroup.BROWSE, HeosCommand.DELETE_PLAYLIST);
54         assertMatches("browse/retrieve_metadata", HeosCommandGroup.BROWSE, HeosCommand.RETRIEVE_METADATA);
55     }
56
57     @Test
58     public void player() {
59         assertMatches("player/get_players", HeosCommandGroup.PLAYER, HeosCommand.GET_PLAYERS);
60         assertMatches("player/get_player_info", HeosCommandGroup.PLAYER, HeosCommand.GET_PLAYER_INFO);
61         assertMatches("player/get_play_state", HeosCommandGroup.PLAYER, HeosCommand.GET_PLAY_STATE);
62         assertMatches("player/set_play_state", HeosCommandGroup.PLAYER, HeosCommand.SET_PLAY_STATE);
63         assertMatches("player/get_now_playing_media", HeosCommandGroup.PLAYER, HeosCommand.GET_NOW_PLAYING_MEDIA);
64         assertMatches("player/get_volume", HeosCommandGroup.PLAYER, HeosCommand.GET_VOLUME);
65         assertMatches("player/set_volume", HeosCommandGroup.PLAYER, HeosCommand.SET_VOLUME);
66         assertMatches("player/volume_up", HeosCommandGroup.PLAYER, HeosCommand.VOLUME_UP);
67         assertMatches("player/volume_down", HeosCommandGroup.PLAYER, HeosCommand.VOLUME_DOWN);
68         assertMatches("player/get_mute", HeosCommandGroup.PLAYER, HeosCommand.GET_MUTE);
69         assertMatches("player/set_mute", HeosCommandGroup.PLAYER, HeosCommand.SET_MUTE);
70         assertMatches("player/toggle_mute", HeosCommandGroup.PLAYER, HeosCommand.TOGGLE_MUTE);
71         assertMatches("player/get_play_mode", HeosCommandGroup.PLAYER, HeosCommand.GET_PLAY_MODE);
72         assertMatches("player/set_play_mode", HeosCommandGroup.PLAYER, HeosCommand.SET_PLAY_MODE);
73         assertMatches("player/get_queue", HeosCommandGroup.PLAYER, HeosCommand.GET_QUEUE);
74         assertMatches("player/play_queue", HeosCommandGroup.PLAYER, HeosCommand.PLAY_QUEUE);
75         assertMatches("player/remove_from_queue", HeosCommandGroup.PLAYER, HeosCommand.REMOVE_FROM_QUEUE);
76         assertMatches("player/save_queue", HeosCommandGroup.PLAYER, HeosCommand.SAVE_QUEUE);
77         assertMatches("player/clear_queue", HeosCommandGroup.PLAYER, HeosCommand.CLEAR_QUEUE);
78         assertMatches("player/move_queue_item", HeosCommandGroup.PLAYER, HeosCommand.MOVE_QUEUE_ITEM);
79         assertMatches("player/play_next", HeosCommandGroup.PLAYER, HeosCommand.PLAY_NEXT);
80         assertMatches("player/play_previous", HeosCommandGroup.PLAYER, HeosCommand.PLAY_PREVIOUS);
81         assertMatches("player/set_quickselect", HeosCommandGroup.PLAYER, HeosCommand.SET_QUICKSELECT);
82         assertMatches("player/play_quickselect", HeosCommandGroup.PLAYER, HeosCommand.PLAY_QUICKSELECT);
83         assertMatches("player/get_quickselects", HeosCommandGroup.PLAYER, HeosCommand.GET_QUICKSELECTS);
84         assertMatches("player/check_update", HeosCommandGroup.PLAYER, HeosCommand.CHECK_UPDATE);
85     }
86
87     @Test
88     public void group() {
89         assertMatches("group/get_groups", HeosCommandGroup.GROUP, HeosCommand.GET_GROUPS);
90         assertMatches("group/get_group_info", HeosCommandGroup.GROUP, HeosCommand.GET_GROUP_INFO);
91         assertMatches("group/set_group", HeosCommandGroup.GROUP, HeosCommand.SET_GROUP);
92         assertMatches("group/get_volume", HeosCommandGroup.GROUP, HeosCommand.GET_VOLUME);
93         assertMatches("group/set_volume", HeosCommandGroup.GROUP, HeosCommand.SET_VOLUME);
94         assertMatches("group/volume_up", HeosCommandGroup.GROUP, HeosCommand.VOLUME_UP);
95         assertMatches("group/volume_down", HeosCommandGroup.GROUP, HeosCommand.VOLUME_DOWN);
96         assertMatches("group/get_mute", HeosCommandGroup.GROUP, HeosCommand.GET_MUTE);
97         assertMatches("group/set_mute", HeosCommandGroup.GROUP, HeosCommand.SET_MUTE);
98         assertMatches("group/toggle_mute", HeosCommandGroup.GROUP, HeosCommand.TOGGLE_MUTE);
99     }
100
101     private void assertMatches(String command, HeosCommandGroup commandGroup, HeosCommand heosCommand) {
102         HeosCommandTuple tuple = HeosCommandTuple.valueOf(command);
103
104         assertNotNull(tuple);
105         assertEquals(commandGroup, tuple.commandGroup);
106         assertEquals(heosCommand, tuple.command);
107     }
108
109     /**
110      * "browse/browse"
111      * "group/get_groups"
112      * "player/get_mute"
113      * "player/get_now_playing_media"
114      * "player/get_player_info"
115      * "player/get_players"
116      * "player/get_play_mode"
117      * "player/get_play_state"
118      * "player/get_volume"
119      * "player/play_next"
120      * "player/play_previous"
121      * "player/set_mute"
122      * "player/set_play_mode"
123      * "player/set_play_state"
124      * "player/set_volume"
125      * "player/volume_down"
126      * "system/heart_beat"
127      * "system/register_for_change_events"
128      * "system/sign_in"
129      */
130 }