56567f282e3ef3d9d759af0f57aa1042701c1fb3
[honeycomb.git] / v3po / v3po2vpp / src / test / java / io / fd / honeycomb / translate / v3po / interfacesstate / InterfaceDataTranslatorTest.java
1 /*
2  * Copyright (c) 2016 Cisco and/or its affiliates.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at:
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package io.fd.honeycomb.translate.v3po.interfacesstate;
18
19 import static org.junit.Assert.assertEquals;
20
21 import org.junit.Test;
22 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.EthernetCsmacd;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.Tap;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VhostUser;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanGpeTunnel;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev150105.VxlanTunnel;
27
28 public class InterfaceDataTranslatorTest implements InterfaceDataTranslator {
29
30     @Test
31     public void testVppPhysAddrToYang() throws Exception {
32         assertEquals("01:02:03:04:05:06", vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5, 6}));
33         assertEquals("0a:0b:0c:0d:0e:0f", vppPhysAddrToYang(new byte[]{0xa, 0xb, 0xc, 0xd, 0xe, 0xf, 0, 0}));
34     }
35
36     @Test(expected = NullPointerException.class)
37     public void testVppPhysAddrToYangFailNullArgument() throws Exception {
38         vppPhysAddrToYang(null);
39     }
40
41     @Test(expected = IllegalArgumentException.class)
42     public void testVppPhysAddrToYangInvalidByteArrayLength() throws Exception {
43         vppPhysAddrToYang(new byte[]{1, 2, 3, 4, 5});
44     }
45
46     @Test
47     public void testGetInterfaceType() {
48         assertEquals(Tap.class, getInterfaceType("tap0"));
49         assertEquals(VxlanTunnel.class, getInterfaceType("vxlan0"));
50         assertEquals(VxlanGpeTunnel.class, getInterfaceType("vxlan_gpe0"));
51         assertEquals(VhostUser.class, getInterfaceType("VirtualEthernet0/0/0"));
52         assertEquals(EthernetCsmacd.class, getInterfaceType("eth0.0"));
53         assertEquals(EthernetCsmacd.class, getInterfaceType("local0"));
54     }
55 }