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.sleepiq.api.model;
15 import static org.junit.jupiter.api.Assertions.*;
17 import java.io.FileReader;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.sleepiq.api.test.AbstractTest;
22 import org.openhab.binding.sleepiq.internal.api.dto.FoundationStatusResponse;
23 import org.openhab.binding.sleepiq.internal.api.enums.FoundationPreset;
24 import org.openhab.binding.sleepiq.internal.api.impl.GsonGenerator;
26 import com.google.gson.Gson;
29 * The {@link FoundationStatusResponseTest} tests deserialization of a foundation status
32 * @author Mark Hilbush - Initial contribution
35 public class FoundationStatusResponseTest extends AbstractTest {
36 private static Gson gson = GsonGenerator.create(true);
39 public void testDeserializeAllFields() throws Exception {
40 try (FileReader reader = new FileReader(getTestDataFile("foundation-status-response.json"))) {
41 FoundationStatusResponse status = gson.fromJson(reader, FoundationStatusResponse.class);
43 assertNotNull(status);
44 assertEquals(0x0f, status.getLeftHeadPosition());
45 assertEquals(0x21, status.getLeftFootPosition());
46 assertEquals(0x0d, status.getRightHeadPosition());
47 assertEquals(0x04, status.getRightFootPosition());
48 assertEquals(FoundationPreset.SNORE, status.getCurrentPositionPresetLeft());
49 assertEquals(FoundationPreset.READ, status.getCurrentPositionPresetRight());