code cleanup
[unimgr.git] / cisco-xr-driver / src / test / java / org / opendaylight / unimgr / mef / nrp / cisco / xr / l2vpn / helper / AttachmentCircuitHelperTest.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.l2vpn.helper;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
12
13 import java.util.List;
14 import org.junit.Test;
15 import org.junit.runner.RunWith;
16 import org.mockito.Mockito;
17 import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.ServicePort;
18 import org.opendaylight.unimgr.mef.nrp.cisco.xr.common.helper.InterfaceHelper;
19 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev170626.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.AttachmentCircuits;
20 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.ios.xr.l2vpn.cfg.rev170626.l2vpn.database.xconnect.groups.xconnect.group.p2p.xconnects.p2p.xconnect.attachment.circuits.AttachmentCircuit;
21 import org.opendaylight.yang.gen.v1.http.cisco.com.ns.yang.cisco.xr.types.rev171201.InterfaceName;
22 import org.powermock.api.mockito.PowerMockito;
23 import org.powermock.core.classloader.annotations.PrepareForTest;
24 import org.powermock.modules.junit4.PowerMockRunner;
25
26
27 /*
28  * @author krzysztof.bijakowski@amartus.com
29  */
30 @RunWith(PowerMockRunner.class)
31 @PrepareForTest(InterfaceHelper.class)
32 public class AttachmentCircuitHelperTest {
33
34     @Test
35     public void testBuild() {
36         //given
37         InterfaceName interfaceName = new InterfaceName("GigabitEthernet0/0/1");
38
39         ServicePort port = Mockito.mock(ServicePort.class);
40         PowerMockito.mockStatic(InterfaceHelper.class);
41         PowerMockito.when(InterfaceHelper.getInterfaceName(port)).thenReturn(interfaceName);
42
43         //when
44         AttachmentCircuits actual = new AttachmentCircuitHelper().addPort(port, true).build();
45
46         //then
47         List<AttachmentCircuit> actualAttachmentCircuitList = actual.getAttachmentCircuit();
48         assertNotNull(actualAttachmentCircuitList);
49         assertEquals(1, actualAttachmentCircuitList.size());
50
51         AttachmentCircuit actualAttachmentCircuit = actualAttachmentCircuitList.get(0);
52         assertNotNull(actualAttachmentCircuit);
53         assertEquals(interfaceName, actualAttachmentCircuit.getName());
54         assertNotNull(actualAttachmentCircuit.getEnable());
55     }
56 }