Save memory consumption by avoding unnecessary instantiation

Change-Id: I7ce66c11136653fabc490aa7f33fdadf4454d2cc
diff --git a/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java b/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java
index 8634fb3..c8a32f0 100644
--- a/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/flow/impl/FlowRuleManagerTest.java
@@ -63,7 +63,6 @@
 import org.onosproject.store.trivial.impl.SimpleFlowRuleStore;
 
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
@@ -412,7 +411,7 @@
 
         @Override
         public Iterable<Device> getDevices() {
-            return Arrays.asList(DEV);
+            return Collections.singletonList(DEV);
         }
 
         @Override
diff --git a/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java b/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java
index 9a0ae89..6b5929a 100644
--- a/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/group/impl/GroupManagerTest.java
@@ -258,9 +258,9 @@
                                         DID,
                                         Group.Type.SELECT,
                                         createdGroup.buckets());
-        List<Group> groupEntries = Arrays.asList(createdGroup);
+        List<Group> groupEntries = Collections.singletonList(createdGroup);
         providerService.pushGroupMetrics(DID, groupEntries);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_ADDED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADDED));
     }
 
     // Test group add bucket operations
@@ -296,15 +296,15 @@
                                        addKey,
                                        appId);
         GroupBuckets updatedBuckets = new GroupBuckets(buckets);
-        List<GroupOperation> expectedGroupOps = Arrays.asList(
-               GroupOperation.createModifyGroupOperation(createdGroup.id(),
-                                                         Group.Type.SELECT,
-                                                         updatedBuckets));
+        List<GroupOperation> expectedGroupOps = Collections.singletonList(
+                GroupOperation.createModifyGroupOperation(createdGroup.id(),
+                        Group.Type.SELECT,
+                        updatedBuckets));
         internalProvider.validate(DID, expectedGroupOps);
         Group existingGroup = groupService.getGroup(DID, addKey);
-        List<Group> groupEntries = Arrays.asList(existingGroup);
+        List<Group> groupEntries = Collections.singletonList(existingGroup);
         providerService.pushGroupMetrics(DID, groupEntries);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED));
     }
 
     // Test group remove bucket operations
@@ -340,15 +340,15 @@
                                             removeKey,
                                             appId);
         GroupBuckets updatedBuckets = new GroupBuckets(buckets);
-        List<GroupOperation> expectedGroupOps = Arrays.asList(
-               GroupOperation.createModifyGroupOperation(createdGroup.id(),
-                                                         Group.Type.SELECT,
-                                                         updatedBuckets));
+        List<GroupOperation> expectedGroupOps = Collections.singletonList(
+                GroupOperation.createModifyGroupOperation(createdGroup.id(),
+                        Group.Type.SELECT,
+                        updatedBuckets));
         internalProvider.validate(DID, expectedGroupOps);
         Group existingGroup = groupService.getGroup(DID, removeKey);
-        List<Group> groupEntries = Arrays.asList(existingGroup);
+        List<Group> groupEntries = Collections.singletonList(existingGroup);
         providerService.pushGroupMetrics(DID, groupEntries);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATED));
     }
 
     // Test group remove operations
@@ -356,13 +356,13 @@
         GroupKey currKey = new DefaultGroupKey("group1RemoveBuckets".getBytes());
         Group existingGroup = groupService.getGroup(DID, currKey);
         groupService.removeGroup(DID, currKey, appId);
-        List<GroupOperation> expectedGroupOps = Arrays.asList(
-             GroupOperation.createDeleteGroupOperation(existingGroup.id(),
-                                                       Group.Type.SELECT));
+        List<GroupOperation> expectedGroupOps = Collections.singletonList(
+                GroupOperation.createDeleteGroupOperation(existingGroup.id(),
+                        Group.Type.SELECT));
         internalProvider.validate(DID, expectedGroupOps);
         List<Group> groupEntries = Collections.emptyList();
         providerService.pushGroupMetrics(DID, groupEntries);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_REMOVED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVED));
     }
 
     /**
@@ -423,7 +423,7 @@
                         createdGroup.type(),
                         createdGroup.buckets());
         providerService.groupOperationFailed(DID, groupAddOp);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_ADD_FAILED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_ADD_FAILED));
 
         // Group Mod failure test
         groupService.addGroup(newGroupDesc);
@@ -435,7 +435,7 @@
                         createdGroup.type(),
                         createdGroup.buckets());
         providerService.groupOperationFailed(DID, groupModOp);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_UPDATE_FAILED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_UPDATE_FAILED));
 
         // Group Delete failure test
         groupService.addGroup(newGroupDesc);
@@ -446,7 +446,7 @@
                 createDeleteGroupOperation(createdGroup.id(),
                         createdGroup.type());
         providerService.groupOperationFailed(DID, groupDelOp);
-        internalListener.validateEvent(Arrays.asList(GroupEvent.Type.GROUP_REMOVE_FAILED));
+        internalListener.validateEvent(Collections.singletonList(GroupEvent.Type.GROUP_REMOVE_FAILED));
 
     }
 
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
index 2512fee..66bf476 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/IntentManagerTest.java
@@ -46,7 +46,6 @@
 import org.onosproject.net.resource.LinkResourceAllocations;
 import org.onosproject.store.trivial.impl.SimpleIntentStore;
 
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.List;
@@ -151,7 +150,7 @@
     private static class MockInstallableIntent extends FlowRuleIntent {
 
         public MockInstallableIntent() {
-            super(APPID, Arrays.asList(new MockFlowRule(100)));
+            super(APPID, Collections.singletonList(new MockFlowRule(100)));
         }
     }
 
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
index 00fcf44..32d917f 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/PointToPointIntentCompilerTest.java
@@ -38,7 +38,7 @@
 import org.onosproject.net.resource.LambdaResource;
 import org.onosproject.net.resource.LinkResourceService;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import static org.hamcrest.CoreMatchers.instanceOf;
@@ -228,8 +228,8 @@
 
         final LinkResourceService resourceService =
                 IntentTestsMocks.MockResourceService.makeBandwidthResourceService(1000.0);
-        final List<Constraint> constraints = Arrays.asList(
-                new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0))));
+        final List<Constraint> constraints =
+                Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0))));
 
         final PointToPointIntent intent = makeIntent("s1", "s3", constraints);
 
@@ -250,8 +250,8 @@
 
         final LinkResourceService resourceService =
                 IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
-        final List<Constraint> constraints = Arrays.asList(
-                new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0))));
+        final List<Constraint> constraints =
+                Collections.singletonList(new BandwidthConstraint(new BandwidthResource(Bandwidth.bps(100.0))));
 
         try {
             final PointToPointIntent intent = makeIntent("s1", "s3", constraints);
@@ -274,7 +274,8 @@
     @Test
     public void testLambdaConstrainedIntentSuccess() {
 
-        final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1)));
+        final List<Constraint> constraints =
+                Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1)));
         final LinkResourceService resourceService =
                 IntentTestsMocks.MockResourceService.makeLambdaResourceService(1);
 
@@ -297,7 +298,8 @@
     @Test
     public void testLambdaConstrainedIntentFailure() {
 
-        final List<Constraint> constraints = Arrays.asList(new LambdaConstraint(LambdaResource.valueOf(1)));
+        final List<Constraint> constraints =
+                Collections.singletonList(new LambdaConstraint(LambdaResource.valueOf(1)));
         final LinkResourceService resourceService =
                 IntentTestsMocks.MockResourceService.makeBandwidthResourceService(10.0);
         try {
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
index 742b4e2..c15ecae 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/phase/CompilingTest.java
@@ -40,7 +40,7 @@
 import org.onosproject.net.provider.ProviderId;
 import org.onosproject.store.Timestamp;
 
-import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.Optional;
 
@@ -70,7 +70,7 @@
     private final ConnectPoint cp3 = new ConnectPoint(deviceId("2"), portNumber(1));
     private final ConnectPoint cp4 = new ConnectPoint(deviceId("2"), portNumber(2));
 
-    private final List<Link> links = Arrays.asList(new DefaultLink(pid, cp2, cp4, DIRECT));
+    private final List<Link> links = Collections.singletonList(new DefaultLink(pid, cp2, cp4, DIRECT));
     private final Path path = new DefaultPath(pid, links, 10);
 
     private PointToPointIntent input;
@@ -118,7 +118,7 @@
     public void testMoveToNextPhaseWithoutError() {
         IntentData pending = new IntentData(input, INSTALL_REQ, version);
 
-        expect(processor.compile(input, null)).andReturn(Arrays.asList(compiled));
+        expect(processor.compile(input, null)).andReturn(Collections.singletonList(compiled));
         replay(processor);
 
         Compiling sut = new Compiling(processor, pending, Optional.empty());