summaryrefslogtreecommitdiffstats
path: root/profiles
diff options
context:
space:
mode:
Diffstat (limited to 'profiles')
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java29
-rw-r--r--profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java16
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java2
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java1
-rw-r--r--profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java11
-rw-r--r--profiles/snmp/src/test/resources/log4j.properties23
6 files changed, 51 insertions, 31 deletions
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
index f6e58757..f0fe43cd 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/mock/MocoServer.java
@@ -15,30 +15,29 @@
*/
package org.onap.cli.fw.http.mock;
-import com.fasterxml.jackson.core.JsonProcessingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.github.dreamhead.moco.HttpServer;
-import com.github.dreamhead.moco.Moco;
-import com.github.dreamhead.moco.ResponseHandler;
-import com.github.dreamhead.moco.Runner;
+import static com.github.dreamhead.moco.Runner.runner;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
import org.onap.cli.fw.conf.OnapCommandConfig;
import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.error.OnapCommandDiscoveryFailed;
import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.error.OnapCommandInvalidSchema;
import org.onap.cli.fw.http.conf.OnapCommandHttpConstants;
-import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import org.onap.cli.fw.utils.OnapCommandDiscoveryUtils;
import org.springframework.core.io.Resource;
import org.yaml.snakeyaml.Yaml;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import static com.github.dreamhead.moco.Runner.runner;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.github.dreamhead.moco.HttpServer;
+import com.github.dreamhead.moco.Moco;
+import com.github.dreamhead.moco.ResponseHandler;
+import com.github.dreamhead.moco.Runner;
public class MocoServer {
diff --git a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
index 2cfb5206..1a13819a 100644
--- a/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
+++ b/profiles/http/src/main/java/org/onap/cli/fw/http/schema/OnapCommandSchemaHttpLoader.java
@@ -47,6 +47,8 @@ import net.minidev.json.JSONObject;
public class OnapCommandSchemaHttpLoader {
+ private static final String ATTRIBUTE = "Attribute '";
+
private OnapCommandSchemaHttpLoader() {
// to follow standards !
}
@@ -174,15 +176,15 @@ public class OnapCommandSchemaHttpLoader {
validationMap.put(OnapCommandHttpConstants.AUTH, OnapCommandHttpConstants.AUTH_VALUES);
validationMap.put(OnapCommandHttpConstants.MODE, OnapCommandHttpConstants.MODE_VALUES);
- for (String secKey : validationMap.keySet()) {
- if (serviceMap.containsKey(secKey)) {
- Object obj = serviceMap.get(secKey);
+ for (Map.Entry<String, String> secKey : validationMap.entrySet()) {
+ if (serviceMap.containsKey(secKey.getKey())) {
+ Object obj = serviceMap.get(secKey.getKey());
if (obj == null) {
- errorList.add("Attribute '" + secKey + "' under '" + OnapCommandHttpConstants.SERVICE + "' is empty");
+ errorList.add(ATTRIBUTE + secKey.getKey() + "' under '" + OnapCommandHttpConstants.SERVICE + "' is empty");
} else {
String value = String.valueOf(obj);
- if (!OnapCommandConfig.getCommaSeparatedList(validationMap.get(secKey)).contains(value)) {
- errorList.add("Attribute '" + secKey + "' contains invalid value. Valide values are "
+ if (!OnapCommandConfig.getCommaSeparatedList(validationMap.get(secKey.getKey())).contains(value)) {
+ errorList.add(ATTRIBUTE + secKey.getKey() + "' contains invalid value. Valide values are "
+ OnapCommandConfig.getCommaSeparatedList(validationMap.get(key1))); //
}
}
@@ -288,7 +290,7 @@ public class OnapCommandSchemaHttpLoader {
String method = (String) requestMap.get(OnapCommandHttpConstants.METHOD);
if (method != null && !method.isEmpty()) {
if (!OnapCommandConfig.getCommaSeparatedList(OnapCommandHttpConstants.HTTP_METHODS).contains(method.toLowerCase())) {
- errorList.add("Attribute '" + OnapCommandHttpConstants.METHOD + "' under '" + OnapCommandHttpConstants.REQUEST + "' is invalid, correct types are "
+ errorList.add(ATTRIBUTE + OnapCommandHttpConstants.METHOD + "' under '" + OnapCommandHttpConstants.REQUEST + "' is invalid, correct types are "
+ OnapCommandConfig.getCommaSeparatedList(OnapCommandHttpConstants.HTTP_METHODS).toString());
}
} else {
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
index 1ee1b200..ed88b0c6 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/cmd/OnapSnmpCommand.java
@@ -60,7 +60,7 @@ public class OnapSnmpCommand extends OnapCommand {
super.addDefaultSchemas(OnapCommandSnmpConstants.DEFAULT_PARAMETER_SNMP_FILE_NAME);
}
- private String getAgent() throws OnapCommandException {
+ private String getAgent() {
OnapCommandParameter onapCommandParameter = this.getParametersMap().get(OnapCommandSnmpConstants.SNMP_AGENT);
return (String) onapCommandParameter.getValue();
}
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java
index 87b9241f..35d6425e 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/exception/OnapSnmpErrorResponse.java
@@ -16,7 +16,6 @@
package org.onap.cli.fw.snmp.exception;
-import org.onap.cli.fw.error.OnapCommandException;
import org.onap.cli.fw.error.OnapCommandExecutionFailed;
/**
diff --git a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java
index 87cde127..b2af9ae6 100644
--- a/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java
+++ b/profiles/snmp/src/main/java/org/onap/cli/fw/snmp/schema/OnapCommandSchemaSnmpLoader.java
@@ -16,19 +16,16 @@
package org.onap.cli.fw.snmp.schema;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
import org.onap.cli.fw.conf.OnapCommandConfig;
-import org.onap.cli.fw.conf.OnapCommandConstants;
import org.onap.cli.fw.error.OnapCommandException;
-import org.onap.cli.fw.schema.OnapCommandSchemaLoader;
import org.onap.cli.fw.snmp.cmd.OnapSnmpCommand;
import org.onap.cli.fw.snmp.conf.OnapCommandSnmpConstants;
import org.onap.cli.fw.utils.OnapCommandUtils;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
public class OnapCommandSchemaSnmpLoader {
private static List<String> validateSnmpSchemaSection(Map<String, Object> values) {
diff --git a/profiles/snmp/src/test/resources/log4j.properties b/profiles/snmp/src/test/resources/log4j.properties
new file mode 100644
index 00000000..78f32285
--- /dev/null
+++ b/profiles/snmp/src/test/resources/log4j.properties
@@ -0,0 +1,23 @@
+# Copyright 2018 Huawei Technologies Co., Ltd.
+#
+# 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.
+
+log4j.rootLogger=ERROR, stdout
+
+log4j.logger.org.onap.cli=DEBUG, stdout
+
+# Direct log messages to stdout
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n