blob: 8d0f7659bd7f03a9b47807189c88330b10668382 [file] [log] [blame]
Sean Condon0e89bda2017-03-21 14:23:19 +00001/*
2 * Copyright 2017-present Open Networking Foundation
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 */
16package org.onosproject.incubator.net.l2monitoring.cfm.impl;
17
18import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMep;
19import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMepEntry;
20import org.onosproject.incubator.net.l2monitoring.cfm.Mep;
21import org.onosproject.incubator.net.l2monitoring.cfm.MepEntry;
22import org.onosproject.incubator.net.l2monitoring.cfm.MepLbCreate;
23import org.onosproject.incubator.net.l2monitoring.cfm.MepLtCreate;
24import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdShort;
25import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
26import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId;
27import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
28import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmMepProgrammable;
29import org.onosproject.net.PortNumber;
30import org.onosproject.net.driver.AbstractHandlerBehaviour;
31
32import java.util.ArrayList;
33import java.util.Collection;
34import java.util.List;
35
36import static org.onosproject.incubator.net.l2monitoring.cfm.impl.CfmMepManagerTest.*;
37
38/**
39 * A dummy implementation of the CfmMepProgrammable for test purposes.
40 */
41public class TestCfmMepProgrammable extends AbstractHandlerBehaviour implements CfmMepProgrammable {
42
43 private List<Mep> deviceMepList;
44
45 public TestCfmMepProgrammable() throws CfmConfigException {
46 deviceMepList = new ArrayList<>();
47
48 deviceMepList.add(DefaultMep.builder(MEPID1, DEVICE_ID1, PortNumber.P0,
49 Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build());
50 deviceMepList.add(DefaultMep.builder(MEPID2, DEVICE_ID2, PortNumber.portNumber(2),
51 Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build());
52 }
53
54 @Override
55 public Collection<MepEntry> getAllMeps(MdId mdName, MaIdShort maName) throws CfmConfigException {
56 return null;
57 }
58
59 @Override
60 public MepEntry getMep(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException {
61 for (Mep mep:deviceMepList) {
62 if (mep.mdId().equals(mdName) && mep.maId().equals(maName) && mep.mepId().equals(mepId)) {
63 return DefaultMepEntry.builder(mep).buildEntry();
64 }
65 }
66 return null;
67 }
68
69 @Override
70 public boolean deleteMep(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException {
71 return true;
72 }
73
74 @Override
75 public boolean createMep(MdId mdName, MaIdShort maName, Mep mep) throws CfmConfigException {
76 return true;
77 }
78
79 @Override
80 public void transmitLoopback(MdId mdName, MaIdShort maName, MepId mepId, MepLbCreate lbCreate)
81 throws CfmConfigException {
82
83 }
84
85 @Override
86 public void abortLoopback(MdId mdName, MaIdShort maName, MepId mepId) throws CfmConfigException {
87
88 }
89
90 @Override
91 public void transmitLinktrace(MdId mdName, MaIdShort maName, MepId mepId, MepLtCreate ltCreate)
92 throws CfmConfigException {
93
94 }
95}