JUnit test - MultiTableMapCacheTest 83/36283/6
authorMiroslav Toth <mirtoth@cisco.com>
Tue, 15 Mar 2016 13:23:27 +0000 (14:23 +0100)
committerMiroslav Toth <mirtoth@cisco.com>
Mon, 21 Mar 2016 09:43:02 +0000 (10:43 +0100)
Change-Id: Iac001a9bd75da44085b31466746dce33aff1a45c
Signed-off-by: Miroslav Toth <mirtoth@cisco.com>
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/mapcache/FlatMapCacheTest.java
mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/mapcache/MultiTableMapCacheTest.java [new file with mode: 0644]

index 51a30e4436a6d6d476e82752e7c39ac36f58e172..a127379b4c1825ee102a26bcf5c3de40120dcfec 100644 (file)
@@ -1,11 +1,10 @@
 /*
- * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
  *
  * This program and the accompanying materials are made available under the
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
-
 package org.opendaylight.lispflowmapping.implementation.mapcache;
 
 import static org.junit.Assert.assertEquals;
@@ -25,27 +24,32 @@ import org.opendaylight.lispflowmapping.interfaces.dao.MappingEntry;
 import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
 import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address
+        .Ipv4Builder;
 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.eid.container.EidBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkeyBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container
+        .MappingAuthkey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container
+        .MappingAuthkeyBuilder;
 
 public class FlatMapCacheTest {
 
-    private static ILispDAO DAO_MOCK;
-    private static FlatMapCache FLAT_MAP_CACHE;
+    private static ILispDAO daoMock;
+    private static FlatMapCache flatMapCache;
     private static final Eid EID_MOCK = mock(Eid.class);
     private static final Object DUMMY_OBJECT = "dummy_object";
 
-    private static final Eid EID_TEST = new EidBuilder().setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("127.0.0.1")).build()).build();
-    private static final MappingAuthkey MAPPING_AUTHKEY = new MappingAuthkeyBuilder().setKeyString("auth_string_test").build();
+    private static final Eid EID_TEST = new EidBuilder().setAddress(new Ipv4Builder()
+            .setIpv4(new Ipv4Address("127.0.0.1")).build()).build();
+    private static final MappingAuthkey MAPPING_AUTHKEY = new MappingAuthkeyBuilder().setKeyString("auth_string_test")
+            .build();
     private static final Eid NORMALIZED_EID = MaskUtil.normalize(EID_TEST);
 
     @Before
     public void init() {
-        DAO_MOCK = mock(ILispDAO.class);
-        FLAT_MAP_CACHE = new FlatMapCache(DAO_MOCK);
+        daoMock = mock(ILispDAO.class);
+        flatMapCache = new FlatMapCache(daoMock);
     }
 
     /**
@@ -53,9 +57,9 @@ public class FlatMapCacheTest {
      */
     @Test
     public void addMappingTest() {
-        FLAT_MAP_CACHE.addMapping(EID_TEST, DUMMY_OBJECT, false);
-        verify(DAO_MOCK, atMost(2)).put(NORMALIZED_EID, new MappingEntry<>(anyString(), any(Date.class)));
-        verify(DAO_MOCK).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.RECORD, DUMMY_OBJECT));
+        flatMapCache.addMapping(EID_TEST, DUMMY_OBJECT, false);
+        verify(daoMock, atMost(2)).put(NORMALIZED_EID, new MappingEntry<>(anyString(), any(Date.class)));
+        verify(daoMock).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.RECORD, DUMMY_OBJECT));
     }
 
     /**
@@ -63,8 +67,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void getMappingTest() {
-        when(DAO_MOCK.getSpecific(NORMALIZED_EID, SubKeys.RECORD)).thenReturn(DUMMY_OBJECT);
-        assertEquals(DUMMY_OBJECT, FLAT_MAP_CACHE.getMapping(EID_MOCK, EID_TEST));
+        when(daoMock.getSpecific(NORMALIZED_EID, SubKeys.RECORD)).thenReturn(DUMMY_OBJECT);
+        assertEquals(DUMMY_OBJECT, flatMapCache.getMapping(EID_MOCK, EID_TEST));
     }
 
     /**
@@ -72,8 +76,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void removeMappingTest() {
-        FLAT_MAP_CACHE.removeMapping(EID_TEST, true);
-        verify(DAO_MOCK).removeSpecific(NORMALIZED_EID, SubKeys.RECORD);
+        flatMapCache.removeMapping(EID_TEST, true);
+        verify(daoMock).removeSpecific(NORMALIZED_EID, SubKeys.RECORD);
     }
 
     /**
@@ -81,8 +85,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void addAuthenticationKeyTest() {
-        FLAT_MAP_CACHE.addAuthenticationKey(EID_TEST, MAPPING_AUTHKEY);
-        verify(DAO_MOCK, atMost(1)).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.AUTH_KEY, MAPPING_AUTHKEY));
+        flatMapCache.addAuthenticationKey(EID_TEST, MAPPING_AUTHKEY);
+        verify(daoMock, atMost(1)).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.AUTH_KEY, MAPPING_AUTHKEY));
     }
 
     /**
@@ -90,8 +94,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void getAuthenticationKeyTest() {
-        when(DAO_MOCK.getSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY)).thenReturn(MAPPING_AUTHKEY);
-        assertEquals(MAPPING_AUTHKEY, FLAT_MAP_CACHE.getAuthenticationKey(EID_TEST));
+        when(daoMock.getSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY)).thenReturn(MAPPING_AUTHKEY);
+        assertEquals(MAPPING_AUTHKEY, flatMapCache.getAuthenticationKey(EID_TEST));
     }
 
     /**
@@ -99,8 +103,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void getAuthenticationKeyTest_withNull() {
-        when(DAO_MOCK.getSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY)).thenReturn(new Object());
-        assertNull(FLAT_MAP_CACHE.getAuthenticationKey(EID_TEST));
+        when(daoMock.getSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY)).thenReturn(new Object());
+        assertNull(flatMapCache.getAuthenticationKey(EID_TEST));
     }
 
     /**
@@ -108,8 +112,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void removeAuthenticationKeyTest() {
-        FLAT_MAP_CACHE.removeAuthenticationKey(EID_TEST);
-        verify(DAO_MOCK).removeSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY);
+        flatMapCache.removeAuthenticationKey(EID_TEST);
+        verify(daoMock).removeSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY);
     }
 
     /**
@@ -117,8 +121,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void updateMappingRegistrationTest() {
-        FLAT_MAP_CACHE.updateMappingRegistration(EID_TEST);
-        verify(DAO_MOCK).put(NORMALIZED_EID, new MappingEntry<>(anyString(), any(Date.class)));
+        flatMapCache.updateMappingRegistration(EID_TEST);
+        verify(daoMock).put(NORMALIZED_EID, new MappingEntry<>(anyString(), any(Date.class)));
     }
 
     /**
@@ -126,8 +130,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void addDataTest() {
-        FLAT_MAP_CACHE.addData(EID_TEST, SubKeys.RECORD, DUMMY_OBJECT);
-        verify(DAO_MOCK).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.RECORD, DUMMY_OBJECT));
+        flatMapCache.addData(EID_TEST, SubKeys.RECORD, DUMMY_OBJECT);
+        verify(daoMock).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.RECORD, DUMMY_OBJECT));
     }
 
     /**
@@ -135,8 +139,8 @@ public class FlatMapCacheTest {
      */
     @Test
     public void getDataTest() {
-        when(DAO_MOCK.getSpecific(NORMALIZED_EID, SubKeys.RECORD)).thenReturn(DUMMY_OBJECT);
-        assertEquals(DUMMY_OBJECT, FLAT_MAP_CACHE.getData(EID_TEST, SubKeys.RECORD));
+        when(daoMock.getSpecific(NORMALIZED_EID, SubKeys.RECORD)).thenReturn(DUMMY_OBJECT);
+        assertEquals(DUMMY_OBJECT, flatMapCache.getData(EID_TEST, SubKeys.RECORD));
     }
 
     /**
@@ -144,7 +148,7 @@ public class FlatMapCacheTest {
      */
     @Test
     public void removeDataTest() {
-        FLAT_MAP_CACHE.removeData(EID_TEST, SubKeys.RECORD);
-        verify(DAO_MOCK).removeSpecific(NORMALIZED_EID, SubKeys.RECORD);
+        flatMapCache.removeData(EID_TEST, SubKeys.RECORD);
+        verify(daoMock).removeSpecific(NORMALIZED_EID, SubKeys.RECORD);
     }
 }
diff --git a/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/mapcache/MultiTableMapCacheTest.java b/mappingservice/implementation/src/test/java/org/opendaylight/lispflowmapping/implementation/mapcache/MultiTableMapCacheTest.java
new file mode 100644 (file)
index 0000000..79f7ca0
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.lispflowmapping.implementation.mapcache;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import com.google.common.collect.Maps;
+import java.util.Date;
+import java.util.Map;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.lispflowmapping.interfaces.dao.ILispDAO;
+import org.opendaylight.lispflowmapping.interfaces.dao.MappingEntry;
+import org.opendaylight.lispflowmapping.interfaces.dao.SubKeys;
+import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
+import org.opendaylight.lispflowmapping.lisp.util.SourceDestKeyHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.InstanceIdType;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address
+        .address.Ipv4Builder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address
+        .address.Ipv4PrefixBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address
+        .address.MacBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address
+        .address.SourceDestKeyBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+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.eid.container.EidBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey
+        .container.MappingAuthkey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey
+        .container.MappingAuthkeyBuilder;
+
+public class MultiTableMapCacheTest {
+
+    private static MultiTableMapCache multiTableMapCache;
+    private static ILispDAO daoMock;
+    private static ILispDAO srcDstDaoMock;
+    private static ILispDAO tableDaoMock;
+    private static ILispDAO dbMock;
+
+    private static final Ipv4Prefix IPV_4_PREFIX_SRC = new Ipv4Prefix("127.0.0.1/24");
+    private static final Ipv4Prefix IPV_4_PREFIX_DST = new Ipv4Prefix("192.168.0.1/24");
+    private static final long VNI = 100L;
+
+    private static final Eid EID_TEST = new EidBuilder().setVirtualNetworkId(new InstanceIdType(VNI))
+            .setAddress(new Ipv4Builder().setIpv4(new Ipv4Address("10.0.0.1")).build()).build();
+    private static final Eid EID_SOURCE_DEST_KEY_TYPE = new EidBuilder().setVirtualNetworkId(new InstanceIdType(VNI))
+            .setAddress(new SourceDestKeyBuilder()
+                    .setSourceDestKey(new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp
+                            .address.types.rev151105.lisp.address.address.source.dest.key.SourceDestKeyBuilder()
+                            .setSource(new SimpleAddress(new IpPrefix(IPV_4_PREFIX_SRC)))
+                            .setDest(new SimpleAddress(new IpPrefix(IPV_4_PREFIX_DST))).build()).build()).build();
+    private static final Eid EID_IPV4_PREFIX = new EidBuilder().setVirtualNetworkId(new InstanceIdType(VNI))
+            .setAddress(new Ipv4PrefixBuilder().setIpv4Prefix(IPV_4_PREFIX_DST).build()).build();
+    private static final Eid NORMALIZED_SRCDST_EID = MaskUtil.normalize(EID_SOURCE_DEST_KEY_TYPE);
+    private static final Eid EID_MAC = new EidBuilder().setVirtualNetworkId(new InstanceIdType(VNI))
+            .setAddress(new MacBuilder().setMac(new MacAddress("aa:bb:cc:dd:ee:ff")).build()).build();
+    private static final Eid NORMALIZED_EID = MaskUtil.normalize(EID_TEST);
+    private static final Object DUMMY_OBJECT = "dummy_object";
+    private static final MappingAuthkey MAPPING_AUTHKEY = new MappingAuthkeyBuilder()
+            .setKeyString("mapping_authkey_test").build();
+
+    @Before
+    public void init() {
+        daoMock = mock(ILispDAO.class);
+        tableDaoMock = mock(ILispDAO.class);
+        srcDstDaoMock = mock(ILispDAO.class);
+        multiTableMapCache = new MultiTableMapCache(daoMock);
+        dbMock = mock(ILispDAO.class);
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#addMapping} with SourceDestKey address type.
+     */
+    @Test
+    public void addMappingTest_withSourceDestKey() {
+
+        final Eid normalized_Eid = MaskUtil.normalize(EID_SOURCE_DEST_KEY_TYPE);
+        final Eid dstKey = SourceDestKeyHelper.getDst(normalized_Eid);
+        final Eid srcKey = SourceDestKeyHelper.getSrc(normalized_Eid);
+
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.getSpecific(dstKey, SubKeys.LCAF_SRCDST)).thenReturn(srcDstDaoMock);
+
+        multiTableMapCache.addMapping(EID_SOURCE_DEST_KEY_TYPE, DUMMY_OBJECT, true);
+        verify(srcDstDaoMock, times(2)).put(srcKey, new MappingEntry<>(anyString(), any(Date.class)));
+        verify(srcDstDaoMock).put(srcKey, new MappingEntry<>(SubKeys.RECORD, DUMMY_OBJECT));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#addMapping} with other than SourceDestKey address type.
+     */
+    @Test
+    public void addMappingTest_withoutSourceDestKey() {
+        final Eid eid_ipv4Type = new EidBuilder().setVirtualNetworkId(new InstanceIdType(VNI))
+                .setAddress(new Ipv4PrefixBuilder().setIpv4Prefix(IPV_4_PREFIX_SRC).build()).build();
+        final Eid normalized_Eid = MaskUtil.normalize(eid_ipv4Type);
+
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+
+        multiTableMapCache.addMapping(eid_ipv4Type, DUMMY_OBJECT, true);
+        verify(tableDaoMock, times(2)).put(normalized_Eid, new MappingEntry<>(anyString(), any(Date.class)));
+        verify(tableDaoMock).put(normalized_Eid, new MappingEntry<>(SubKeys.RECORD, DUMMY_OBJECT));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#getMapping} with SourceDestKey address type.
+     */
+    @Test
+    public void getMappingTest() {
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+
+        final Eid dstAddr = SourceDestKeyHelper.getDst(EID_SOURCE_DEST_KEY_TYPE);
+        final Eid normalizedDstAddr = MaskUtil.normalize(dstAddr);
+
+        final Eid srcAddr = SourceDestKeyHelper.getSrc(EID_SOURCE_DEST_KEY_TYPE);
+        final Eid normalizedSrcAddr = MaskUtil.normalize(srcAddr);
+
+        final Map<String, Object> entry = Maps.newConcurrentMap();
+        entry.put(SubKeys.RECORD, DUMMY_OBJECT);
+        entry.put(SubKeys.LCAF_SRCDST, srcDstDaoMock);
+
+        final Object obj = "mapping_lpm_eid";
+        final Map<String, Object> entry2 = Maps.newConcurrentMap();
+        entry2.put(SubKeys.RECORD, obj);
+
+        when(tableDaoMock.get(normalizedDstAddr)).thenReturn(entry);
+        when(srcDstDaoMock.get(normalizedSrcAddr)).thenReturn(entry2);
+
+        assertEquals(obj, multiTableMapCache.getMapping(EID_TEST, EID_SOURCE_DEST_KEY_TYPE));
+        assertNull(multiTableMapCache.getMapping(null, null));
+        assertNull(multiTableMapCache.getMapping(EID_TEST, null));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#removeMapping}.
+     */
+    @Test
+    public void removeMappingTest() {
+
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.getSpecific(SourceDestKeyHelper
+                .getDst(NORMALIZED_SRCDST_EID), SubKeys.LCAF_SRCDST)).thenReturn(dbMock);
+
+        multiTableMapCache.removeMapping(EID_SOURCE_DEST_KEY_TYPE, true);
+        verify(dbMock).removeSpecific(SourceDestKeyHelper.getSrc(NORMALIZED_SRCDST_EID),
+                SubKeys.RECORD);
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#addAuthenticationKey}.
+     */
+    @Test
+    public void addAuthenticationKeyTest() {
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.putNestedTable(SourceDestKeyHelper.getDst(NORMALIZED_SRCDST_EID), SubKeys.LCAF_SRCDST))
+                .thenReturn(srcDstDaoMock);
+
+        multiTableMapCache.addAuthenticationKey(EID_SOURCE_DEST_KEY_TYPE, MAPPING_AUTHKEY);
+        verify(srcDstDaoMock).put(SourceDestKeyHelper.getSrc(NORMALIZED_SRCDST_EID),
+                new MappingEntry<>(SubKeys.AUTH_KEY, MAPPING_AUTHKEY));
+
+        multiTableMapCache.addAuthenticationKey(EID_TEST, MAPPING_AUTHKEY);
+        verify(tableDaoMock).put(NORMALIZED_EID, new MappingEntry<>(SubKeys.AUTH_KEY, MAPPING_AUTHKEY));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#getAuthenticationKey} with Ipv4Prefix address.
+     */
+    @Test
+    public void getAuthenticationKeyTest_withIpv4Prefix() {
+        final short maskLength = MaskUtil.getMaskForAddress(EID_IPV4_PREFIX.getAddress());
+        final Eid key = MaskUtil.normalize(EID_IPV4_PREFIX, maskLength);
+
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.getSpecific(key, SubKeys.AUTH_KEY)).thenReturn(MAPPING_AUTHKEY);
+
+        assertEquals(MAPPING_AUTHKEY, multiTableMapCache.getAuthenticationKey(EID_IPV4_PREFIX));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#getAuthenticationKey} with SourceDestKey address.
+     */
+    @Test
+    public void getAuthenticationKeyTest_withSourceDestKey() {
+        final Eid eidSrc = SourceDestKeyHelper.getSrc(EID_SOURCE_DEST_KEY_TYPE);
+        final Eid eidDst = SourceDestKeyHelper.getDst(EID_SOURCE_DEST_KEY_TYPE);
+        final short maskLength = MaskUtil.getMaskForAddress(eidSrc.getAddress());
+        final Eid key = MaskUtil.normalize(eidSrc, maskLength);
+
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.getSpecific(eidDst, SubKeys.LCAF_SRCDST))
+                .thenReturn(srcDstDaoMock);
+        when(srcDstDaoMock.getSpecific(key, SubKeys.AUTH_KEY)).thenReturn(MAPPING_AUTHKEY);
+
+        assertEquals(MAPPING_AUTHKEY, multiTableMapCache.getAuthenticationKey(EID_SOURCE_DEST_KEY_TYPE));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#getAuthenticationKey} with Mac address.
+     */
+    @Test
+    public void getAuthenticationKeyTest_withMac() {
+        final Eid key = MaskUtil.normalize(EID_MAC);
+
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.getSpecific(key, SubKeys.AUTH_KEY)).thenReturn(MAPPING_AUTHKEY);
+
+        assertEquals(MAPPING_AUTHKEY, multiTableMapCache.getAuthenticationKey(EID_MAC));
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#removeAuthenticationKey} with SourceDestKey address type.
+     */
+    @Test
+    public void removeAuthenticationKeyTest_withSourceDestKey() {
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+        when(tableDaoMock.getSpecific(SourceDestKeyHelper.getDst(NORMALIZED_SRCDST_EID), SubKeys.LCAF_SRCDST))
+                .thenReturn(srcDstDaoMock);
+
+        multiTableMapCache.removeAuthenticationKey(EID_SOURCE_DEST_KEY_TYPE);
+        verify(srcDstDaoMock).removeSpecific(NORMALIZED_SRCDST_EID, SubKeys.AUTH_KEY);
+    }
+
+    /**
+     * Tests {@link MultiTableMapCache#removeAuthenticationKey} with Ipv4 address type.
+     */
+    @Test
+    public void removeAuthenticationKeyTest_withIpv4() {
+        when(daoMock.getSpecific(VNI, SubKeys.VNI)).thenReturn(tableDaoMock);
+
+        multiTableMapCache.removeAuthenticationKey(EID_TEST);
+        verify(tableDaoMock).removeSpecific(NORMALIZED_EID, SubKeys.AUTH_KEY);
+    }
+}