Sean Condon | 0e89bda | 2017-03-21 14:23:19 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.drivers.microsemi.yang; |
| 17 | |
| 18 | import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation; |
| 19 | import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain; |
| 20 | import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation; |
| 21 | import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain; |
| 22 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdCharStr; |
| 23 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId; |
| 24 | import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdIdCharStr; |
| 25 | import org.onosproject.incubator.net.l2monitoring.cfm.impl.CfmMdManager; |
| 26 | import static org.easymock.EasyMock.*; |
| 27 | import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException; |
| 28 | import org.onosproject.incubator.net.l2monitoring.cfm.service.MdStore; |
| 29 | |
| 30 | import java.util.Optional; |
| 31 | |
| 32 | public class MockCfmMdService extends CfmMdManager { |
| 33 | |
| 34 | @Override |
| 35 | public void activate() { |
| 36 | store = createMock(MdStore.class); |
| 37 | |
| 38 | try { |
| 39 | MaintenanceAssociation ma = DefaultMaintenanceAssociation |
| 40 | .builder(MaIdCharStr.asMaId("ma-1-1"), 6) |
| 41 | .maNumericId((short) 1) |
| 42 | .ccmInterval(MaintenanceAssociation.CcmInterval.INTERVAL_3MS) |
| 43 | .build(); |
| 44 | |
| 45 | MdId md1Name = MdIdCharStr.asMdId("md-1"); |
| 46 | MaintenanceDomain md1 = DefaultMaintenanceDomain |
| 47 | .builder(md1Name) |
| 48 | .mdNumericId((short) 1) |
| 49 | .mdLevel(MaintenanceDomain.MdLevel.LEVEL3) |
| 50 | .addToMaList(ma) |
| 51 | .build(); |
| 52 | |
| 53 | expect(store.createUpdateMaintenanceDomain(md1)) |
| 54 | .andReturn(true); |
| 55 | expect(store.getMaintenanceDomain(md1Name)) |
| 56 | .andReturn(Optional.of(md1)).anyTimes(); |
| 57 | replay(store); |
| 58 | |
| 59 | } catch (CfmConfigException e) { |
| 60 | throw new IllegalArgumentException("Error creating Md md-1 for test"); |
| 61 | } |
| 62 | } |
| 63 | } |