Provides wait mechanism in test for Radius Server

Change-Id: If571458efb8a66ec972106dad34418b23d772fe9
diff --git a/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java b/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java
index c9564b0..25b8fc8 100644
--- a/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java
+++ b/app/src/test/java/org/opencord/aaa/impl/AaaStatisticsTest.java
@@ -582,20 +582,32 @@
     }
 
     /*
-     * Mock implementation of SocketBasedRadiusCommunicator class.
-     *
-     */
+    * Mock implementation of SocketBasedRadiusCommunicator class.
+    *
+    */
     class TestSocketBasedRadiusCommunicator extends SocketBasedRadiusCommunicator {
 
         TestSocketBasedRadiusCommunicator(ApplicationId appId, PacketService pktService, AaaManager aaaManager) {
             super(appId, pktService, aaaManager);
         }
 
+        /**
+        * Wait 10 millis to simulate a non 0 rtt.
+        *
+        * @throws InterruptedException
+        */
+        private void waitPacket() throws InterruptedException {
+            synchronized (this) {
+                this.wait(10);
+            }
+        }
+
         // Implementation of socketBasedRadiusCommunicator--> run() method
         public void handlePacketFromServer(PacketContext context) {
-
             RADIUS incomingPkt = (RADIUS) fetchPacket(savedPackets.size() - 1);
             try {
+                // wait a couple of millis to avoid rtt being 0
+                waitPacket();
                 if (context == null) {
                     aaaStatisticsManager.handleRoundtripTime(incomingPkt.getIdentifier());
                     aaaManager.handleRadiusPacket(incomingPkt);
@@ -610,6 +622,8 @@
                 aaaManager.aaaStatisticsManager.getAaaStats().increaseMalformedResponsesRx();
                 aaaStatisticsManager.getAaaStats().countDroppedResponsesRx();
                 log.error("Cannot deserialize packet", dex);
+            } catch (InterruptedException inte) {
+                Thread.currentThread().interrupt();
             }
         }
 
diff --git a/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java b/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java
index d2bbeb1..ec4e113 100644
--- a/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java
+++ b/app/src/test/java/org/opencord/aaa/impl/AaaTestBase.java
@@ -16,6 +16,7 @@
 package org.opencord.aaa.impl;
 
 import com.google.common.base.Charsets;
+import com.google.common.collect.Lists;
 import org.onlab.packet.BasePacket;
 import org.onlab.packet.EAP;
 import org.onlab.packet.EAPOL;
@@ -45,6 +46,7 @@
 import org.opencord.sadis.BaseInformationService;
 import org.opencord.sadis.SadisService;
 import org.opencord.sadis.SubscriberAndDeviceInformation;
+import org.opencord.sadis.UniTagInformation;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.ServiceReference;
@@ -217,15 +219,29 @@
 
     private class MockSubscriberAndDeviceInformation extends SubscriberAndDeviceInformation {
 
-        MockSubscriberAndDeviceInformation(String id, VlanId ctag,
-                                           VlanId stag, String nasPortId,
-                                           String circuitId, MacAddress hardId,
+        MockSubscriberAndDeviceInformation(String id, VlanId uniTagMatch, VlanId ctag,
+                                           VlanId stag, int dsPonPrio, int upPonPrio,
+                                           int techProfileId, String dsBpId, String usBpId,
+                                           String nasPortId, String circuitId, MacAddress hardId,
                                            Ip4Address ipAddress) {
+            // Builds UniTagInformation
+            UniTagInformation.Builder tagInfoBuilder = new UniTagInformation.Builder();
+            UniTagInformation uniTagInfo = tagInfoBuilder.setUniTagMatch(uniTagMatch)
+                    .setPonCTag(ctag)
+                    .setPonSTag(stag)
+                    .setDsPonCTagPriority(dsPonPrio)
+                    .setUsPonSTagPriority(upPonPrio)
+                    .setTechnologyProfileId(techProfileId)
+                    .setDownstreamBandwidthProfile(dsBpId)
+                    .setUpstreamBandwidthProfile(usBpId)
+                    .build();
+
             this.setHardwareIdentifier(hardId);
             this.setId(id);
             this.setIPAddress(ipAddress);
             this.setNasPortId(nasPortId);
             this.setCircuitId(circuitId);
+            this.setUniTagList(Lists.newArrayList(uniTagInfo));
         }
     }
 
@@ -292,14 +308,24 @@
 }
 
     final class MockSubService implements BaseInformationService<SubscriberAndDeviceInformation> {
+        private final VlanId uniTagMatch = VlanId.vlanId((short) 35);
         private final VlanId clientCtag = VlanId.vlanId((short) 999);
         private final VlanId clientStag = VlanId.vlanId((short) 111);
+        private final int dsPrio = 0;
+        private final int usPrio = 0;
+        private final int techProfileId = 64;
+        private final String usBpId = "HSIA-US";
+        private final String dsBpId = "HSIA-DS";
         private final String clientNasPortId = "PON 1/1";
         private final String clientCircuitId = "CIR-PON 1/1";
 
+
         MockSubscriberAndDeviceInformation sub =
-                new MockSubscriberAndDeviceInformation(clientNasPortId, clientCtag,
-                        clientStag, clientNasPortId, clientCircuitId, null, null);
+                new MockSubscriberAndDeviceInformation(clientNasPortId, uniTagMatch, clientCtag,
+                                                       clientStag, dsPrio, usPrio,
+                                                       techProfileId, dsBpId, usBpId,
+                                                       clientNasPortId, clientCircuitId, null,
+                                                       null);
         @Override
         public SubscriberAndDeviceInformation get(String id) {