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.hue.internal;
15 import static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.core.test.java.JavaOSGiTest;
19 import org.openhab.core.thing.Thing;
20 import org.openhab.core.thing.binding.ThingHandler;
23 * @author Markus Rathgeb - Initial contribution
24 * @author Markus Rathgeb - migrated to plain Java test
27 public class AbstractHueOSGiTestParent extends JavaOSGiTest {
30 * Gets the handler of a thing if it fits to a specific type.
32 * @param thing the thing
33 * @param clazz type of thing handler
34 * @return the thing handler
36 protected <T extends ThingHandler> T getThingHandler(Thing thing, Class<T> clazz) {
37 return waitForAssert(() -> {
38 final ThingHandler tmp = thing.getHandler();
39 if (clazz.isInstance(tmp)) {
40 return clazz.cast(tmp);
43 assertEquals(clazz, tmp.getClass());
44 throw new IllegalStateException();