Remove duplicate value test command and ensure existing value test command handles null values

Change-Id: Icb049963a61778b145100ef5266c80f9b2fcc5de
diff --git a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/AtomicValueTestCommand.java b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/AtomicValueTestCommand.java
index 7c00737..39a1320 100644
--- a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/AtomicValueTestCommand.java
+++ b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/AtomicValueTestCommand.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017-present Open Networking Laboratory
+ * Copyright 2016-present Open Networking Laboratory
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,14 +24,14 @@
 import org.onosproject.store.service.StorageService;
 
 /**
- * Atomic value test command.
+ * CLI command to manipulate a distributed value.
  */
 @Command(scope = "onos", name = "value-test",
-        description = "Manipulate an atomic value")
+        description = "Manipulate a distributed value")
 public class AtomicValueTestCommand extends AbstractShellCommand {
 
     @Argument(index = 0, name = "name",
-            description = "value name",
+            description = "Value name",
             required = true, multiValued = false)
     String name = null;
 
@@ -40,43 +40,40 @@
             required = true, multiValued = false)
     String operation = null;
 
-    @Argument(index = 2, name = "key",
+    @Argument(index = 2, name = "value1",
             description = "first arg",
             required = false, multiValued = false)
-    String arg1 = null;
+    String value1 = null;
 
-    @Argument(index = 3, name = "value1",
+    @Argument(index = 3, name = "value2",
             description = "second arg",
             required = false, multiValued = false)
-    String arg2 = null;
+    String value2 = null;
 
-    AtomicValue<String> value;
+    AtomicValue<String> atomicValue;
 
     @Override
     protected void execute() {
         StorageService storageService = get(StorageService.class);
-        value = storageService.<String>atomicValueBuilder()
-                .withName(name)
-                .withSerializer(Serializer.using(KryoNamespaces.BASIC))
-                .build()
-                .asAtomicValue();
-
+        atomicValue = storageService.<String>atomicValueBuilder()
+                                    .withName(name)
+                                    .withSerializer(Serializer.using(KryoNamespaces.BASIC))
+                                    .build()
+                                    .asAtomicValue();
         if ("get".equals(operation)) {
-            print(value.get());
+            print("%s", atomicValue.get());
         } else if ("set".equals(operation)) {
-            value.set("null".equals(arg1) ? null : arg1);
-        } else if ("getAndSet".equals(operation)) {
-            print(value.getAndSet(arg1));
+            atomicValue.set("null".equals(value1) ? null : value1);
         } else if ("compareAndSet".equals(operation)) {
-            print(value.compareAndSet("null".equals(arg1) ? null : arg1, "null".equals(arg2) ? null : arg2));
-        }
-    }
-
-    void print(Object value) {
-        if (value == null) {
-            print("null");
+            print("%b", atomicValue.compareAndSet(
+                    "null".equals(value1) ? null : value1,
+                    "null".equals(value2) ? null : value2));
+        } else if ("getAndSet".equals(operation)) {
+            print("%s", atomicValue.getAndSet(value1));
+        } else if ("destroy".equals(operation)) {
+            atomicValue.destroy();
         } else {
-            print("%s", value);
+            print("Error, unknown operation %s", operation);
         }
     }
 }
diff --git a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/ValueTestCommand.java b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/ValueTestCommand.java
deleted file mode 100644
index afb39ad..0000000
--- a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/ValueTestCommand.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * Copyright 2016-present Open Networking Laboratory
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.onosproject.distributedprimitives.cli;
-
-import org.apache.karaf.shell.commands.Argument;
-import org.apache.karaf.shell.commands.Command;
-import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.store.serializers.KryoNamespaces;
-import org.onosproject.store.service.AtomicValue;
-import org.onosproject.store.service.Serializer;
-import org.onosproject.store.service.StorageService;
-
-/**
- * CLI command to manipulate a distributed value.
- */
-@Command(scope = "onos", name = "value-test",
-        description = "Manipulate a distributed value")
-public class ValueTestCommand extends AbstractShellCommand {
-
-    @Argument(index = 0, name = "value",
-            description = "Value name",
-            required = true, multiValued = false)
-    String value = null;
-
-    @Argument(index = 1, name = "operation",
-            description = "operation name",
-            required = true, multiValued = false)
-    String operation = null;
-
-    @Argument(index = 2, name = "value1",
-            description = "first arg",
-            required = false, multiValued = false)
-    String value1 = null;
-
-    @Argument(index = 3, name = "value2",
-            description = "second arg",
-            required = false, multiValued = false)
-    String value2 = null;
-
-    AtomicValue<String> atomicValue;
-
-    @Override
-    protected void execute() {
-        StorageService storageService = get(StorageService.class);
-        atomicValue = storageService.<String>atomicValueBuilder()
-                                    .withName(value)
-                                    .withSerializer(Serializer.using(KryoNamespaces.BASIC))
-                                    .build()
-                                    .asAtomicValue();
-        if ("get".equals(operation)) {
-            print("%s", atomicValue.get());
-        } else if ("set".equals(operation)) {
-            atomicValue.set(value1);
-        } else if ("compareAndSet".equals(operation)) {
-            print("%b", atomicValue.compareAndSet(value1, value2));
-        } else if ("getAndSet".equals(operation)) {
-            print("%s", atomicValue.getAndSet(value1));
-        } else if ("destroy".equals(operation)) {
-            atomicValue.destroy();
-        } else {
-            print("Error, unknown operation %s", operation);
-        }
-    }
-}
diff --git a/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index 735eaa7..52ef0c5 100644
--- a/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/apps/test/distributed-primitives/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -17,9 +17,6 @@
 
     <command-bundle xmlns="http://karaf.apache.org/xmlns/shell/v1.1.0">
         <command>
-            <action class="org.onosproject.distributedprimitives.cli.AtomicValueTestCommand"/>
-        </command>
-        <command>
             <action class="org.onosproject.distributedprimitives.cli.CounterTestIncrementCommand"/>
         </command>
         <command>
@@ -50,7 +47,7 @@
             <action class="org.onosproject.distributedprimitives.cli.EventuallyConsistentMapTestCommand"/>
         </command>
         <command>
-            <action class="org.onosproject.distributedprimitives.cli.ValueTestCommand"/>
+            <action class="org.onosproject.distributedprimitives.cli.AtomicValueTestCommand"/>
         </command>
         <command>
             <action class="org.onosproject.distributedprimitives.cli.LeaderElectorTestCommand"/>