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.*;
17 import static org.mockito.Mockito.*;
19 import java.util.concurrent.ExecutionException;
20 import java.util.concurrent.TimeoutException;
21 import java.util.function.Consumer;
23 import org.eclipse.jdt.annotation.NonNullByDefault;
24 import org.junit.jupiter.api.BeforeEach;
25 import org.junit.jupiter.api.Test;
26 import org.junit.jupiter.api.extension.ExtendWith;
27 import org.mockito.Mock;
28 import org.mockito.junit.jupiter.MockitoExtension;
29 import org.openhab.binding.boschshc.internal.devices.BoschSHCBindingConstants;
30 import org.openhab.binding.boschshc.internal.devices.bridge.BridgeHandler;
31 import org.openhab.binding.boschshc.internal.exceptions.BoschSHCException;
32 import org.openhab.binding.boschshc.internal.services.intrusion.dto.IntrusionDetectionSystemState;
35 * Unit tests for {@link IntrusionDetectionSystemStateService}.
37 * @author David Pace - Initial contribution
41 @ExtendWith(MockitoExtension.class)
42 class IntrusionDetectionSystemStateServiceTest {
44 private @NonNullByDefault({}) IntrusionDetectionSystemStateService fixture;
46 private @Mock @NonNullByDefault({}) BridgeHandler bridgeHandler;
48 private @Mock @NonNullByDefault({}) Consumer<IntrusionDetectionSystemState> consumer;
50 private @Mock @NonNullByDefault({}) IntrusionDetectionSystemState testState;
54 fixture = new IntrusionDetectionSystemStateService();
55 fixture.initialize(bridgeHandler, BoschSHCBindingConstants.SERVICE_INTRUSION_DETECTION, consumer);
59 void getState() throws InterruptedException, TimeoutException, ExecutionException, BoschSHCException {
60 when(bridgeHandler.getState(anyString(), any())).thenReturn(testState);
61 IntrusionDetectionSystemState state = fixture.getState();
62 verify(bridgeHandler).getState("intrusion/states/system", IntrusionDetectionSystemState.class);
63 assertSame(testState, state);