blob: ba6d6561eb7709dbdc0c9fad276af8d514349764 [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.drivers.microsemi.yang;
17
18import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceAssociation;
19import org.onosproject.incubator.net.l2monitoring.cfm.DefaultMaintenanceDomain;
20import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceAssociation;
21import org.onosproject.incubator.net.l2monitoring.cfm.MaintenanceDomain;
22import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MaIdCharStr;
23import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdId;
24import org.onosproject.incubator.net.l2monitoring.cfm.identifier.MdIdCharStr;
25import org.onosproject.incubator.net.l2monitoring.cfm.impl.CfmMdManager;
26import static org.easymock.EasyMock.*;
27import org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException;
28import org.onosproject.incubator.net.l2monitoring.cfm.service.MdStore;
29
30import java.util.Optional;
31
32public 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}