2 * Copyright (c) 2016 Cisco Systems Inc and others. All rights reserved.
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
8 package org.opendaylight.unimgr.mef.nrp.cisco.xr.l2vpn.helper;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertNotNull;
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;
28 * @author krzysztof.bijakowski@amartus.com
30 @RunWith(PowerMockRunner.class)
31 @PrepareForTest(InterfaceHelper.class)
32 public class AttachmentCircuitHelperTest {
35 public void testBuild() {
37 InterfaceName interfaceName = new InterfaceName("GigabitEthernet0/0/1");
39 ServicePort port = Mockito.mock(ServicePort.class);
40 PowerMockito.mockStatic(InterfaceHelper.class);
41 PowerMockito.when(InterfaceHelper.getInterfaceName(port)).thenReturn(interfaceName);
44 AttachmentCircuits actual = new AttachmentCircuitHelper().addPort(port, true).build();
47 List<AttachmentCircuit> actualAttachmentCircuitList = actual.getAttachmentCircuit();
48 assertNotNull(actualAttachmentCircuitList);
49 assertEquals(1, actualAttachmentCircuitList.size());
51 AttachmentCircuit actualAttachmentCircuit = actualAttachmentCircuitList.get(0);
52 assertNotNull(actualAttachmentCircuit);
53 assertEquals(interfaceName, actualAttachmentCircuit.getName());
54 assertNotNull(actualAttachmentCircuit.getEnable());