aboutsummaryrefslogtreecommitdiffstats
path: root/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util
diff options
context:
space:
mode:
Diffstat (limited to 'vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util')
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java94
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java113
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java62
-rw-r--r--vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java130
4 files changed, 0 insertions, 399 deletions
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java
deleted file mode 100644
index 352e9404..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/DataBrokerUtil.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.sdnc.vnfapi.util;
-
-import com.google.common.base.Optional;
-import com.google.common.util.concurrent.CheckedFuture;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
-import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.Vnfs;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfList;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfListKey;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-
-/**
- * This util class provides utility to read and write {@link VnfList} data objects from the {@link DataBroker}
- *
- */
-public class DataBrokerUtil {
-
-
- private final DataBroker dataBroker;
-
- public DataBrokerUtil(DataBroker dataBroker) {
- this.dataBroker = dataBroker;
- }
-
- /** @return VnfList - the VnfList object read from the DataBroker or null if none was found */
- public VnfList read(String VnfListKey, LogicalDatastoreType logicalDatastoreType) throws Exception {
- InstanceIdentifier VnfListInstanceIdentifier = InstanceIdentifier.<Vnfs>builder(Vnfs.class)
- .child(VnfList.class, new VnfListKey(VnfListKey)).build();
- ReadOnlyTransaction readTx = dataBroker.newReadOnlyTransaction();
- Optional<VnfList> data = (Optional<VnfList>) readTx.read(logicalDatastoreType, VnfListInstanceIdentifier).get();
- if(!data.isPresent()){
- return null;
- }
- return data.get();
- }
-
-
- /**
- * Write the {@link VnfList} object to the {@link DataBroker}
- * @param isReplace - false specifies the new data is to be merged into existing data, where as true cause the
- * existing data to be replaced.
- * @param VnfList - the {@link VnfList} data object to be presisted in the db.
- * @param logicalDatastoreType - The logicalDatastoreType
- */
- public void write(boolean isReplace,VnfList VnfList, LogicalDatastoreType logicalDatastoreType) throws Exception {
- // Each entry will be identifiable by a unique key, we have to create that
- // identifier
- InstanceIdentifier.InstanceIdentifierBuilder<VnfList> VnfListBuilder = InstanceIdentifier
- .<Vnfs>builder(Vnfs.class).child(VnfList.class, VnfList.key());
- InstanceIdentifier<VnfList> path = VnfListBuilder.build();
-
- WriteTransaction tx = dataBroker.newWriteOnlyTransaction();
- if (!isReplace) {
- tx.merge(logicalDatastoreType, path, VnfList);
- } else {
- tx.put(logicalDatastoreType, path, VnfList);
- }
- CheckedFuture<Void,TransactionCommitFailedException> cf = tx.submit();
- cf.checkedGet();
-
- }
-
-
-
-
-
-
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java
deleted file mode 100644
index b28139c7..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/MDSALUtil.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.sdnc.vnfapi.util;
-
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationInputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.VnfTopologyOperationOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.sdnc.request.header.SdncRequestHeaderBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.information.ServiceInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.information.VnfInformationBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.model.infrastructure.VnfListBuilder;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.vnf.request.information.VnfRequestInformationBuilder;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-
-import java.util.concurrent.Future;
-import java.util.function.Consumer;
-import java.util.function.Function;
-
-
-/**
- * This uill class provides utility to build yang objects using a recursive syntax that resembles the tree structure
- * when defining the same yang object in json format.
- *
- * For Example
- * <pre>
- * {@code
- * import static org.onap.sdnc.northbound.util.MDSALUtil.*;
- * VnfTopologyOperationInput input = build(vnfTopologyOperationInput()
- * .setServiceInformation(
- * build(serviceInformation()
- * .setServiceId("serviceId: xyz")
- * .setServiceInstanceId("serviceInstanceId: xyz")
- * .setServiceType("serviceType: xyz")
- * .setSubscriberName("subscriberName: xyz")
- * )
- * )
- * .setVnfRequestInformation(
- * build(vnfRequestInformation()
- * .setVnfId("vnfId: xyz")
- * .setVnfName("vnfName: xyz")//defect if missing
- * .setVnfType("vnfType: xyz")//defect if missing
- * )
- * )
- * .setSdncRequestHeader(
- * build(sdncRequestHeader()
- * .setSvcAction(SvcAction.Delete)
- * )
- * )
- * );
- * );
- * }
- * </pre>
- */
-public class MDSALUtil {
-
- public static VnfTopologyOperationInputBuilder vnfTopologyOperationInput(){return new VnfTopologyOperationInputBuilder();}
- public static VnfTopologyOperationOutputBuilder vnfTopologyOperationOutput(){return new VnfTopologyOperationOutputBuilder();}
-
- public static ServiceInformationBuilder serviceInformation(){return new ServiceInformationBuilder();}
- public static VnfRequestInformationBuilder vnfRequestInformation(){return new VnfRequestInformationBuilder();}
- public static VnfListBuilder vnfList(){return new VnfListBuilder();}
- public static ServiceDataBuilder serviceData() { return new ServiceDataBuilder();}
- public static SdncRequestHeaderBuilder sdncRequestHeader(){return new SdncRequestHeaderBuilder();}
- public static VnfInformationBuilder vnfInformation(){return new VnfInformationBuilder();}
-
-
- public static <P> P build(Builder<P> b) {
- return b == null? null :b.build();
- }
-
- public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject){
- if(sourceDataObject == null){
- return null;
- }
- B bp = builderConstructor.apply(sourceDataObject);
- return bp.build();
- }
-
- public static <P,B extends Builder<P>> P build(Function<P,B> builderConstructor,P sourceDataObject,Consumer<B> builder){
- if(sourceDataObject == null){
- return null;
- }
- B bp = builderConstructor.apply(sourceDataObject);
- builder.accept(bp);
- return bp.build();
- }
-
- public static <I,O> O exec(Function<I,Future<RpcResult<O>>> rpc,I rpcParameter,Function<RpcResult<O>,O> rpcResult) throws Exception {
- Future<RpcResult<O>> future = rpc.apply(rpcParameter);
- return rpcResult.apply(future.get());
- }
-
-}
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java
deleted file mode 100644
index 6ecc94c8..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/PropBuilder.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.sdnc.vnfapi.util;
-
-import org.opendaylight.yangtools.concepts.Builder;
-
-import java.util.Properties;
-
-/**
- * A Util class that adds method chaining to the {@link #set(String, String)} to reducing the syntax needed to populate
- * {@link Properties}
- */
-public class PropBuilder implements Builder<Properties> {
-
-
- final Properties prop;
-
- public PropBuilder(Properties prop) {
- this.prop = prop;
- }
-
- public PropBuilder() {
- this.prop = new Properties();
- }
-
- public Properties build(){
- return prop;
- }
-
- public PropBuilder set(String key, String value) {
- prop.setProperty(key, value);
- return this;
- }
-
- public String get(String key) {
- return prop.getProperty(key);
- }
-
-
- public static PropBuilder propBuilder(){
- return (new PropBuilder());
- }
-} \ No newline at end of file
diff --git a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java b/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java
deleted file mode 100644
index d4d94ca8..00000000
--- a/vnfapi/provider/src/test/java/org/onap/sdnc/vnfapi/util/VNFSDNSvcLogicServiceClientMockUtil.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * openECOMP : SDN-C
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights
- * reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.sdnc.vnfapi.util;
-
-import org.onap.sdnc.vnfapi.VNFSDNSvcLogicServiceClient;
-import org.opendaylight.yang.gen.v1.org.onap.sdnctl.vnf.rev150720.service.data.ServiceDataBuilder;
-
-import java.util.Properties;
-
-import static org.mockito.Mockito.eq;
-import static org.mockito.Mockito.isA;
-import static org.mockito.Mockito.when;
-import static org.onap.sdnc.vnfapi.util.MDSALUtil.build;
-import static org.onap.sdnc.vnfapi.util.PropBuilder.propBuilder;
-
-
-/**
- * VNFSDNSvcLogicServiceClientMockUtil provides a set of util methods for quickly configuring method
- * behaviour on the Mock VNFSDNSvcLogicServiceClient
- */
-public class VNFSDNSvcLogicServiceClientMockUtil {
-
-
- private final String MODULE = "VNF-API";
- private final String MODE = "sync";
- private final String VERSION = null;
- private String scvOperation = null;
-
-
- public final String errorCode = "error-code";
- public final String errorMessage = "error-message";
- public final String ackFinal = "ack-final";
- public final String serviceObjectPath = "service-object-path";
- public final String networkObjectPath = "network-object-path";
- public final String networkId = "networkId";
-
-
- private final VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient;
-
-
-
- public VNFSDNSvcLogicServiceClientMockUtil(VNFSDNSvcLogicServiceClient mockVNFSDNSvcLogicServiceClient) {
- this.mockVNFSDNSvcLogicServiceClient = mockVNFSDNSvcLogicServiceClient;
- }
-
-
- /** @param scvOperation - The scvOperation parameter to use on the {@link VNFSDNSvcLogicServiceClient} methods */
- public void setScvOperation(String scvOperation) {
- this.scvOperation = scvOperation;
- }
-
- /**
- * Configure {@link VNFSDNSvcLogicServiceClient#hasGraph(String, String, String, String)}
- * to return the specified value when when invoked with the parameters
- * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
- */
- public void mockHasGraph(Boolean isHasGraph) throws Exception {
- when(
- mockVNFSDNSvcLogicServiceClient
- .hasGraph(
- eq(MODULE),
- eq(scvOperation),
- eq(VERSION),
- eq(MODE)
- )
- )
- .thenReturn(isHasGraph);
- }
-
-
- /**
- * @return
- * PropBuilder - A PropBuilder populated with the expected properties returned from
- * {@link VNFSDNSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
- */
- public PropBuilder createExecuteOKResult(){
- return propBuilder()
- .set(errorCode,"200")
- .set(errorMessage,"OK")
- .set(ackFinal,"Y")
- .set(serviceObjectPath,"serviceObjectPath: XYZ")
- .set(networkObjectPath,"networkObjectPath: XYZ")
- .set(networkId,"networkId: XYZ");
-
- }
-
-
- /**
- * Configure
- * {@link VNFSDNSvcLogicServiceClient#execute(String, String, String, String, ServiceDataBuilder, Properties)}
- * to return the specified svcResultProp when when invoked with the parameters
- * {@link #MODULE}, {@link #MODE}, {@link #VERSION} and {@link #scvOperation}
- */
- public void mockExecute(PropBuilder svcResultProp) throws Exception{
- when(
- mockVNFSDNSvcLogicServiceClient
- .execute(
- eq(MODULE),
- eq(scvOperation),
- eq(VERSION),
- eq(MODE),
- isA(ServiceDataBuilder.class),
- isA(Properties.class)
- )
- )
- .thenReturn(build(
- svcResultProp
- ));
- }
-
-}