2 * Copyright (c) 2010-2024 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.solarforecast;
15 import java.util.HashMap;
16 import java.util.List;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.core.config.core.ConfigDescription;
22 import org.openhab.core.config.core.Configuration;
23 import org.openhab.core.thing.Bridge;
24 import org.openhab.core.thing.Channel;
25 import org.openhab.core.thing.ChannelGroupUID;
26 import org.openhab.core.thing.ChannelUID;
27 import org.openhab.core.thing.Thing;
28 import org.openhab.core.thing.ThingStatusInfo;
29 import org.openhab.core.thing.ThingTypeUID;
30 import org.openhab.core.thing.ThingUID;
31 import org.openhab.core.thing.binding.ThingHandlerCallback;
32 import org.openhab.core.thing.binding.builder.ChannelBuilder;
33 import org.openhab.core.thing.type.ChannelGroupTypeUID;
34 import org.openhab.core.thing.type.ChannelTypeUID;
35 import org.openhab.core.types.Command;
36 import org.openhab.core.types.State;
37 import org.openhab.core.types.TimeSeries;
38 import org.openhab.core.types.TimeSeries.Policy;
41 * The {@link CallbackMock} is a helper for unit tests to receive callbacks
43 * @author Bernd Weymann - Initial contribution
46 public class CallbackMock implements ThingHandlerCallback {
48 Map<String, TimeSeries> seriesMap = new HashMap<String, TimeSeries>();
51 public void stateUpdated(ChannelUID channelUID, State state) {
55 public void postCommand(ChannelUID channelUID, Command command) {
59 public void sendTimeSeries(ChannelUID channelUID, TimeSeries timeSeries) {
60 seriesMap.put(channelUID.getAsString(), timeSeries);
63 public TimeSeries getTimeSeries(String cuid) {
64 TimeSeries ts = seriesMap.get(cuid);
66 ts = new TimeSeries(Policy.REPLACE);
72 public void statusUpdated(Thing thing, ThingStatusInfo thingStatus) {
76 public void thingUpdated(Thing thing) {
80 public void validateConfigurationParameters(Thing thing, Map<String, Object> configurationParameters) {
84 public void validateConfigurationParameters(Channel channel, Map<String, Object> configurationParameters) {
88 public @Nullable ConfigDescription getConfigDescription(ChannelTypeUID channelTypeUID) {
93 public @Nullable ConfigDescription getConfigDescription(ThingTypeUID thingTypeUID) {
98 public void configurationUpdated(Thing thing) {
102 public void migrateThingType(Thing thing, ThingTypeUID thingTypeUID, Configuration configuration) {
106 public void channelTriggered(Thing thing, ChannelUID channelUID, String event) {
110 public ChannelBuilder createChannelBuilder(ChannelUID channelUID, ChannelTypeUID channelTypeUID) {
111 return ChannelBuilder.create(channelUID);
115 public ChannelBuilder editChannel(Thing thing, ChannelUID channelUID) {
116 return ChannelBuilder.create(channelUID);
120 public List<ChannelBuilder> createChannelBuilders(ChannelGroupUID channelGroupUID,
121 ChannelGroupTypeUID channelGroupTypeUID) {
126 public boolean isChannelLinked(ChannelUID channelUID) {
131 public @Nullable Bridge getBridge(ThingUID bridgeUID) {