Connectivity service synchronous write.
[unimgr.git] / legato-api / src / test / java / org / opendaylight / unimgr / mef / legato / global / l2cp / LegatoL2cpEecProfileDataTreeChangeListenerTest.java
1 /*
2  * Copyright (c) 2018 Xoriant Corporation and others. All rights reserved.
3  *
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
7  */
8
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;
14
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;
34
35
36 /**
37  * @author Arif.Hussain@Xoriant.Com
38  *
39  */
40 @RunWith(PowerMockRunner.class)
41 public class LegatoL2cpEecProfileDataTreeChangeListenerTest {
42
43     private LegatoL2cpEecController legatoL2cpEecController;
44
45     @Before
46     public void setUp() throws Exception {
47         legatoL2cpEecController = mock(LegatoL2cpEecController.class, Mockito.CALLS_REAL_METHODS);
48     }
49
50     @SuppressWarnings("unchecked")
51     @Test
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));
64     }
65
66
67     private DataTreeModification<Profile> getDataTree(final ModificationType modificationType) {
68         final DataObjectModification<Profile> proDataObjModification = new DataObjectModification<Profile>() {
69             @Override
70             public Collection<DataObjectModification<? extends DataObject>> getModifiedChildren() {
71                 // TODO Auto-generated method stub
72                 return null;
73             }
74
75             @Override
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
79                 return null;
80             }
81
82             @Override
83             public <C extends ChildOf<? super Profile>> DataObjectModification<C> getModifiedChildContainer(Class<C> arg0) {
84                 // TODO Auto-generated method stub
85                 return null;
86             }
87
88             @Override
89             public DataObjectModification<? extends DataObject> getModifiedChild(PathArgument arg0) {
90                 // TODO Auto-generated method stub
91                 return null;
92             }
93
94             @Override
95             public <C extends Augmentation<Profile> & DataObject> DataObjectModification<C> getModifiedAugmentation(
96                     Class<C> arg0) {
97                 // TODO Auto-generated method stub
98                 return null;
99             }
100
101             @Override
102             public ModificationType getModificationType() {
103                 return modificationType;
104             }
105
106             @Override
107             public PathArgument getIdentifier() {
108                 // TODO Auto-generated method stub
109                 return null;
110             }
111
112             @Override
113             public Class<Profile> getDataType() {
114                 // TODO Auto-generated method stub
115                 return null;
116             }
117
118             @Override
119             public Profile getDataBefore() {
120                 // TODO Auto-generated method stub
121                 return null;
122             }
123
124             @Override
125             public Profile getDataAfter() {
126                 // TODO Auto-generated method stub
127                 return null;
128             }
129         };
130
131         DataTreeModification<Profile> modifiedPro = new DataTreeModification<Profile>() {
132             @Override
133             public DataTreeIdentifier<Profile> getRootPath() {
134                 return null;
135             }
136
137             @Override
138             public DataObjectModification<Profile> getRootNode() {
139                 return proDataObjModification;
140             }
141         };
142         return modifiedPro;
143     }
144
145 }