]> git.basschouten.com Git - openhab-addons.git/blob
7ed186c0d248514c96798c1515d2fe351c4f990a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package java.org.openhab.binding.vesync.internal.handler.requests;
14
15 import static org.junit.jupiter.api.Assertions.assertEquals;
16
17 import java.util.regex.Matcher;
18 import java.util.regex.Pattern;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.Test;
22 import org.openhab.binding.vesync.internal.VeSyncConstants;
23 import org.openhab.binding.vesync.internal.dto.requests.VesyncRequest;
24
25 /**
26  * The {@link VesyncRequestTest} class implements unit test case for {@link VesyncRequest}
27  *
28  * @author David Goodyear - Initial contribution
29  */
30 @NonNullByDefault
31 public class VesyncRequestTest {
32
33     @Test
34     public void checkBaseFieldsExist() {
35         String content = VeSyncConstants.GSON.toJson(new VesyncRequest());
36
37         assertEquals(true, content.contains("\"timeZone\": \"America/New_York\""));
38         assertEquals(true, content.contains("\"acceptLanguage\": \"en\""));
39
40         assertEquals(true, content.contains("\"appVersion\": \"2.5.1\""));
41         assertEquals(true, content.contains("\"phoneBrand\": \"SM N9005\""));
42         assertEquals(true, content.contains("\"phoneOS\": \"Android\""));
43
44         Pattern p = Pattern.compile("\"traceId\": \"\\d+\"");
45         Matcher m = p.matcher(content);
46         assertEquals(true, m.find());
47     }
48 }