2 * Copyright (c) 2018 Xoriant Corporation 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
9 package org.opendaylight.unimgr.mef.legato.global.l2cp;
10 import static org.mockito.Matchers.any;
11 import static org.mockito.Mockito.mock;
12 import static org.mockito.Mockito.times;
13 import static org.mockito.Mockito.verify;
15 import java.util.ArrayList;
16 import java.util.Collection;
17 import org.junit.Before;
18 import org.junit.Test;
19 import org.junit.runner.RunWith;
20 import org.mockito.Mockito;
21 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
22 import org.opendaylight.controller.md.sal.binding.api.DataObjectModification.ModificationType;
23 import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
24 import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
25 import org.opendaylight.unimgr.mef.legato.LegatoL2cpEecController;
26 import org.opendaylight.yang.gen.v1.urn.mef.yang.mef.global.rev171215.mef.global.l2cp.eec.profiles.Profile;
27 import org.opendaylight.yangtools.yang.binding.Augmentation;
28 import org.opendaylight.yangtools.yang.binding.ChildOf;
29 import org.opendaylight.yangtools.yang.binding.DataObject;
30 import org.opendaylight.yangtools.yang.binding.Identifiable;
31 import org.opendaylight.yangtools.yang.binding.Identifier;
32 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
33 import org.powermock.modules.junit4.PowerMockRunner;
37 * @author Arif.Hussain@Xoriant.Com
40 @RunWith(PowerMockRunner.class)
41 public class LegatoL2cpEecProfileDataTreeChangeListenerTest {
43 private LegatoL2cpEecController legatoL2cpEecController;
46 public void setUp() throws Exception {
47 legatoL2cpEecController = mock(LegatoL2cpEecController.class, Mockito.CALLS_REAL_METHODS);
50 @SuppressWarnings("unchecked")
52 public void testL2cpEecDataTreeChangeListener() {
53 Collection<DataTreeModification<Profile>> collection = new ArrayList<DataTreeModification<Profile>>();
54 DataTreeModification<Profile> profile = getDataTree(ModificationType.WRITE);
55 collection.add(profile);
56 profile = getDataTree(ModificationType.DELETE);
57 collection.add(profile);
58 profile = getDataTree(ModificationType.SUBTREE_MODIFIED);
59 collection.add(profile);
60 legatoL2cpEecController.onDataTreeChanged(collection);
61 verify(legatoL2cpEecController, times(1)).add(any(DataTreeModification.class));
62 verify(legatoL2cpEecController, times(1)).remove(any(DataTreeModification.class));
63 verify(legatoL2cpEecController, times(1)).update(any(DataTreeModification.class));
67 private DataTreeModification<Profile> getDataTree(final ModificationType modificationType) {
68 final DataObjectModification<Profile> proDataObjModification = new DataObjectModification<Profile>() {
70 public Collection<DataObjectModification<? extends DataObject>> getModifiedChildren() {
71 // TODO Auto-generated method stub
76 public <C extends Identifiable<K> & ChildOf<? super Profile>, K extends Identifier<C>> DataObjectModification<C> getModifiedChildListItem(
77 Class<C> arg0, K arg1) {
78 // TODO Auto-generated method stub
83 public <C extends ChildOf<? super Profile>> DataObjectModification<C> getModifiedChildContainer(Class<C> arg0) {
84 // TODO Auto-generated method stub
89 public DataObjectModification<? extends DataObject> getModifiedChild(PathArgument arg0) {
90 // TODO Auto-generated method stub
95 public <C extends Augmentation<Profile> & DataObject> DataObjectModification<C> getModifiedAugmentation(
97 // TODO Auto-generated method stub
102 public ModificationType getModificationType() {
103 return modificationType;
107 public PathArgument getIdentifier() {
108 // TODO Auto-generated method stub
113 public Class<Profile> getDataType() {
114 // TODO Auto-generated method stub
119 public Profile getDataBefore() {
120 // TODO Auto-generated method stub
125 public Profile getDataAfter() {
126 // TODO Auto-generated method stub
131 DataTreeModification<Profile> modifiedPro = new DataTreeModification<Profile>() {
133 public DataTreeIdentifier<Profile> getRootPath() {
138 public DataObjectModification<Profile> getRootNode() {
139 return proDataObjModification;