summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-03-28 15:57:56 +0530
committerKanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>2018-03-28 15:57:56 +0530
commit3a55d9cac0afdc82e09bfea709bbc2f96b8f5886 (patch)
treefc80bf949c2b2b8af1679f7a396ef8df1a6f2f14
parentd962e2d37d37ccc04d1dfc0169a1d50f3a1a513b (diff)
Make SchemaInfo comparable
Issue-ID: CLI-100 Change-Id: Iff1d0606b1b2e0d386282daf47b27d50c24fe18b Signed-off-by: Kanagaraj Manickam k00365106 <kanagaraj.manickam@huawei.com>
-rw-r--r--framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java13
-rw-r--r--validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java33
2 files changed, 26 insertions, 20 deletions
diff --git a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java
index df30a240..8f3df9ae 100644
--- a/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java
+++ b/framework/src/main/java/org/onap/cli/fw/schema/OnapCommandSchemaInfo.java
@@ -16,18 +16,18 @@
package org.onap.cli.fw.schema;
+import java.util.ArrayList;
+import java.util.List;
+
import org.onap.cli.fw.cmd.OnapCommandType;
import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.info.OnapCommandState;
-import java.util.ArrayList;
-import java.util.List;
-
/**
* OnapCommandSchemaInfo is used in discovery caching.
*
*/
-public class OnapCommandSchemaInfo {
+public class OnapCommandSchemaInfo implements Comparable<OnapCommandSchemaInfo> {
/**
* Name of the schema file name
@@ -138,5 +138,10 @@ public class OnapCommandSchemaInfo {
this.state = state;
}
+ @Override
+ public int compareTo(OnapCommandSchemaInfo o) {
+ return this.cmdName.compareTo(o.getCmdName());
+ }
+
}
diff --git a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
index a631e3d2..c046e530 100644
--- a/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
+++ b/validate/validation/src/test/java/org/onap/cli/validation/OnapValidationTest.java
@@ -16,19 +16,8 @@
package org.onap.cli.validation;
-import org.apache.commons.io.FileUtils;
-import org.junit.Test;
-import org.onap.cli.fw.conf.OnapCommandConstants;
-import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandInvalidSample;
-import org.onap.cli.fw.registrar.OnapCommandRegistrar;
-import org.onap.cli.fw.schema.OnapCommandSchemaInfo;
-import org.onap.cli.main.OnapCli;
-import org.onap.cli.main.conf.OnapCliConstants;
-import org.onap.cli.moco.OnapCommandSample;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.yaml.snakeyaml.Yaml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
@@ -44,8 +33,18 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
+import org.apache.commons.io.FileUtils;
+import org.junit.Test;
+import org.onap.cli.fw.error.OnapCommandException;
+import org.onap.cli.fw.error.OnapCommandInvalidSample;
+import org.onap.cli.fw.registrar.OnapCommandRegistrar;
+import org.onap.cli.fw.schema.OnapCommandSchemaInfo;
+import org.onap.cli.main.OnapCli;
+import org.onap.cli.main.conf.OnapCliConstants;
+import org.onap.cli.moco.OnapCommandSample;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.yaml.snakeyaml.Yaml;
public class OnapValidationTest {
@@ -96,7 +95,9 @@ public class OnapValidationTest {
System.out.println(version);
System.out.println("==========================\n\n");
int i = 1;
- for (OnapCommandSchemaInfo sch : OnapCommandRegistrar.getRegistrar().listCommandInfo()) {
+ List<OnapCommandSchemaInfo> cmds = OnapCommandRegistrar.getRegistrar().listCommandInfo();
+ Collections.sort(cmds);
+ for (OnapCommandSchemaInfo sch : cmds) {
if (sch.isIgnore()) {
continue;
}