2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 IBM
6 * =============================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.appc.interfaceService.serviceExecutor;
24 import static org.junit.Assert.*;
26 import org.junit.Test;
27 import org.onap.appc.interfaces.service.executor.RequestValidator;
29 public class TestRequestValidator {
31 @Test(expected = Exception.class)
32 public void TestRequestDataException() throws Exception{
34 String requestData ="";
35 String requestDataType = "";
36 RequestValidator.validate(action, requestData, requestDataType);
39 @Test(expected = Exception.class)
40 public void TestVNFDataException() throws Exception{
42 String requestData = "{\"current-request\" :{\"action\" : \"Audit\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id\",\"vnf-id\" : \"vnf-id\",\"vnfc-name\" : \"vnfc-name\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id\"}},\"in-progress-requests\" :[{\"action\" : \"HealthCheck\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id1\",\"vnf-id\" : \"vnf-id1\",\"vnfc-name\" : \"vnfc-name1\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id1\"}},{\"action\" : \"CheckLock\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id2\",\"vnf-id\" : \"vnf-id2\",\"vnfc-name\" : \"vnfc-name2\",\"vf-module-id\" : \"vf-module-id2\",\"vserver-id\": \"vserver-id2\"}}]}";
43 String requestDataType = "";
44 RequestValidator.validate(action, requestData, requestDataType);
47 @Test(expected = Exception.class)
48 public void TestCRException() throws Exception{
50 String requestData = "{\"vnf-id\":\"\"}";
51 String requestDataType = "";
52 RequestValidator.validate(action, requestData, requestDataType);
55 @Test(expected = Exception.class)
56 public void TestCRequestAction() throws Exception{
58 String requestData = "{\"vnf-id\":\"\",\"current-request\" :{\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id\",\"vnf-id\" : \"vnf-id\",\"vnfc-name\" : \"vnfc-name\",\"vf-module-id\" : \"vf-module-id\",\"vserver-id\": \"vserver-id\"}}}}";
59 String requestDataType = "";
60 RequestValidator.validate(action, requestData, requestDataType);
63 @Test(expected = Exception.class)
64 public void TestCRequestActionIdentifier() throws Exception{
66 String requestData = "{\"vnf-id\":\"\",\"current-request\" :{\"action\" : \"Audit\"}}}}";
67 String requestDataType = "";
68 RequestValidator.validate(action, requestData, requestDataType);
72 public void TestCRequest() throws Exception{
74 String requestData = "{\"vnf-id\":\"\",\"current-request\" :{\"action\" : \"Audit\",\"action-identifiers\" : {\"service-instance-id\" : \"service-instance-id\"}}}}";
75 String requestDataType = "";
76 RequestValidator.validate(action, requestData, requestDataType);