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.boschshc.internal.services.intrusion;
15 import static org.junit.jupiter.api.Assertions.assertSame;
16 import static org.mockito.ArgumentMatchers.any;
17 import static org.mockito.ArgumentMatchers.anyString;
18 import static org.mockito.Mockito.verify;
19 import static org.mockito.Mockito.when;
21 import java.util.concurrent.ExecutionException;
22 import java.util.concurrent.TimeoutException;
23 import java.util.function.Consumer;
25 import org.junit.jupiter.api.BeforeEach;
26 import org.junit.jupiter.api.Test;
27 import org.junit.jupiter.api.extension.ExtendWith;
28 import org.mockito.Mock;
29 import org.mockito.junit.jupiter.MockitoExtension;
30 import org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants;
31 import org.openhab.binding.boschshc.internal.devices.bridge.BridgeHandler;
32 import org.openhab.binding.boschshc.internal.exceptions.BoschSHCException;
33 import org.openhab.binding.boschshc.internal.services.intrusion.dto.IntrusionDetectionSystemState;
36 * Unit tests for {@link IntrusionDetectionSystemStateService}.
38 * @author David Pace - Initial contribution
41 @ExtendWith(MockitoExtension.class)
42 class IntrusionDetectionSystemStateServiceTest {
44 private IntrusionDetectionSystemStateService fixture;
47 private BridgeHandler bridgeHandler;
50 private Consumer<IntrusionDetectionSystemState> consumer;
53 private IntrusionDetectionSystemState testState;
57 fixture = new IntrusionDetectionSystemStateService();
58 fixture.initialize(bridgeHandler, BoschSHCBindingConstants.SERVICE_INTRUSION_DETECTION, consumer);
62 void getState() throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
63 when(bridgeHandler.getState(anyString(), any())).thenReturn(testState);
64 IntrusionDetectionSystemState state = fixture.getState();
65 verify(bridgeHandler).getState("intrusion/states/system", IntrusionDetectionSystemState.class);
66 assertSame(testState, state);