aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvidhyasree <sn141y@att.com>2018-05-31 23:49:10 -0400
committerPatrick Brady <pb071s@att.com>2018-06-01 22:03:23 +0000
commit6f44e217b73e2eca6abd00ffabb67e1aa4fca237 (patch)
tree2a40546c099feb5ba68ee87d1bce2277404fdae9
parentf52f019fc49a37a68c285af6d5d289f4322819f4 (diff)
ConfigScaleOut-Payload parameter to manadatory
Issue-ID: APPC-929 Change-Id: Ifd0b8f303dd77acbf37774f749b9063dc67e7620 Signed-off-by: vidhyasree <sn141y@att.com>
-rw-r--r--appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java19
-rw-r--r--appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ConfigScaleOutServiceTest.java13
-rw-r--r--appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang2
3 files changed, 22 insertions, 12 deletions
diff --git a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java
index 86699e6ba..e656aed2e 100644
--- a/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java
+++ b/appc-provider/appc-provider-bundle/src/main/java/org/onap/appc/provider/lcm/service/ConfigScaleOutService.java
@@ -41,6 +41,7 @@ public class ConfigScaleOutService extends AbstractBaseService {
super(Action.ConfigScaleOut);
logger.debug("ConfigScaleOutService starts");
}
+
public ConfigScaleOutOutputBuilder process(ConfigScaleOutInput input) {
CommonHeader commonHeader = input.getCommonHeader();
ActionIdentifiers actionIdentifiers = input.getActionIdentifiers();
@@ -48,7 +49,7 @@ public class ConfigScaleOutService extends AbstractBaseService {
validate(commonHeader, input.getAction(), actionIdentifiers, payload);
if (status == null) {
- proceedAction(commonHeader,actionIdentifiers,payload);
+ proceedAction(commonHeader, actionIdentifiers, payload);
}
ConfigScaleOutOutputBuilder outputBuilder = new ConfigScaleOutOutputBuilder();
@@ -69,14 +70,14 @@ public class ConfigScaleOutService extends AbstractBaseService {
// validate payload
String keyName = "payload";
-// if (payload == null) {
-// status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
-// return;
-// }
- if (payload !=null) {
+ if (payload == null) {
+ status = buildStatusForParamName(LCMCommandStatus.MISSING_MANDATORY_PARAMETER, keyName);
+ return;
+ }
+// if (payload !=null) {
String payloadString = payload.getValue();
status = validateMustHaveParamValue(
- payloadString == null ? payloadString : payloadString.trim(), "payload");
+ payloadString == null ? payloadString : payloadString.trim(), "payload");
if (status != null) {
return;
}
@@ -84,12 +85,14 @@ public class ConfigScaleOutService extends AbstractBaseService {
try {
Map<String, String> payloadMap = JsonUtil.convertJsonStringToFlatMap(payloadString);
validateMustHaveParamValue(payloadMap.get(keyName), keyName);
+ validateMustHaveParamValue(payloadMap.get("payload.request-parameters.vf-module-id"), "vf-module-id");
} catch (IOException e) {
logger.error(String.format("ConfigScaleOutService (%s) got IOException when converting payload", rpcName), e);
status = buildStatusForErrorMsg(LCMCommandStatus.UNEXPECTED_ERROR, e.getMessage());
}
}
- }
+
+// }
void proceedAction(CommonHeader commonHeader,
ActionIdentifiers actionIdentifiers,
diff --git a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ConfigScaleOutServiceTest.java b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ConfigScaleOutServiceTest.java
index e46bb91ba..bb5e953a0 100644
--- a/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ConfigScaleOutServiceTest.java
+++ b/appc-provider/appc-provider-bundle/src/test/java/org/onap/appc/provider/lcm/service/ConfigScaleOutServiceTest.java
@@ -30,6 +30,7 @@ import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.internal.util.reflection.Whitebox;
import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.appc.util.JsonUtil;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.*;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.action.identifiers.ActionIdentifiers;
import org.opendaylight.yang.gen.v1.org.onap.appc.lcm.rev160108.common.header.CommonHeader;
@@ -39,6 +40,8 @@ import org.onap.appc.executor.objects.LCMCommandStatus;
import org.onap.appc.requesthandler.objects.RequestHandlerOutput;
import org.onap.appc.requesthandler.objects.RequestHandlerInput;
+import java.util.Map;
+
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
@@ -56,6 +59,7 @@ public class ConfigScaleOutServiceTest {
private ConfigScaleOutService configscaleoutServiceAction;
@Before
public void setUp() throws Exception {
+
configscaleoutServiceAction = spy(new ConfigScaleOutService());
}
@@ -149,20 +153,23 @@ public class ConfigScaleOutServiceTest {
configscaleoutServiceAction.validate(mockCommonHeader, Action.ConfigScaleOut, mockAI, null);
Mockito.verify(configscaleoutServiceAction, times(1)).validateExcludedActIds(any(), any());
status = (Status) Whitebox.getInternalState(configscaleoutServiceAction, "status");
- Assert.assertTrue("Should skip Payload",true);
+ Assert.assertEquals("should return missing parameter",
+ Integer.valueOf(LCMCommandStatus.MISSING_MANDATORY_PARAMETER.getResponseCode()), status.getCode());
// test empty payload
Mockito.doReturn("").when(mockPayload).getValue();
configscaleoutServiceAction.validate(mockCommonHeader, Action.ConfigScaleOut, mockAI, mockPayload);
status = (Status) Whitebox.getInternalState(configscaleoutServiceAction, "status");
- Assert.assertTrue("Should skip Payload",true);
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
// test space payload
Mockito.doReturn(" ").when(mockPayload).getValue();
configscaleoutServiceAction.validate(mockCommonHeader, Action.ConfigScaleOut, mockAI, mockPayload);
status = (Status) Whitebox.getInternalState(configscaleoutServiceAction, "status");
- Assert.assertTrue("Should skip Payload",true);
+ Assert.assertEquals("should return invalid parameter",
+ Integer.valueOf(LCMCommandStatus.INVALID_INPUT_PARAMETER.getResponseCode()), status.getCode());
}
}
diff --git a/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang b/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang
index 5ff992a08..2ef9e5438 100644
--- a/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang
+++ b/appc-provider/appc-provider-model/src/main/yang/appc-provider-lcm.yang
@@ -786,7 +786,7 @@ module appc-provider-lcm {
uses action-identifiers;
leaf payload {
type payload;
- mandatory false;
+ mandatory true;
}
}
output {