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.openhab.core.test.java.JavaOSGiTest;
18 import org.openhab.core.thing.Thing;
19 import org.openhab.core.thing.binding.ThingHandler;
22 * @author Markus Rathgeb - migrated to plain Java test
24 public class AbstractHueOSGiTestParent extends JavaOSGiTest {
27 * Gets the handler of a thing if it fits to a specific type.
29 * @param thing the thing
30 * @param clazz type of thing handler
31 * @return the thing handler
33 protected <T extends ThingHandler> T getThingHandler(Thing thing, Class<T> clazz) {
34 return waitForAssert(() -> {
35 final ThingHandler tmp = thing.getHandler();
36 if (clazz.isInstance(tmp)) {
37 return clazz.cast(tmp);
40 assertEquals(clazz, tmp.getClass());
41 throw new RuntimeException();