Add HexString/DottedQuad/Uuid support to IetfYangUtil
[mdsal.git] / model / ietf / rfc6991-ietf-yang-types / src / test / java / org / opendaylight / yang / gen / v1 / urn / ietf / params / xml / ns / yang / ietf / yang / types / rev130715 / IetfYangUtilTest.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.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715;
9
10 import static org.junit.Assert.assertArrayEquals;
11 import static org.junit.Assert.assertEquals;
12 import static org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.IetfYangUtil.INSTANCE;
13
14 import java.util.UUID;
15 import org.junit.Test;
16
17 public class IetfYangUtilTest {
18     @Test
19     public void testDottedQuad() {
20         assertArrayEquals(new byte[] { 1, 2, 3, 4 }, INSTANCE.dottedQuadBytes(new DottedQuad("1.2.3.4")));
21         assertEquals(new DottedQuad("1.2.3.4"), INSTANCE.dottedQuadFor(new byte[] { 1, 2, 3, 4 }));
22     }
23
24     @Test
25     public void testHexString() {
26         assertArrayEquals(new byte[] { 0, 1 }, INSTANCE.hexStringBytes(new HexString("00:01")));
27         assertEquals(new HexString("00:01"), INSTANCE.hexStringFor(new byte[] { 0, 1 }));
28     }
29
30     @Test
31     public void testPhysAddress() {
32         assertArrayEquals(new byte[] { 0, 1} , INSTANCE.physAddressBytes(new PhysAddress("00:01")));
33         assertEquals(new PhysAddress("00:01"), INSTANCE.physAddressFor(new byte[] { 0, 1 }));
34     }
35
36     @Test
37     public void testMacAddress() {
38         assertArrayEquals(new byte[] { 0, 1, 2, 3, 4, 5 },
39             INSTANCE.macAddressBytes(new MacAddress("00:01:02:03:04:05")));
40         assertEquals(new MacAddress("00:01:02:03:04:05"), INSTANCE.macAddressFor(new byte[] { 0, 1, 2, 3, 4, 5 }));
41     }
42
43     @Test
44     public void testUuid() {
45         final UUID java = UUID.randomUUID();
46         assertEquals(new Uuid(java.toString()), INSTANCE.uuidFor(java));
47     }
48 }