code cleanup
[unimgr.git] / cisco-xr-driver / src / test / java / org / opendaylight / unimgr / mef / nrp / cisco / xr / common / util / MtuUtilsTest.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 package org.opendaylight.unimgr.mef.nrp.cisco.xr.common.util;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.util.LinkedList;
14 import java.util.List;
15 import org.junit.Test;
16 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev170907._interface.configurations._interface.configuration.Mtus;
17 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.ifmgr.cfg.rev170907._interface.configurations._interface.configuration.mtus.Mtu;
18 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev171201.CiscoIosXrString;
19 import org.opendaylight.yangtools.yang.common.Uint32;
20
21
22 /*
23  * @author krzysztof.bijakowski@amartus.com
24  */
25
26 public class MtuUtilsTest {
27
28     @Test
29     public void testGenerateMtusSingle() {
30         //given
31         Long mtuValue = 1522L;
32         CiscoIosXrString owner = new CiscoIosXrString("testAddCeps");
33
34         //when
35         Mtus actual = MtuUtils.generateMtus(mtuValue, owner);
36
37         //then
38         assertNotNull(actual);
39
40         List<Mtu> actualMtuList = actual.getMtu();
41         assertEquals(actualMtuList.size(), 1);
42
43         Mtu actualMtu = actualMtuList.get(0);
44         assertEquals(Uint32.valueOf(mtuValue), actualMtu.getMtu());
45         assertEquals(owner, actualMtu.getOwner());
46     }
47
48     @Test
49     public void testGenerateMtusMultiple() {
50         //given
51         List<Long> mtuValues = new LinkedList<>();
52         mtuValues.add(1522L);
53         mtuValues.add(3000L);
54
55         CiscoIosXrString owner = new CiscoIosXrString("testAddCeps");
56
57         //when
58         Mtus actual = MtuUtils.generateMtus(mtuValues, owner);
59
60         //then
61         assertNotNull(actual);
62
63         List<Mtu> actualMtuList = actual.getMtu();
64         assertEquals(actualMtuList.size(), 2);
65
66         Mtu actualMtu = actualMtuList.get(0);
67         assertEquals(Uint32.valueOf(mtuValues.get(0)), actualMtu.getMtu());
68         assertEquals(owner, actualMtu.getOwner());
69
70         actualMtu = actualMtuList.get(1);
71         assertEquals(Uint32.valueOf(mtuValues.get(1)), actualMtu.getMtu());
72         assertEquals(owner, actualMtu.getOwner());
73     }
74 }