Migrate yang-data-codec-gson to JUnit5
[yangtools.git] / codec / yang-data-codec-gson / src / test / java / org / opendaylight / yangtools / yang / data / codec / gson / RFC7951YT1027Test.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.yangtools.yang.data.codec.gson;
9
10 import static org.junit.jupiter.api.Assertions.assertEquals;
11
12 import java.io.IOException;
13 import org.junit.jupiter.api.AfterAll;
14 import org.junit.jupiter.api.BeforeAll;
15 import org.junit.jupiter.api.Test;
16
17 class RFC7951YT1027Test extends AbstractYT1027Test {
18     private static JSONCodecFactory CODEC_FACTORY;
19
20     @BeforeAll
21     static void createFactory() {
22         CODEC_FACTORY = JSONCodecFactorySupplier.RFC7951.getShared(SCHEMA_CONTEXT);
23     }
24
25     @AfterAll
26     static void destroyFactory() {
27         CODEC_FACTORY = null;
28     }
29
30     @Test
31     void testDecimalUnquotedParsing() throws IOException {
32         assertEquals(DECIMAL_DATA, fromJSON(UNQUOTED_DECIMAL));
33     }
34
35     @Test
36     void testInt64UnquotedParsing() throws IOException {
37         assertEquals(INT64_DATA, fromJSON(UNQUOTED_INT64));
38     }
39
40     @Test
41     void testUint64UnquotedParsing() throws IOException {
42         assertEquals(UINT64_DATA, fromJSON(UNQUOTED_UINT64));
43     }
44
45     @Override
46     JSONCodecFactory codecFactory() {
47         return CODEC_FACTORY;
48     }
49
50     @Override
51     Class<?> wrapperClass() {
52         return QuotedJSONCodec.class;
53     }
54
55     @Override
56     String expectedDecimal() {
57         return """
58             {
59               "yt1027:decimal": "1.1"
60             }""";
61     }
62
63     @Override
64     String expectedInt64() {
65         return """
66             {
67               "yt1027:int64": "2"
68             }""";
69     }
70
71     @Override
72     String expectedUint64() {
73         return """
74             {
75               "yt1027:uint64": "1"
76             }""";
77     }
78 }