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 static org.junit.jupiter.api.Assertions.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.junit.Test;
19 import org.openhab.binding.vesync.internal.exceptions.AuthenticationException;
20 import org.openhab.binding.vesync.internal.VeSyncConstants;
21 import org.openhab.binding.vesync.internal.dto.requests.VesyncLoginCredentials;
22 import org.openhab.binding.vesync.internal.dto.requests.VesyncRequestManagedDevicesPage;
24 import java.util.regex.Matcher;
25 import java.util.regex.Pattern;
28 * The {@link VesyncRequestManagedDevicesPageTest} class implements unit test case for
29 * {@link VesyncRequestManagedDevicesPage}
31 * @author David Goodyear - Initial contribution
34 public class VesyncRequestManagedDevicesPageTest {
37 public void checkBaseFieldsExist() {
38 String content = VeSyncConstants.GSON.toJson(new VesyncLoginCredentials("username", "passmd5"));
40 assertEquals(true, content.contains("\"timeZone\": \"America/New_York\""));
41 assertEquals(true, content.contains("\"acceptLanguage\": \"en\""));
43 assertEquals(true, content.contains("\"appVersion\": \"2.5.1\""));
44 assertEquals(true, content.contains("\"phoneBrand\": \"SM N9005\""));
45 assertEquals(true, content.contains("\"phoneOS\": \"Android\""));
47 Pattern p = Pattern.compile("\"traceId\": \"\\d+\"");
48 Matcher m = p.matcher(content);
49 assertEquals(true, m.find());
53 public void checkRequestDevicesFields() {
57 content = VeSyncConstants.GSON
58 .toJson(new VesyncRequestManagedDevicesPage(org.openhab.binding.vesync.internal.handler.requests.VesyncAuthenticatedRequestTest.testUser, 1, 100));
59 } catch (AuthenticationException ae) {
64 assertEquals(true, content.contains("\"method\": \"devices\""));
65 assertEquals(true, content.contains("\"pageNo\": \"1\""));
66 assertEquals(true, content.contains("\"pageSize\": \"100\""));
67 assertEquals(true, content.contains("\"token\": \"AccessTokenString=\""));
68 assertEquals(true, content.contains("\"accountID\": \"5328043\""));