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.mybmw.internal.handler;
15 import static org.mockito.Mockito.*;
17 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.junit.jupiter.api.Test;
22 import org.mockito.ArgumentCaptor;
23 import org.openhab.core.i18n.LocationProvider;
24 import org.openhab.core.thing.ChannelUID;
25 import org.openhab.core.thing.Thing;
26 import org.openhab.core.thing.ThingUID;
27 import org.openhab.core.thing.binding.ThingHandlerCallback;
28 import org.openhab.core.types.State;
31 * The {@link ErrorResponseTest} is responsible for handling commands, which are
32 * sent to one of the channels.
34 * @author Bernd Weymann - Initial contribution
37 @SuppressWarnings("null")
38 public class ErrorResponseTest {
40 ArgumentCaptor<ChannelUID> channelCaptor;
42 ArgumentCaptor<State> stateCaptor;
44 ThingHandlerCallback tc;
48 List<ChannelUID> allChannels;
50 List<State> allStates;
56 * Prepare environment for Vehicle Status Updates
58 public void setup(String type, boolean imperial) {
60 this.imperial = imperial;
61 Thing thing = mock(Thing.class);
62 when(thing.getUID()).thenReturn(new ThingUID("testbinding", "test"));
63 MyBMWCommandOptionProvider cop = mock(MyBMWCommandOptionProvider.class);
64 LocationProvider locationProvider = mock(LocationProvider.class);
65 cch = new VehicleHandler(thing, cop, locationProvider, type);
66 tc = mock(ThingHandlerCallback.class);
68 channelCaptor = ArgumentCaptor.forClass(ChannelUID.class);
69 stateCaptor = ArgumentCaptor.forClass(State.class);
73 public void testErrorResponseCallbacks() {
74 String error = "{\"error\":true,\"reason\":\"offline\"}";
76 cch.vehicleStatusCallback.onResponse(error);