73e45080eb80f05e8b6ceefa740433d3a4c8b030
[appc.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
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
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.appc.interfaceService.serviceExecutor;
23
24 import static org.junit.Assert.*;
25
26 import org.junit.Test;
27 import org.onap.appc.interfaces.service.executor.RequestValidator;
28
29 public class TestRequestValidator {
30
31     @Test(expected = Exception.class)
32     public void TestRequestDataException() throws Exception{
33         String action ="";
34         String requestData ="";
35         String requestDataType = "";
36         RequestValidator.validate(action, requestData, requestDataType);
37     }
38
39     @Test(expected = Exception.class)
40     public void TestVNFDataException() throws Exception{
41         String action ="";
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);
45     }
46
47     @Test(expected = Exception.class)
48     public void TestCRException() throws Exception{
49         String action ="";
50         String requestData = "{\"vnf-id\":\"\"}";
51         String requestDataType = "";
52         RequestValidator.validate(action, requestData, requestDataType);
53     }
54
55     @Test(expected = Exception.class)
56     public void TestCRequestAction() throws Exception{
57         String action ="";
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);
61     }
62
63     @Test(expected = Exception.class)
64     public void TestCRequestActionIdentifier() throws Exception{
65         String action ="";
66         String requestData = "{\"vnf-id\":\"\",\"current-request\" :{\"action\" : \"Audit\"}}}}";
67         String requestDataType = "";
68         RequestValidator.validate(action, requestData, requestDataType);
69     }
70
71     @Test
72     public void TestCRequest() throws Exception{
73         String action ="";
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);
77     }
78 }