2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package org.onap.sdnc.northbound.util;
24 import org.onap.sdnc.northbound.GenericResourceApiSvcLogicServiceClient;
25 import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
27 import java.util.Properties;
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.northbound.util.MDSALUtil.build;
33 import static org.onap.sdnc.northbound.util.PropBuilder.propBuilder;
37 * GenericResourceApiSvcLogicServiceClientMockUtil provides a set of util methods for quickly configuring method
38 * behaviour on the Mock GenericResourceApiSvcLogicServiceClient
40 public class GenericResourceApiSvcLogicServiceClientMockUtil {
43 private final String MODULE = "generic-resource-api";
44 private final String MODE = "sync";
45 private final String VERSION = null;
46 private String scvOperation = null;
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";
57 private final GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient;
61 public GenericResourceApiSvcLogicServiceClientMockUtil(GenericResourceApiSvcLogicServiceClient mockGenericResourceApiSvcLogicServiceClient) {
62 this.mockGenericResourceApiSvcLogicServiceClient = mockGenericResourceApiSvcLogicServiceClient;
66 /** @param scvOperation - The scvOperation parameter to use on the {@link GenericResourceApiSvcLogicServiceClient} methods */
67 public void setScvOperation(String scvOperation) {
68 this.scvOperation = scvOperation;
72 * Configure {@link GenericResourceApiSvcLogicServiceClient#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}
76 public void mockHasGraph(Boolean isHasGraph) throws Exception {
78 mockGenericResourceApiSvcLogicServiceClient
86 .thenReturn(isHasGraph);
92 * PropBuilder - A PropBuilder populated with the expected properties returned from
93 * {@link GenericResourceApiSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
95 public PropBuilder createExecuteOKResult(){
98 .set(errorMessage,"OK")
100 .set(serviceObjectPath,"serviceObjectPath: XYZ")
101 .set(networkObjectPath,"networkObjectPath: XYZ")
102 .set(networkId,"networkId: XYZ");
109 * {@link GenericResourceApiSvcLogicServiceClient#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}
113 public void mockExecute(PropBuilder svcResultProp) throws Exception{
115 mockGenericResourceApiSvcLogicServiceClient
121 isA(ServiceDataBuilder.class),
122 isA(Properties.class)