Release version 2.1.1 and roll versions
[sdnc/northbound.git] / vnfapi / provider / src / test / java / org / onap / sdnc / vnfapi / util / VNFSDNSvcLogicServiceClientMockUtil.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                             reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.sdnc.vnfapi.util;
23
24 import org.onap.sdnc.vnfapi.VNFSDNSvcLogicServiceClient;
25 import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
26
27 import java.util.Properties;
28
29 import static org.mockito.Mockito.eq;
30 import static org.mockito.Mockito.isA;
31 import static org.mockito.Mockito.when;
32 import static org.onap.sdnc.vnfapi.util.MDSALUtil.build;
33 import static org.onap.sdnc.vnfapi.util.PropBuilder.propBuilder;
34
35
36 /**
37  * VNFSDNSvcLogicServiceClientMockUtil provides a set of util methods for quickly configuring method
38  * behaviour on the Mock VNFSDNSvcLogicServiceClient
39  */
40 public class VNFSDNSvcLogicServiceClientMockUtil {
41
42
43     private final String MODULE = "VNF-API";
44     private final String MODE = "sync";
45     private final String VERSION = null;
46     private String scvOperation = null;
47
48
49     public final String errorCode = "error-code";
50     public final String errorMessage = "error-message";
51     public final String ackFinal = "ack-final";
52     public final String serviceObjectPath = "service-object-path";
53     public final String networkObjectPath = "network-object-path";
54     public final String networkId = "networkId";
55
56
57     private final VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient;
58
59
60
61     public VNFSDNSvcLogicServiceClientMockUtil(VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient) {
62         this.mockVNFSDNSvcLogicServiceClient = mockVNFSDNSvcLogicServiceClient;
63     }
64
65
66     /** @param scvOperation -  The scvOperation parameter to use on the {@link VNFSDNSvcLogicServiceClient} methods */
67     public void setScvOperation(String scvOperation) {
68         this.scvOperation = scvOperation;
69     }
70
71     /**
72      * Configure {@link VNFSDNSvcLogicServiceClient#hasGraph(String, String, String, String)}
73      * to return the specified value when when invoked with the parameters
74      * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
75      */
76     public void mockHasGraph(Boolean isHasGraph) throws Exception {
77         when(
78                 mockVNFSDNSvcLogicServiceClient
79                         .hasGraph(
80                                 eq(MODULE),
81                                 eq(scvOperation),
82                                 eq(VERSION),
83                                 eq(MODE)
84                         )
85         )
86                 .thenReturn(isHasGraph);
87     }
88
89
90     /**
91      * @return
92      * PropBuilder - A PropBuilder populated with the expected properties returned from
93      * {@link VNFSDNSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
94      */
95     public PropBuilder createExecuteOKResult(){
96         return propBuilder()
97                 .set(errorCode,"200")
98                 .set(errorMessage,"OK")
99                 .set(ackFinal,"Y")
100                 .set(serviceObjectPath,"serviceObjectPath: XYZ")
101                 .set(networkObjectPath,"networkObjectPath: XYZ")
102                 .set(networkId,"networkId: XYZ");
103
104     }
105
106
107     /**
108      * Configure
109      * {@link VNFSDNSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
110      * to return the specified svcResultProp when when invoked with the parameters
111      * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
112      */
113     public void mockExecute(PropBuilder svcResultProp) throws Exception{
114         when(
115                 mockVNFSDNSvcLogicServiceClient
116                         .execute(
117                                 eq(MODULE),
118                                 eq(scvOperation),
119                                 eq(VERSION),
120                                 eq(MODE),
121                                 isA(ServiceDataBuilder.class),
122                                 isA(Properties.class)
123                         )
124         )
125                 .thenReturn(build(
126                         svcResultProp
127                 ));
128     }
129
130 }