Revert "SEBA-814 To support Multi-Tcont on TT-workflow, SADIS configuration is updated."

(we need to release a stable version for ONOS 2.2 before applying this changes)

This reverts commit 94f12a0bb65f9e9873dcbc482ed97c406edd85e3.

Change-Id: Ic3df9c1fc1fafcc405319936c20be0dc070361c1
diff --git a/app/src/test/java/org/opencord/sadis/impl/SubscriberAndDeviceManagerTest.java b/app/src/test/java/org/opencord/sadis/impl/SubscriberAndDeviceManagerTest.java
index fa68966..6ff5cc3 100644
--- a/app/src/test/java/org/opencord/sadis/impl/SubscriberAndDeviceManagerTest.java
+++ b/app/src/test/java/org/opencord/sadis/impl/SubscriberAndDeviceManagerTest.java
@@ -24,17 +24,34 @@
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.onlab.packet.Ip4Address;
+import org.onlab.packet.MacAddress;
+import org.onlab.packet.VlanId;
 
-import org.opencord.sadis.BaseConfig;
-import org.opencord.sadis.BaseInformation;
-import org.opencord.sadis.BaseInformationService;
 import org.opencord.sadis.SubscriberAndDeviceInformation;
+import org.opencord.sadis.BaseConfig;
+import org.opencord.sadis.BaseInformationService;
+import org.opencord.sadis.BaseInformation;
 
 /**
  * Set of tests of the SADIS ONOS application component.
  */
 public class SubscriberAndDeviceManagerTest extends BaseSadis {
 
+    SubscriberAndDeviceInformationBuilder entry1 = SubscriberAndDeviceInformationBuilder.build("1", (short) 2,
+            (short) 2, "1/1/2", (short) 125, (short) 3, "aa:bb:cc:dd:ee:ff", "XXX-NASID", "10.10.10.10",
+            "circuit123", "remote123", 64, "1Gb", "1Gb");
+    SubscriberAndDeviceInformationBuilder entry2 = SubscriberAndDeviceInformationBuilder.build("2", (short) 4,
+            (short) 4, "1/1/2", (short) 129, (short) 4, "aa:bb:cc:dd:ee:ff", "YYY-NASID", "1.1.1.1",
+            "circuit234", "remote234", 64, "10Gb", "10Gb");
+    SubscriberAndDeviceInformationBuilder entry3 = SubscriberAndDeviceInformationBuilder.build("3", (short) 7,
+            (short) 8, "1/1/2", (short) 130, (short) 7, "ff:aa:dd:cc:bb:ee", "MNO-NASID", "30.30.30.30",
+            "circuit567", "remote567", 64, "10Gb", "10Gb");
+    SubscriberAndDeviceInformationBuilder entry4 = SubscriberAndDeviceInformationBuilder.build("4", (short) 2,
+            (short) 1, "1/1/2", (short) 132, (short) 1, "ff:cc:dd:aa:ee:bb", "PQR-NASID", "15.15.15.15",
+            "circuit678", "remote678", 64, "5Gb", "5Gb");
+
+
     @Before
     public void setUp() throws Exception {
         config = new SubscriberAndDeviceInformationConfig();
@@ -57,9 +74,23 @@
     private void checkEntriesForSubscriberAndAccessDevice(BaseConfig config) {
         List<SubscriberAndDeviceInformation> entries = config.getEntries();
         assertEquals(3, entries.size());
-        assertTrue(checkEquality(entry1, entries.get(0)));
-        assertTrue(checkEquality(entry2, entries.get(1)));
-        assertTrue(checkEquality(entry5, entries.get(2)));
+
+        SubscriberAndDeviceInformation sub = SubscriberAndDeviceInformationBuilder.build("1", (short) 2, (short) 2,
+                "1/1/2", (short) 125,
+                (short) 3, "aa:bb:cc:dd:ee:ff", "XXX-NASID", "10.10.10.10", "circuit123", "remote123",
+                64, "1Gb", "1Gb");
+        assertTrue(checkEquality(sub, entries.get(0)));
+
+
+        sub = SubscriberAndDeviceInformationBuilder.build("2", (short) 4, (short) 4, "1/1/2", (short) 129,
+                (short) 4, "aa:bb:cc:dd:ee:ff", "YYY-NASID", "1.1.1.1", "circuit234", "remote234",
+                64, "10Gb", "10Gb");
+        assertTrue(checkEquality(sub, entries.get(1)));
+
+        sub = SubscriberAndDeviceInformationBuilder.build("cc:dd:ee:ff:aa:bb", (short) -1, (short) -1, null,
+                (short) -1, (short) -1, "cc:dd:ee:ff:aa:bb", "CCC-NASID", "12.12.12.12", "circuit345", "remote345",
+                64, "10Gb", "10Gb");
+        assertTrue(checkEquality(sub, entries.get(2)));
     }
 
     @Test
@@ -67,15 +98,14 @@
 
         BaseInformationService<SubscriberAndDeviceInformation> subscriberService = sadis.getSubscriberInfoService();
 
-        checkGetForExisting(ID1, entry1, subscriberService);
-        checkGetForExisting(ID2, entry2, subscriberService);
-        checkGetForExisting(ID5, entry5, subscriberService);
+        checkGetForExisting("1", entry1, subscriberService);
+        checkGetForExisting("2", entry2, subscriberService);
 
-        invalidateId(ID1, subscriberService);
-        checkFromBoth(ID1, entry1, subscriberService);
+        invalidateId("1", subscriberService);
+        checkFromBoth("1", entry1, subscriberService);
 
         invalidateAll(subscriberService);
-        checkFromBoth(ID2, entry2, subscriberService);
+        checkFromBoth("2", entry2, subscriberService);
     }
 
 
@@ -90,14 +120,14 @@
         config.init(subject, "sadis-remote-mode-test", node("/RemoteConfig.json"), mapper, delegate);
         configListener.event(event);
 
-        checkGetForExisting(ID3, entry3, subscriberService);
-        checkGetForExisting(ID4, entry4, subscriberService);
+        checkGetForExisting("3", entry3, subscriberService);
+        checkGetForExisting("4", entry4, subscriberService);
 
-        invalidateId(ID3, subscriberService);
-        checkFromBoth(ID3, entry3, subscriberService);
+        invalidateId("3", subscriberService);
+        checkFromBoth("3", entry3, subscriberService);
 
         invalidateAll(subscriberService);
-        checkFromBoth(ID4, entry4, subscriberService);
+        checkFromBoth("4", entry4, subscriberService);
     }
 
     @Test
@@ -106,16 +136,60 @@
         config.init(subject, "sadis-remote-mode-test", node("/RemoteConfig.json"), mapper, delegate);
         configListener.event(event);
 
-        checkGetForExisting(ID3, null, service);
-        checkGetForNonExist(ID1, service);
+        checkGetForExisting("3", null, service);
+        checkGetForNonExist("1", service);
 
         config.init(subject, "sadis-local-mode-test", node("/LocalSubConfig.json"), mapper, delegate);
         configListener.event(event);
 
-        checkGetForExisting(ID1, null, service);
-        checkGetForNonExist(ID3, service);
+        checkGetForExisting("1", null, service);
+        checkGetForNonExist("3", service);
     }
 
+
+    private static final class SubscriberAndDeviceInformationBuilder extends SubscriberAndDeviceInformation {
+
+        public static SubscriberAndDeviceInformationBuilder build(String id, short cTag, short sTag, String nasPortId,
+                                                                  short port, short slot, String mac, String nasId,
+                                                                  String ipAddress, String circuitId, String remoteId,
+                                                                  int technologyProfileId,
+                                                                  String upstreamBandwidthProfile,
+                                                                  String downstreamBandwidthProfile) {
+
+            SubscriberAndDeviceInformationBuilder info = new SubscriberAndDeviceInformationBuilder();
+            info.setId(id);
+            if (cTag != -1) {
+                info.setCTag(VlanId.vlanId(cTag));
+            }
+            if (sTag != -1) {
+                info.setSTag(VlanId.vlanId(sTag));
+            }
+            info.setNasPortId(nasPortId);
+            if (port != -1) {
+                info.setUplinkPort(port);
+            }
+            if (slot != -1) {
+                info.setSlot(slot);
+            }
+            info.setHardwareIdentifier(MacAddress.valueOf(mac));
+            info.setIPAddress(Ip4Address.valueOf(ipAddress));
+            info.setNasId(nasId);
+            info.setCircuitId(circuitId);
+            info.setRemoteId(remoteId);
+
+            if (technologyProfileId != -1) {
+                info.setTechnologyProfileId(technologyProfileId);
+            }
+
+            info.setUpstreamBandwidthProfile(upstreamBandwidthProfile);
+            info.setDownstreamBandwidthProfile(downstreamBandwidthProfile);
+
+            return info;
+        }
+
+    }
+
+    @Override
     public boolean checkEquality(BaseInformation localEntry, BaseInformation entry) {
         SubscriberAndDeviceInformation sub = (SubscriberAndDeviceInformation) localEntry;
         SubscriberAndDeviceInformation other = (SubscriberAndDeviceInformation) localEntry;
@@ -123,6 +197,13 @@
         if (other == null) {
             return false;
         }
+        if (sub.cTag() == null) {
+            if (other.cTag() != null) {
+                return false;
+            }
+        } else if (!sub.cTag().equals(other.cTag())) {
+            return false;
+        }
         if (sub.hardwareIdentifier() == null) {
             if (other.hardwareIdentifier() != null) {
                 return false;
@@ -161,6 +242,13 @@
         if (sub.uplinkPort() != other.uplinkPort()) {
             return false;
         }
+        if (sub.sTag() == null) {
+            if (other.sTag() != null) {
+                return false;
+            }
+        } else if (!sub.sTag().equals(other.sTag())) {
+            return false;
+        }
         if (sub.slot() != other.slot()) {
             return false;
         }
@@ -178,13 +266,25 @@
         } else if (!sub.remoteId().equals(other.remoteId())) {
             return false;
         }
-        if (sub.uniTagList() == null) {
-            if (other.uniTagList() != null) {
+        if (sub.technologyProfileId() != other.technologyProfileId()) {
+            return false;
+        }
+        if (sub.upstreamBandwidthProfile() == null) {
+            if (other.upstreamBandwidthProfile() != null) {
                 return false;
             }
-        } else if (!sub.uniTagList().equals(other.uniTagList())) {
+        } else if (!sub.upstreamBandwidthProfile().equals(other.upstreamBandwidthProfile())) {
+            return false;
+        }
+        if (sub.downstreamBandwidthProfile() == null) {
+            if (other.downstreamBandwidthProfile() != null) {
+                return false;
+            }
+        } else if (!sub.downstreamBandwidthProfile().equals(other.downstreamBandwidthProfile())) {
             return false;
         }
         return true;
     }
+
+
 }