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.vesync.internal.handler.requests;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.junit.Test;
17 import org.openhab.binding.vesync.internal.exceptions.AuthenticationException;
18 import org.openhab.binding.vesync.internal.VeSyncConstants;
19 import org.openhab.binding.vesync.internal.dto.requests.VesyncLoginCredentials;
20 import org.openhab.binding.vesync.internal.dto.requests.VesyncRequestManagedDevicesPage;
21 import org.openhab.binding.vesync.internal.dto.requests.VesyncRequestV1ManagedDeviceDetails;
23 import java.util.regex.Matcher;
24 import java.util.regex.Pattern;
26 import static org.junit.jupiter.api.Assertions.assertEquals;
29 * The {@link VesyncRequestV1ManagedDeviceDetails} class implements unit test case for
30 * {@link VesyncRequestManagedDevicesPage}
32 * @author David Goodyear - Initial contribution
35 public class VesyncRequestV1ManagedDeviceDetailsTest {
37 // Verified content URLS
38 // https://smartapi.vesync.com/131airPurifier/v1/device/deviceDetail
41 public void checkBaseFieldsExist() {
42 String content = VeSyncConstants.GSON.toJson(new VesyncLoginCredentials("username", "passmd5"));
44 assertEquals(true, content.contains("\"timeZone\": \"America/New_York\""));
45 assertEquals(true, content.contains("\"acceptLanguage\": \"en\""));
47 assertEquals(true, content.contains("\"appVersion\": \"2.5.1\""));
48 assertEquals(true, content.contains("\"phoneBrand\": \"SM N9005\""));
49 assertEquals(true, content.contains("\"phoneOS\": \"Android\""));
51 Pattern p = Pattern.compile("\"traceId\": \"\\d+\"");
52 Matcher m = p.matcher(content);
53 assertEquals(true, m.find());
57 public void checkRequestDevicesFields() {
61 content = VeSyncConstants.GSON
62 .toJson(new VesyncRequestV1ManagedDeviceDetails(VesyncAuthenticatedRequestTest.testUser, "MyDeviceUUID"));
63 } catch (AuthenticationException ae) {
67 assertEquals(true, content.contains("\"uuid\": \"MyDeviceUUID\""));
68 assertEquals(true, content.contains("\"mobileId\": \"1234567890123456\""));
69 assertEquals(true, content.contains("\"token\": \"AccessTokenString=\""));
70 assertEquals(true, content.contains("\"accountID\": \"5328043\""));