Junit for APPC for Network Client
[appc.git] / appc-outbound / appc-network-inventory-client / provider / src / test / java / org / openecomp / appc / instar / interfaceImpl / TestInstarResponseHandlerImpl.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24
25 package org.openecomp.appc.instar.interfaceImpl;
26
27 import org.junit.Test;
28 import org.openecomp.sdnc.config.params.data.ResponseKey;
29 import org.openecomp.sdnc.sli.SvcLogicContext;
30
31 public class TestInstarResponseHandlerImpl {
32
33     @Test
34     public void testProcessResponseForIpv4(){
35         ResponseKey resKey = new ResponseKey();
36         resKey.setUniqueKeyValue("x");
37         SvcLogicContext svc = new SvcLogicContext();
38         svc.setAttribute("vnf-name", "fqdn");
39         resKey.setFieldKeyName("ipaddress-v4");
40         String instarKey = "key";
41         String instarRes ="{\"vnfConfigurationParameterDetails\":"
42                 + "[{\"fqdn\":\"fqdnx\",\"v4IPAddress\":\"value2\"}]}";
43         InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
44         impl.processResponse(instarRes, instarKey);
45     }    
46
47     @Test
48     public void testProcessResponseForIpv6(){
49         ResponseKey resKey = new ResponseKey();
50         resKey.setUniqueKeyValue("x");
51         SvcLogicContext svc = new SvcLogicContext();
52         svc.setAttribute("vnf-name", "fqdn");
53         resKey.setFieldKeyName("ipaddress-v6");
54         String instarKey = "key";
55         String instarRes ="{\"vnfConfigurationParameterDetails\":"
56                 + "[{\"fqdn\":\"fqdnx\",\"v6IPAddress\":\"value2\"}]}";
57         InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
58         impl.processResponse(instarRes, instarKey);
59     }
60     
61     @Test
62     public void testProcessResponseInstarKeyValues(){
63         
64         ResponseKey resKey = new ResponseKey();
65         resKey.setUniqueKeyValue("x");
66         String json ="{\"vnfConfigurationParameterDetails\":"
67                 + "[{\"fqdn\":\"fqdnx\",\"v4IPAddress\":\"value2\"}]}";
68         SvcLogicContext svc = new SvcLogicContext();
69         svc.setAttribute("vnf-name", "fqdn");
70         svc.setAttribute("INSTAR-KEY-VALUES", json);
71         resKey.setFieldKeyName("ipaddress-v6");
72         String instarKey = "key";
73         String instarRes ="{\"vnfConfigurationParameterDetails\":"
74                 + "[{\"fqdn\":\"fqdnx\",\"v6IPAddress\":\"value2\"}]}";
75         InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
76         impl.processResponse(instarRes, instarKey);
77     }
78 }