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.serialization;
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16 import static org.junit.jupiter.api.Assertions.assertNotNull;
17 import static org.junit.jupiter.api.Assertions.assertTrue;
19 import java.util.HashSet;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.junit.jupiter.api.Test;
23 import org.openhab.binding.boschshc.internal.devices.bridge.dto.DeviceServiceData;
24 import org.openhab.binding.boschshc.internal.devices.bridge.dto.LongPollResult;
25 import org.openhab.binding.boschshc.internal.devices.bridge.dto.Scenario;
28 * Unit tests for {@link BoschServiceDataDeserializer}.
30 * @author Patrick Gell - Initial contribution
34 class BoschServiceDataDeserializerTest {
37 void deserializationOfLongPollingResult() {
42 "@type": "scenarioTriggered",
43 "name": "MyTriggeredScenario",
44 "id": "509bd737-eed0-40b7-8caa-e8686a714399",
45 "lastTimeTriggered": "1689417526720"
48 "path":"/devices/hdm:HomeMaticIP:3014F711A0001916D859A8A9/services/PowerSwitch",
49 "@type":"DeviceServiceData",
52 "@type":"powerSwitchState",
55 "deviceId":"hdm:HomeMaticIP:3014F711A0001916D859A8A9"
62 var longPollResult = GsonUtils.DEFAULT_GSON_INSTANCE.fromJson(resultJson, LongPollResult.class);
63 assertNotNull(longPollResult);
64 assertEquals(2, longPollResult.result.size());
66 var resultClasses = new HashSet<>(longPollResult.result.stream().map(e -> e.getClass().getName()).toList());
67 assertEquals(2, resultClasses.size());
68 assertTrue(resultClasses.contains(DeviceServiceData.class.getName()));
69 assertTrue(resultClasses.contains(Scenario.class.getName()));