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.enigma2.internal;
15 import static org.eclipse.jdt.annotation.Checks.requireNonNull;
16 import static org.hamcrest.MatcherAssert.assertThat;
17 import static org.hamcrest.Matchers.*;
18 import static org.mockito.Mockito.*;
19 import static org.openhab.binding.enigma2.internal.Enigma2BindingConstants.THING_TYPE_DEVICE;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.junit.jupiter.api.Test;
24 import org.openhab.core.config.core.Configuration;
25 import org.openhab.core.thing.Thing;
26 import org.openhab.core.thing.ThingTypeUID;
29 * The {@link Enigma2HandlerFactoryTest} class is responsible for testing {@link Enigma2HandlerFactory}.
31 * @author Guido Dolfen - Initial contribution
33 @SuppressWarnings("null")
35 public class Enigma2HandlerFactoryTest {
39 private Configuration configuration;
42 public void testSupportsThingType() {
43 assertThat(new Enigma2HandlerFactory().supportsThingType(Enigma2BindingConstants.THING_TYPE_DEVICE), is(true));
47 public void testSupportsThingTypeFalse() {
48 assertThat(new Enigma2HandlerFactory().supportsThingType(new ThingTypeUID("any", "device")), is(false));
52 public void testCreateHandlerNull() {
53 thing = mock(Thing.class);
54 assertThat(new Enigma2HandlerFactory().createHandler(requireNonNull(thing)), is(nullValue()));
58 public void testCreateHandler() {
59 thing = mock(Thing.class);
60 configuration = mock(Configuration.class);
61 when(thing.getConfiguration()).thenReturn(requireNonNull(configuration));
62 when(configuration.as(Enigma2Configuration.class)).thenReturn(new Enigma2Configuration());
63 when(thing.getThingTypeUID()).thenReturn(THING_TYPE_DEVICE);
64 assertThat(new Enigma2HandlerFactory().createHandler(requireNonNull(thing)), is(notNullValue()));