2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.netvirt.bgpmanager.test;
10 import java.util.Collection;
11 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
12 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
13 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
14 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
15 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.FibEntries;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.fibentries.VrfTables;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.fibmanager.rev150330.vrfentries.VrfEntry;
19 import org.opendaylight.yangtools.concepts.ListenerRegistration;
20 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 public class MockFibManager extends AbstractMockFibManager<VrfEntry> {
24 private int numFibEntries = 0;
26 private ListenerRegistration<MockFibManager> listenerRegistration;
28 public MockFibManager(final DataBroker db) {
30 registerListener(db) ;
33 private void registerListener(final DataBroker db) {
34 final DataTreeIdentifier<VrfEntry> treeId =
35 new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, getWildCardPath());
36 listenerRegistration = db.registerDataTreeChangeListener(treeId, MockFibManager.this);
39 private InstanceIdentifier<VrfEntry> getWildCardPath() {
40 return InstanceIdentifier.create(FibEntries.class).child(VrfTables.class).child(VrfEntry.class);
44 public void onDataTreeChanged(Collection<DataTreeModification<VrfEntry>> changes) {
45 for (DataTreeModification<VrfEntry> change : changes) {
46 final InstanceIdentifier<VrfEntry> key = change.getRootPath().getRootIdentifier();
47 final DataObjectModification<VrfEntry> mod = change.getRootNode();
49 switch (mod.getModificationType()) {
54 if (mod.getDataBefore() == null) {
57 // UPDATE COUNT UNCHANGED
61 throw new IllegalArgumentException("Unhandled modification type " + mod.getModificationType());
66 public int getDataChgCount() {