aboutsummaryrefslogtreecommitdiffstats
path: root/client/client-full/src/main
diff options
context:
space:
mode:
authorning.xi <ning.xi@est.tech>2019-08-13 05:20:20 +0000
committerning.xi <ning.xi@est.tech>2019-08-13 05:20:20 +0000
commitc678c3a22f7761928f4be8e4f82f2f3c7ea417db (patch)
tree15679e12025af9a056208ff9879250b7ce458d25 /client/client-full/src/main
parent6203d19345c38dbfb6136ea6754bb11ca09fa90b (diff)
add JUnit test in client deployment and client full
Issue-ID: POLICY-1962 Change-Id: Ic10b0edc9364624161f71935f51f4411fe67c882 Signed-off-by: ning.xi <ning.xi@est.tech>
Diffstat (limited to 'client/client-full/src/main')
-rw-r--r--client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java41
1 files changed, 39 insertions, 2 deletions
diff --git a/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java b/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
index 9832f4317..1fb01c86e 100644
--- a/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
+++ b/client/client-full/src/main/java/org/onap/policy/apex/client/full/rest/ParameterCheck.java
@@ -1,6 +1,7 @@
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2016-2018 Ericsson. All rights reserved.
+ * Copyright (C) 2019 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +22,6 @@
package org.onap.policy.apex.client.full.rest;
import java.util.Map;
-
import org.onap.policy.apex.model.basicmodel.concepts.AxArtifactKey;
import org.slf4j.ext.XLogger;
import org.slf4j.ext.XLoggerFactory;
@@ -69,6 +69,10 @@ public final class ParameterCheck {
* @return the host name
*/
public static String getHostName(final Map<String, String[]> parameterMap) {
+ if (parameterMap == null) {
+ return null;
+ }
+
if (!parameterMap.containsKey(HOSTNAME_PAR)) {
LOGGER.warn(PARAMETER + HOSTNAME_PAR + NOT_FOUND);
return null;
@@ -76,6 +80,10 @@ public final class ParameterCheck {
final String[] hostNameValue = parameterMap.get(HOSTNAME_PAR);
+ if (hostNameValue == null) {
+ return null;
+ }
+
if (hostNameValue.length == 0 || hostNameValue[0].trim().length() == 0) {
LOGGER.warn("value of parameter \"" + HOSTNAME_PAR + NOT_FOUND);
return null;
@@ -91,6 +99,10 @@ public final class ParameterCheck {
* @return the port
*/
public static int getPort(final Map<String, String[]> parameterMap) {
+ if (parameterMap == null) {
+ return -1;
+ }
+
if (!parameterMap.containsKey(PORT_PAR)) {
LOGGER.warn(PARAMETER + PORT_PAR + NOT_FOUND);
return -1;
@@ -127,6 +139,10 @@ public final class ParameterCheck {
* @return the engine key
*/
public static AxArtifactKey getEngineKey(final Map<String, String[]> parameterMap) {
+ if (parameterMap == null) {
+ return null;
+ }
+
String artifactKeyParameter = null;
for (final String parameter : parameterMap.keySet()) {
// Check for an AxArtifactKey parameter
@@ -147,7 +163,12 @@ public final class ParameterCheck {
return null;
}
- return new AxArtifactKey(axArtifactKeyArray[1]);
+ try {
+ return new AxArtifactKey(axArtifactKeyArray[1]);
+ } catch (Exception apEx) {
+ LOGGER.trace("invalid artifact key ID {}", axArtifactKeyArray[1], apEx);
+ return null;
+ }
}
/**
@@ -159,6 +180,10 @@ public final class ParameterCheck {
*/
public static ParameterCheck.StartStop getStartStop(final Map<String, String[]> parameterMap,
final AxArtifactKey engineKey) {
+ if (parameterMap == null || engineKey == null) {
+ return null;
+ }
+
final String startStopPar = AXARTIFACTKEY_PAR + '#' + engineKey.getId();
if (!parameterMap.containsKey(startStopPar)) {
LOGGER.warn("parameter \"{}\" not found", startStopPar);
@@ -167,6 +192,10 @@ public final class ParameterCheck {
final String[] startStopValue = parameterMap.get(startStopPar);
+ if (startStopValue == null) {
+ return null;
+ }
+
if (startStopValue.length == 0 || startStopValue[0].trim().length() == 0) {
LOGGER.warn("value of parameter \"{}\" not found", startStopPar);
return null;
@@ -193,6 +222,10 @@ public final class ParameterCheck {
* @return The long value
*/
public static long getLong(final Map<String, String[]> parameterMap, final String longName) {
+ if (parameterMap == null || longName == null) {
+ return -1;
+ }
+
if (!parameterMap.containsKey(longName)) {
LOGGER.warn("parameter \"{}\" not found", longName);
return -1;
@@ -200,6 +233,10 @@ public final class ParameterCheck {
final String[] longValue = parameterMap.get(longName);
+ if (longValue == null) {
+ return -1;
+ }
+
if (longValue.length == 0 || longValue[0].trim().length() == 0) {
LOGGER.warn("value of parameter \"{}\" not found", longName);
return -1;