Bump upstreams
[lispflowmapping.git] / mappingservice / southbound / src / test / java / org / opendaylight / lispflowmapping / southbound / lisp / AuthenticationKeyDataListenerTest.java
index 36a27f7b6ba53ccbae354bb4c9a8806b6b90a682..c51a657aef1e82ca0196b7ead3133f09aa2d16d6 100644 (file)
@@ -14,29 +14,31 @@ import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
 import org.mockito.Mock;
 import org.mockito.Mockito;
-import org.mockito.runners.MockitoJUnitRunner;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
-import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.mockito.junit.MockitoJUnitRunner;
 import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
 import org.opendaylight.lispflowmapping.mapcache.AuthKeyDb;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.DataObjectModification;
+import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
+import org.opendaylight.mdsal.binding.api.DataTreeModification;
+import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.authkey.container.MappingAuthkeyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.EidUri;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKey;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyBuilder;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.db.instance.AuthenticationKeyKey;
+import org.opendaylight.yangtools.concepts.Registration;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.common.Uint16;
 
 @RunWith(MockitoJUnitRunner.class)
 public class AuthenticationKeyDataListenerTest {
 
     @Mock(name = "akdb") private static AuthKeyDb akdbMock;
     @Mock(name = "broker") private static DataBroker brokerMock;
-    @Mock(name = "registration") private static ListenerRegistration<AuthenticationKeyDataListener>
-            registrationMock;
+    @Mock(name = "registration") private static Registration registrationMock;
     @InjectMocks private static AuthenticationKeyDataListener authenticationKeyDataListener;
 
     private static DataTreeModification<AuthenticationKey> change_del;
@@ -57,7 +59,7 @@ public class AuthenticationKeyDataListenerTest {
     private static final Eid IPV4_PREFIX_EID = LispAddressUtil.asIpv4PrefixEid(IPV4_STRING_1 + MASK);
     private static final Eid IPV4_PREFIX_BINARY_EID = LispAddressUtil.asIpv4PrefixBinaryEid(IPV4_STRING_1 + MASK);
 
-    private static final MappingAuthkey MAPPING_AUTHKEY = new MappingAuthkeyBuilder().setKeyType(1)
+    private static final MappingAuthkey MAPPING_AUTHKEY = new MappingAuthkeyBuilder().setKeyType(Uint16.ONE)
             .setKeyString("key").build();
 
     private static final AuthenticationKey AUTHENTICATION_KEY_1 = getAuthenticationKey(IPV4_BINARY_EID_1);
@@ -70,7 +72,7 @@ public class AuthenticationKeyDataListenerTest {
     public void init() {
         final InstanceIdentifier<AuthenticationKey> instanceIdentifierMock = Mockito.mock(InstanceIdentifier.class);
         final DataTreeIdentifier<AuthenticationKey> dataTreeIdentifier =
-                new DataTreeIdentifier<>(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
+                DataTreeIdentifier.of(LogicalDatastoreType.CONFIGURATION, instanceIdentifierMock);
 
         change_del = Mockito.mock(DataTreeModification.class);
         change_subtreeModified = Mockito.mock(DataTreeModification.class);
@@ -85,12 +87,12 @@ public class AuthenticationKeyDataListenerTest {
         Mockito.when(change_subtreeModified.getRootNode()).thenReturn(mod_subtreeModified);
         Mockito.when(change_write.getRootPath()).thenReturn(dataTreeIdentifier);
         Mockito.when(change_write.getRootNode()).thenReturn(mod_write);
-        Mockito.when(mod_del.getModificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
-        Mockito.when(mod_subtreeModified.getModificationType())
+        Mockito.when(mod_del.modificationType()).thenReturn(DataObjectModification.ModificationType.DELETE);
+        Mockito.when(mod_subtreeModified.modificationType())
                 .thenReturn(DataObjectModification.ModificationType.SUBTREE_MODIFIED);
-        Mockito.when(mod_write.getModificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);
+        Mockito.when(mod_write.modificationType()).thenReturn(DataObjectModification.ModificationType.WRITE);
 
-        Mockito.when(brokerMock.registerDataTreeChangeListener(Mockito.any(DataTreeIdentifier.class),
+        Mockito.when(brokerMock.registerTreeChangeListener(Mockito.any(DataTreeIdentifier.class),
                 Mockito.any(AuthenticationKeyDataListener.class))).thenReturn(registrationMock);
         authenticationKeyDataListener = new AuthenticationKeyDataListener(brokerMock, akdbMock);
     }
@@ -99,9 +101,8 @@ public class AuthenticationKeyDataListenerTest {
      * Tests {@link AuthenticationKeyDataListener#onDataTreeChanged} method with DELETE mod type, binary eid.
      */
     @Test
-    @SuppressWarnings("unchecked")
     public void onDataTreeChangedTest_delete_BinaryEid() {
-        Mockito.when(mod_del.getDataBefore()).thenReturn(AUTHENTICATION_KEY_1);
+        Mockito.when(mod_del.dataBefore()).thenReturn(AUTHENTICATION_KEY_1);
 
         authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_del));
         Mockito.verify(akdbMock).removeAuthenticationKey(IPV4_BINARY_EID_1);
@@ -111,9 +112,8 @@ public class AuthenticationKeyDataListenerTest {
      * Tests {@link AuthenticationKeyDataListener#onDataTreeChanged} method with DELETE mod type, Ipv4Prefix eid.
      */
     @Test
-    @SuppressWarnings("unchecked")
     public void onDataTreeChangedTest_delete_Ipv4PrefixEid() {
-        Mockito.when(mod_del.getDataBefore()).thenReturn(AUTHENTICATION_KEY_PREFIX);
+        Mockito.when(mod_del.dataBefore()).thenReturn(AUTHENTICATION_KEY_PREFIX);
 
         authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_del));
         Mockito.verify(akdbMock).removeAuthenticationKey(IPV4_PREFIX_BINARY_EID);
@@ -123,9 +123,8 @@ public class AuthenticationKeyDataListenerTest {
      * Tests {@link AuthenticationKeyDataListener#onDataTreeChanged} method with SUBTREE_MODIFIED mod type.
      */
     @Test
-    @SuppressWarnings("unchecked")
     public void onDataTreeChangedTest_subtreeModified() {
-        Mockito.when(mod_subtreeModified.getDataAfter()).thenReturn(AUTHENTICATION_KEY_2);
+        Mockito.when(mod_subtreeModified.dataAfter()).thenReturn(AUTHENTICATION_KEY_2);
 
         authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_subtreeModified));
         Mockito.verify(akdbMock).addAuthenticationKey(IPV4_BINARY_EID_2, MAPPING_AUTHKEY);
@@ -135,9 +134,8 @@ public class AuthenticationKeyDataListenerTest {
      * Tests {@link AuthenticationKeyDataListener#onDataTreeChanged} method with WRITE mod type.
      */
     @Test
-    @SuppressWarnings("unchecked")
     public void onDataTreeChangedTest_write() {
-        Mockito.when(mod_write.getDataAfter()).thenReturn(AUTHENTICATION_KEY_3);
+        Mockito.when(mod_write.dataAfter()).thenReturn(AUTHENTICATION_KEY_3);
 
         authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_write));
         Mockito.verify(akdbMock).addAuthenticationKey(IPV4_BINARY_EID_3, MAPPING_AUTHKEY);
@@ -152,10 +150,10 @@ public class AuthenticationKeyDataListenerTest {
         final DataTreeModification<AuthenticationKey> change_nullModType = Mockito.mock(DataTreeModification.class);
         final DataObjectModification mod_nullModType = Mockito.mock(DataObjectModification.class);
         Mockito.when(change_nullModType.getRootNode()).thenReturn(mod_nullModType);
-        Mockito.when(mod_nullModType.getModificationType()).thenReturn(null);
+        Mockito.when(mod_nullModType.modificationType()).thenReturn(null);
 
         authenticationKeyDataListener.onDataTreeChanged(Lists.newArrayList(change_nullModType));
-        Mockito.verifyZeroInteractions(akdbMock);
+        Mockito.verifyNoInteractions(akdbMock);
     }
 
     /**
@@ -167,8 +165,9 @@ public class AuthenticationKeyDataListenerTest {
         Mockito.verify(registrationMock).close();
     }
 
-    private static AuthenticationKey getAuthenticationKey(Eid eid) {
+    private static AuthenticationKey getAuthenticationKey(final Eid eid) {
         return new AuthenticationKeyBuilder()
+                .withKey(new AuthenticationKeyKey(new EidUri("uri-1")))
                 .setEid(eid)
                 .setMappingAuthkey(MAPPING_AUTHKEY)
                 .build();