Fix sonar issues
- Move string literals to the left side of comparison
- Fix a typo
Change-Id: I3e59cde5d73d99d918b51fa5bcaa7c737ed7f525
diff --git a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java
index b23de26..f6f6e06 100644
--- a/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java
+++ b/apps/test/distributed-primitives/src/main/java/org/onosproject/distributedprimitives/cli/WorkQueueTestCommand.java
@@ -46,7 +46,7 @@
String name = null;
@Argument(index = 1, name = "operation",
- description = "operation name. One of {add, addMutiple, "
+ description = "operation name. One of {add, addMultiple, "
+ "takeAndComplete, totalPending, totalInProgress, totalCompleted, destroy}",
required = true, multiValued = false)
String operation = null;
@@ -68,35 +68,35 @@
StorageService storageService = get(StorageService.class);
Serializer serializer = Serializer.using(KryoNamespaces.BASIC);
queue = storageService.getWorkQueue(name, serializer);
- if (operation.equals("add")) {
+ if ("add".equals(operation)) {
if (value1 == null) {
print("Usage: add <value1>");
} else {
get(queue.addOne(value1));
print("Done");
}
- } else if (operation.equals("addMultiple")) {
+ } else if ("addMultiple".equals(operation)) {
if (value1 == null || value2 == null) {
print("Usage: addMultiple <value1> <value2>");
} else {
get(queue.addMultiple(Arrays.asList(value1, value2)));
print("Done");
}
- } else if (operation.equals("takeAndComplete")) {
+ } else if ("takeAndComplete".equals(operation)) {
int maxItems = value1 != null ? Integer.parseInt(value1) : 1;
Collection<Task<String>> tasks = get(queue.take(maxItems));
tasks.forEach(task -> get(queue.complete(task.taskId())));
print("Done");
- } else if (operation.equals("totalPending")) {
+ } else if ("totalPending".equals(operation)) {
WorkQueueStats stats = get(queue.stats());
print("%d", stats.totalPending());
- } else if (operation.equals("totalInProgress")) {
+ } else if ("totalInProgress".equals(operation)) {
WorkQueueStats stats = get(queue.stats());
print("%d", stats.totalInProgress());
- } else if (operation.equals("totalCompleted")) {
+ } else if ("totalCompleted".equals(operation)) {
WorkQueueStats stats = get(queue.stats());
print("%d", stats.totalCompleted());
- } else if (operation.equals("destroy")) {
+ } else if ("destroy".equals(operation)) {
get(queue.destroy());
} else {
print("Invalid operation name. Valid operations names are:"