Migrate implementation/neutron/southbound to IETF YANG model
[lispflowmapping.git] / mappingservice / implementation / src / test / java / org / opendaylight / lispflowmapping / implementation / lisp / MappingServiceTest.java
index e5db74c40b0769eb00bc02e7886f6deff92adc9a..82bac8fbc03c279e34591743d74bb51ef3f48a4b 100644 (file)
@@ -21,12 +21,14 @@ import org.opendaylight.lispflowmapping.implementation.mdsal.DataStoreBackEnd;
 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.LispAFIConvertor;
+import org.opendaylight.lispflowmapping.lisp.util.LispAddressUtil;
 import org.opendaylight.lispflowmapping.lisp.util.MaskUtil;
 import org.opendaylight.lispflowmapping.tools.junit.BaseTestCase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.lispaddress.LispAddressContainer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.MappingOrigin;
 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.mapping.authkey.container.MappingAuthkey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.mappingservice.rev150906.mapping.authkey.container.MappingAuthkeyBuilder;
 
 /**
  *
@@ -40,7 +42,7 @@ public class MappingServiceTest extends BaseTestCase {
     private DataStoreBackEnd dsbe;
     private MappingSystem mapSystem;
 
-    private LispAddressContainer eid;
+    private Eid eid;
     private String eidIpv4String = "10.31.0.5";
 
     @Override
@@ -61,17 +63,17 @@ public class MappingServiceTest extends BaseTestCase {
         inject(mapService, "dsbe", dsbe);
         inject(mapService, "mappingSystem", mapSystem);
 
-        eid = LispAFIConvertor.asIPv4Address(eidIpv4String);
+        eid = LispAddressUtil.asIpv4PrefixEid(eidIpv4String + "/32");
 
     }
 
     @SuppressWarnings("unchecked")
     @Test
     public void handleAddAuthenticationKey() throws Exception {
-        String authKey = "pass";
-        MappingEntry<String> keyMappingEntry = new MappingEntry<String>(SubKeys.AUTH_KEY, authKey);
-        LispAddressContainer key = getDefaultKey();
-        MappingEntry<String>[] authKeys =(MappingEntry<String>[]) (Arrays.asList(keyMappingEntry).toArray());
+        MappingAuthkey authKey = new MappingAuthkeyBuilder().setKeyType(1).setKeyString("pass").build();
+        MappingEntry<MappingAuthkey> keyMappingEntry = new MappingEntry<>(SubKeys.AUTH_KEY, authKey);
+        Eid key = getDefaultKey();
+        MappingEntry<MappingAuthkey>[] authKeys =(MappingEntry<MappingAuthkey>[]) (Arrays.asList(keyMappingEntry).toArray());
         addDsbeAddKeyExpectation();
         oneOf(dao).put(weq(key), weq(authKeys));
         mapService.addAuthenticationKey(eid, authKey);
@@ -79,7 +81,7 @@ public class MappingServiceTest extends BaseTestCase {
 
     @Test
     public void handleGetAuthenticationKey() throws Exception {
-        LispAddressContainer key = getDefaultKey();
+        Eid key = getDefaultKey();
         oneOf(dao).getSpecific(weq(key), with(SubKeys.AUTH_KEY));
         ret("password");
         assertEquals("password", mapService.getAuthenticationKey(eid));
@@ -88,8 +90,8 @@ public class MappingServiceTest extends BaseTestCase {
     @Test
     public void handleGetAuthenticationKeyNoIteration() throws Exception {
         mapSystem.setIterateMask(false);
-        LispAddressContainer key = getDefaultKey();
-        LispAddressContainer passKey = getKey(30);
+        Eid key = getDefaultKey();
+        Eid passKey = getKey(30);
         oneOf(dao).getSpecific(weq(key), with(SubKeys.AUTH_KEY));
         allowing(dao).getSpecific(weq(passKey), with(SubKeys.AUTH_KEY));
         ret("password");
@@ -98,25 +100,26 @@ public class MappingServiceTest extends BaseTestCase {
 
     @Test
     public void handleRemoveAuthenticationKey() throws Exception {
-        LispAddressContainer key = getDefaultKey();
+        Eid key = getDefaultKey();
         addDsbeRemoveKeyExpectation();
         oneOf(dao).removeSpecific(weq(key), with(SubKeys.AUTH_KEY));
         mapService.removeAuthenticationKey(eid);
     }
 
-    private LispAddressContainer getDefaultKey() {
+    private Eid getDefaultKey() {
         return getKey(32);
     }
 
-    private LispAddressContainer getKey(int mask) {
-        return MaskUtil.normalize(eid, (short)mask);
+    private Eid getKey(int mask) {
+        Eid key = LispAddressUtil.asIpv4PrefixEid(eidIpv4String + "/" + Integer.toString(mask));
+        return MaskUtil.normalize(key, (short) mask);
     }
 
     private void addDsbeAddKeyExpectation() {
         ValueSaverAction<AuthenticationKey> dsbeAddKeySaverAction = new ValueSaverAction<AuthenticationKey>() {
             @Override
             public Object invoke(Invocation invocation) throws Throwable {
-                mapSystem.addAuthenticationKey(lastValue.getLispAddressContainer(), lastValue.getAuthkey());
+                mapSystem.addAuthenticationKey(lastValue.getEid(), lastValue.getMappingAuthkey());
                 return null;
             }
         };
@@ -127,7 +130,7 @@ public class MappingServiceTest extends BaseTestCase {
         ValueSaverAction<AuthenticationKey> dsbeRemoveKeySaverAction = new ValueSaverAction<AuthenticationKey>() {
             @Override
             public Object invoke(Invocation invocation) throws Throwable {
-                mapSystem.removeAuthenticationKey(lastValue.getLispAddressContainer());
+                mapSystem.removeAuthenticationKey(lastValue.getEid());
                 return null;
             }
         };