2 * Copyright (c) 2016 CableLabs 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.cli;
10 import static org.mockito.Mockito.mock;
11 import static org.mockito.Mockito.when;
13 import java.util.ArrayList;
14 import java.util.List;
16 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
17 import org.opendaylight.unimgr.api.IUnimgrConsoleProvider;
18 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress;
19 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.Evc;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.EvcAugmentation;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.UniAugmentation;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniDest;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.unimgr.rev151012.evc.UniSource;
25 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link;
26 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
28 public class UnimgrConsoleProviderTest implements IUnimgrConsoleProvider {
30 private final List<UniAugmentation> listUni = new ArrayList<UniAugmentation>();
31 private final List<EvcAugmentation> listEvc = new ArrayList<EvcAugmentation>();
32 private boolean firstTest = true;
35 public boolean addUni(UniAugmentation uni) {
36 return (listUni.contains(uni)) ? false : listUni.add(uni);
40 public boolean removeUni(IpAddress ipAddress) {
41 firstTest = !firstTest;
46 public List<UniAugmentation> listUnis(LogicalDatastoreType dataStoreType) {
50 public void setListUnis(int amount, String ipAddress) {
51 for(int i=0; i<amount; i++){
52 final UniAugmentation uniAug = mock(UniAugmentation.class);
53 final IpAddress ipAddr = mock(IpAddress.class);
54 final Ipv4Address ip4 = mock(Ipv4Address.class);
55 when(uniAug.getIpAddress()).thenReturn(ipAddr);
56 when(ipAddr.getIpv4Address()).thenReturn(ip4);
57 when(ip4.getValue()).thenReturn(ipAddress);
63 public UniAugmentation getUni(IpAddress ipAddress) {
64 return (listUni.isEmpty()) ? null : listUni.get(0);
68 public boolean addEvc(EvcAugmentation evc) {
69 return (listEvc.contains(evc)) ? false : listEvc.add(evc);
73 public Evc getEvc(String uuid) {
74 return (listEvc.isEmpty()) ? null : listEvc.get(0);
78 public boolean removeEvc(String uuid) {
79 firstTest = !firstTest;
84 public void close() throws Exception { }
87 public boolean updateUni(UniAugmentation uni) {
88 // TODO Auto-generated method stub
93 public boolean updateEvc(InstanceIdentifier<Link> evcKey, EvcAugmentation evc, UniSource uniSource,
95 // TODO Auto-generated method stub