Address FIXME for QueuedNotificationManager
[yangtools.git] / yang / yang-data-impl / src / test / java / org / opendaylight / yangtools / yang / data / impl / codecs / Uint16CodecStringTest.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. 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
9 package org.opendaylight.yangtools.yang.data.impl.codecs;
10
11 import static org.junit.Assert.*;
12 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.deserializeWithExpectedIllegalArgEx;
13 import static org.opendaylight.yangtools.yang.data.impl.codecs.TypeDefinitionAwareCodecTestHelper.getCodec;
14
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.data.api.codec.Uint16Codec;
17 import org.opendaylight.yangtools.yang.model.util.Uint16;
18
19 /**
20  * Unit tests for Uint16CodecString.
21  *
22  * @author Thomas Pantelis
23  */
24 public class Uint16CodecStringTest {
25
26     @SuppressWarnings("unchecked")
27     @Test
28     public void testSerialize() {
29         Uint16Codec<String> codec = getCodec(Uint16.getInstance(), Uint16Codec.class);
30
31         assertEquals("serialize", "10", codec.serialize(Integer.valueOf( 10 )));
32         assertEquals("serialize", "", codec.serialize(null));
33     }
34
35     @SuppressWarnings("unchecked")
36     @Test
37     public void testDeserialize() {
38         final String hexa = "0X45c";
39         final String octal = "02134";
40         final String integer = "1116";
41
42         Uint16Codec<String> codec = getCodec(Uint16.getInstance(), Uint16Codec.class);
43
44         assertEquals("deserialize", codec.deserialize(hexa), Integer.valueOf("045c", 16));
45         assertEquals("deserialize", codec.deserialize(octal), Integer.valueOf(octal, 8));
46         assertEquals("deserialize", codec.deserialize(integer), Integer.valueOf(integer, 10));
47
48         deserializeWithExpectedIllegalArgEx(codec, "1o");
49         deserializeWithExpectedIllegalArgEx(codec, "");
50         deserializeWithExpectedIllegalArgEx(codec, null);
51     }
52 }