summaryrefslogtreecommitdiffstats
path: root/generic-resource-api/provider
diff options
context:
space:
mode:
Diffstat (limited to 'generic-resource-api/provider')
-rw-r--r--generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java43
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java99
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java193
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java272
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java18
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java8
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java13
-rw-r--r--generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java25
8 files changed, 532 insertions, 139 deletions
diff --git a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
index 13b02f95..099d723c 100644
--- a/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
+++ b/generic-resource-api/provider/src/main/java/org/onap/sdnc/northbound/GenericResourceApiProvider.java
@@ -786,7 +786,11 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty("vnf-object-path");
+
+ //FIXME if needed
+ /*before was "vfn-object-path", but it didn't make sense, since everywhere else,
+ when extracting service object path the "service-object-path" property is used*/
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
}
setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
@@ -1016,7 +1020,12 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
- serviceObjectPath = respProps.getProperty("vf-module-object-path");
+
+
+ //FIXME if needed
+ /*before was "vf-module-object-path", but it didnt make sense, since everywhere else,
+ when extracting service object path the "service-object-path" property is used*/
+ serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
}
setServiceStatus(serviceStatusBuilder, responseObject.getStatusCode(), responseObject.getMessage(), ackFinal);
@@ -1526,7 +1535,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
Properties respProps = null;
- ResponseObject error = new ResponseObject("200", "");
+ ResponseObject responseObject = new ResponseObject("200", "");
String ackFinal = "Y";
String allottedResourceId = ERROR_NETWORK_ID;
String serviceObjectPath = null;
@@ -1539,31 +1548,31 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
respProps = svcLogicClient.execute(APP_NAME, svcOperation, null, "sync", serviceDataBuilder, parms);
} catch (Exception e) {
log.error(SERVICE_LOGIC_EXECUTION_ERROR_MESSAGE, svcOperation, e);
- error.setMessage(e.getMessage());
- error.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
}
} else {
- error.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
- error.setStatusCode("503");
+ responseObject.setMessage(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + svcOperation + "'");
+ responseObject.setStatusCode("503");
}
} catch (Exception e) {
- error.setStatusCode("500");
- error.setMessage(e.getMessage());
+ responseObject.setStatusCode("500");
+ responseObject.setMessage(e.getMessage());
log.error(SERVICE_LOGIC_SEARCH_ERROR_MESSAGE, e);
}
if (respProps != null) {
- error.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
- error.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
+ responseObject.setStatusCode(respProps.getProperty(ERROR_CODE_PARAM));
+ responseObject.setMessage(respProps.getProperty(ERROR_MESSAGE_PARAM));
ackFinal = respProps.getProperty(ACK_FINAL_PARAM, "Y");
allottedResourceId = respProps.getProperty(ALLOTTED_RESOURCE_ID_PARAM);
serviceObjectPath = respProps.getProperty(SERVICE_OBJECT_PATH_PARAM);
securityZoneObjectPath = respProps.getProperty("security-zone-object-path");
}
- if (failed(error)) {
- responseBuilder.setResponseCode(error.getStatusCode());
- responseBuilder.setResponseMessage(error.getMessage());
+ if (failed(responseObject)) {
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
+ responseBuilder.setResponseMessage(responseObject.getMessage());
responseBuilder.setAckFinalIndicator(ackFinal);
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1603,7 +1612,7 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
} catch (IllegalStateException e) {
log.error(UPDATING_MDSAL_ERROR_MESSAGE, svcOperation, siid, e);
responseBuilder.setResponseCode("500");
- responseBuilder.setResponseMessage(e.toString());
+ responseBuilder.setResponseMessage(e.getMessage());
responseBuilder.setAckFinalIndicator("Y");
log.error(RETURNED_FAILED_MESSAGE, svcOperation, siid, responseBuilder.build());
@@ -1616,9 +1625,9 @@ public class GenericResourceApiProvider implements AutoCloseable, GENERICRESOURC
}
// Update succeeded
- responseBuilder.setResponseCode(error.getStatusCode());
+ responseBuilder.setResponseCode(responseObject.getStatusCode());
responseBuilder.setAckFinalIndicator(ackFinal);
- trySetResponseMessage(responseBuilder, error);
+ trySetResponseMessage(responseBuilder, responseObject);
log.info(UPDATED_MDSAL_INFO_MESSAGE, svcOperation, siid);
log.info(RETURNED_SUCCESS_MESSAGE, svcOperation, siid, responseBuilder.build());
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java
index d3513f70..55b7db44 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ContrailRouteTopologyOperationRPCTest.java
@@ -8,12 +8,18 @@ import static org.onap.sdnc.northbound.GenericResourceApiProvider.INVALID_INPUT_
import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.contrailRouteResponseInformation;
import static org.onap.sdnc.northbound.util.MDSALUtil.contrailRouteTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.contrailRouteTopologyOperationOutput;
import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
import static org.onap.sdnc.northbound.util.MDSALUtil.service;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceData;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceLevelOperStatus;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
import java.time.Instant;
import org.junit.Before;
@@ -32,6 +38,10 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastOrderStatus;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastRpcAction;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.OrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformation;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.Service;
import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -65,6 +75,10 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
public void should_fail_when_invalid_service_data() throws Exception {
ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
.setServiceInformation(build(serviceInformationBuilder()
.setServiceInstanceId("test-service-instance-id")
))
@@ -86,6 +100,10 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
svcClient.mockExecute(new RuntimeException("test exception"));
ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
.setServiceInformation(build(serviceInformationBuilder()
.setServiceInstanceId("test-service-instance-id")
))
@@ -107,6 +125,10 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
svcClient.mockHasGraph(false);
ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
.setServiceInformation(build(serviceInformationBuilder()
.setServiceInstanceId("test-service-instance-id")
))
@@ -136,6 +158,10 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
genericResourceApiProvider.setDataBroker(spyDataBroker);
ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
.setServiceInformation(build(serviceInformationBuilder()
.setServiceInstanceId("test-service-instance-id")
))
@@ -152,6 +178,47 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
}
+ @Test
+ public void should_success_when_no_errors_encountered() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcResultProp.set("contrail-route-object-path", "contrailRouteObjectPath: XYZ");
+ svcClient.mockExecute(svcResultProp);
+
+ ContrailRouteTopologyOperationInput input = build(contrailRouteTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ Service service = persistServiceInDataBroker(input);
+
+ ContrailRouteTopologyOperationOutput output =
+ exec(genericResourceApiProvider::contrailRouteTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ ContrailRouteTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+
+ Service actualService = db
+ .read(input.getServiceInformation().getServiceInstanceId(), LogicalDatastoreType.CONFIGURATION);
+
+ Service expectedService = createExpectedService(input, service.getServiceData());
+ assertEquals(expectedService, actualService);
+ }
+
private Service persistServiceInDataBroker(ContrailRouteTopologyOperationInput input) throws Exception {
Service service = build(service()
@@ -160,7 +227,7 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
.setServiceLevelOperStatus(build(serviceLevelOperStatus()
.setOrderStatus(OrderStatus.Created)
.setModifyTimestamp(Instant.now().toString())
- .setLastSvcRequestId("svc-request-id: abc")
+ .setLastSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
.setLastRpcAction(LastRpcAction.Activate)
.setLastOrderStatus(LastOrderStatus.PendingAssignment)
.setLastAction(LastAction.ActivateNetworkInstance)
@@ -171,4 +238,34 @@ public class ContrailRouteTopologyOperationRPCTest extends GenericResourceApiPro
db.write(true, service, LogicalDatastoreType.CONFIGURATION);
return service;
}
+
+ private ContrailRouteTopologyOperationOutput createExpectedOutput(PropBuilder propBuilder,
+ ContrailRouteTopologyOperationInput input) {
+
+ return build(contrailRouteTopologyOperationOutput()
+ .setContrailRouteResponseInformation(build(contrailRouteResponseInformation()
+ .setObjectPath(propBuilder.get("contrail-route-object-path"))))
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+
+ private Service createExpectedService(
+ ContrailRouteTopologyOperationInput expectedInput, ServiceData expectedServiceData) {
+
+ ServiceInformation expectedServiceInformation = expectedInput.getServiceInformation();
+
+ return build(service()
+ .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
+ .setServiceData(build(serviceData()))
+ .setServiceData(expectedServiceData)
+ .setServiceStatus(build(serviceStatus()))
+ );
+ }
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java
index 5688f578..29436415 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/NetworkTopologyOperationRPCTest.java
@@ -42,8 +42,6 @@ import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceLevelOperStatus;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
-import static org.onap.sdnc.northbound.util.MDSALUtil.vnfInformationBuilder;
-import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyOperationInput;
import static org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastAction;
import static org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastOrderStatus;
import static org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastRpcAction;
@@ -62,8 +60,6 @@ import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionChainClosedException;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInput;
-import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutput;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
@@ -194,8 +190,8 @@ public class NetworkTopologyOperationRPCTest extends GenericResourceApiProviderT
}
/**
- * Verify ServiceTopologyOperation RPC executes a DG then produces the expected
- * {@link NetworkTopologyOperationOutput} and persisted the expected {@link Service} in the {@link DataBroker}
+ * Verify ServiceTopologyOperation RPC executes a DG then produces the expected {@link
+ * NetworkTopologyOperationOutput} and persisted the expected {@link Service} in the {@link DataBroker}
*/
@Test
public void should_success_when_no_errors_encountered() throws Exception {
@@ -205,155 +201,146 @@ public class NetworkTopologyOperationRPCTest extends GenericResourceApiProviderT
PropBuilder svcResultProp = svcClient.createExecuteOKResult();
svcClient.mockExecute(svcResultProp);
-
//construct the input parameter for the NetworkTopologyOperation
- NetworkTopologyOperationInput networkTopologyOperationInput = createNTOI();
-
+ NetworkTopologyOperationInput input = createNTOI();
//pre-populate the DataBroke with the required ServiceData.
- Service service = persistServiceInDataBroker(networkTopologyOperationInput);
-
-
+ Service service = persistServiceInDataBroker(input);
//execute the mdsal exec
- NetworkTopologyOperationOutput actualNetworkTopologyOperationOutput = exec(
- genericResourceApiProvider::networkTopologyOperation
- , networkTopologyOperationInput
- , RpcResult::getResult
+ NetworkTopologyOperationOutput output = exec(
+ genericResourceApiProvider::networkTopologyOperation
+ , input
+ , RpcResult::getResult
);
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
//verify the returned NetworkTopologyOperationOutput
NetworkTopologyOperationOutput expectedNetworkTopologyOperationOutput
- = createExpectedNTOO(svcResultProp,networkTopologyOperationInput);
- assertEquals(expectedNetworkTopologyOperationOutput,actualNetworkTopologyOperationOutput);
-
+ = createExpectedNTOO(svcResultProp, input);
+ assertEquals(expectedNetworkTopologyOperationOutput, output);
//verify the persisted Service
Service actualService = db.read(
- networkTopologyOperationInput.getServiceInformation().getServiceInstanceId(),
- LogicalDatastoreType.CONFIGURATION
+ input.getServiceInformation().getServiceInstanceId(),
+ LogicalDatastoreType.CONFIGURATION
);
Service expectedService = createExpectedService(
- expectedNetworkTopologyOperationOutput,
- networkTopologyOperationInput,
- service.getServiceData(),
- actualService);
- assertEquals(expectedService,actualService);
+ expectedNetworkTopologyOperationOutput,
+ input,
+ service.getServiceData(),
+ actualService);
+ assertEquals(expectedService, actualService);
}
- private NetworkTopologyOperationInput createNTOI()
- {
+ private NetworkTopologyOperationInput createNTOI() {
return build(
- networkTopologyOperationInput()
- .setSdncRequestHeader(build(sdncRequestHeader()
- .setSvcRequestId("svc-request-id: xyz")
- .setSvcAction(SvcAction.Assign)
- ))
- .setRequestInformation(build(requestInformation()
- .setRequestId("request-id: xyz")
- .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
- ))
- .setServiceInformation(build(serviceInformationBuilder()
- .setServiceInstanceId("service-instance-id: xyz")
- ))
- .setNetworkInformation(build(
- networkInformation()
- ))
+ networkTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("svc-request-id: xyz")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("request-id: xyz")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("service-instance-id: xyz")
+ ))
+ .setNetworkInformation(build(
+ networkInformation()
+ ))
);
}
private Service persistServiceInDataBroker(
- NetworkTopologyOperationInput networkTopologyOperationInput
- ) throws Exception{
+ NetworkTopologyOperationInput networkTopologyOperationInput
+ ) throws Exception {
Service service = build(
- service()
- .setServiceInstanceId(
- networkTopologyOperationInput.getServiceInformation().getServiceInstanceId()
- )
- .setServiceData(build(
- serviceData()
- .setServiceLevelOperStatus(build(
- serviceLevelOperStatus()
- .setOrderStatus(OrderStatus.Created)
- .setModifyTimestamp(Instant.now().toString())
- .setLastSvcRequestId("svc-request-id: abc")
- .setLastRpcAction(LastRpcAction.Activate)
- .setLastOrderStatus(LastOrderStatus.PendingAssignment)
- .setLastAction(LastAction.ActivateNetworkInstance)
- .setCreateTimestamp(Instant.now().toString())
- ))
+ service()
+ .setServiceInstanceId(
+ networkTopologyOperationInput.getServiceInformation().getServiceInstanceId()
+ )
+ .setServiceData(build(
+ serviceData()
+ .setServiceLevelOperStatus(build(
+ serviceLevelOperStatus()
+ .setOrderStatus(OrderStatus.Created)
+ .setModifyTimestamp(Instant.now().toString())
+ .setLastSvcRequestId("svc-request-id: abc")
+ .setLastRpcAction(LastRpcAction.Activate)
+ .setLastOrderStatus(LastOrderStatus.PendingAssignment)
+ .setLastAction(LastAction.ActivateNetworkInstance)
+ .setCreateTimestamp(Instant.now().toString())
))
+ ))
);
- db.write(true,service, LogicalDatastoreType.CONFIGURATION);
+ db.write(true, service, LogicalDatastoreType.CONFIGURATION);
return service;
}
-
-
-
-
private NetworkTopologyOperationOutput createExpectedNTOO(
- PropBuilder expectedSvcResultProp,
- NetworkTopologyOperationInput expectedNetworkTopologyOperationInput){
+ PropBuilder expectedSvcResultProp,
+ NetworkTopologyOperationInput expectedNetworkTopologyOperationInput) {
return build(
- networkTopologyOperationOutput()
- .setSvcRequestId(expectedNetworkTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
- .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
- .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
- .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
- .setServiceResponseInformation(build(serviceResponseInformation()
- .setInstanceId(expectedNetworkTopologyOperationInput.getServiceInformation().getServiceInstanceId())
- .setObjectPath(expectedSvcResultProp.get(svcClient.serviceObjectPath))
- ))
- .setNetworkResponseInformation(build(
- networkResponseInformation()
- .setInstanceId(expectedSvcResultProp.get(svcClient.networkId))
- .setObjectPath(expectedSvcResultProp.get(svcClient.networkObjectPath))
- ))
+ networkTopologyOperationOutput()
+ .setSvcRequestId(expectedNetworkTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
+ .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(expectedNetworkTopologyOperationInput.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(expectedSvcResultProp.get(svcClient.serviceObjectPath))
+ ))
+ .setNetworkResponseInformation(build(
+ networkResponseInformation()
+ .setInstanceId(expectedSvcResultProp.get(svcClient.networkId))
+ .setObjectPath(expectedSvcResultProp.get(svcClient.networkObjectPath))
+ ))
);
}
private Service createExpectedService(
- NetworkTopologyOperationOutput expectedNetworkTopologyOperationOutput,
- NetworkTopologyOperationInput expectedNetworkTopologyOperationInput,
- ServiceData expectedServiceData,
- Service actualService
- ){
-
+ NetworkTopologyOperationOutput expectedNetworkTopologyOperationOutput,
+ NetworkTopologyOperationInput expectedNetworkTopologyOperationInput,
+ ServiceData expectedServiceData,
+ Service actualService
+ ) {
//We cannot predict the timeStamp value so just steal it from the actual
//we need this to prevent the equals method from returning false as a result of the timestamp
- String responseTimeStamp = actualService == null || actualService.getServiceStatus() == null?
- null : actualService.getServiceStatus().getResponseTimestamp();
+ String responseTimeStamp = actualService == null || actualService.getServiceStatus() == null ?
+ null : actualService.getServiceStatus().getResponseTimestamp();
SdncRequestHeader expectedSdncRequestHeader = expectedNetworkTopologyOperationInput.getSdncRequestHeader();
ServiceInformation expectedServiceInformation = expectedNetworkTopologyOperationInput.getServiceInformation();
RequestInformation expectedRequestInformation = expectedNetworkTopologyOperationInput.getRequestInformation();
return build(
- service()
- .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
- .setServiceData(build(serviceData()))
- .setServiceData(expectedServiceData)
- .setServiceStatus(
- build(
- serviceStatus()
- )
- )
+ service()
+ .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
+ .setServiceData(build(serviceData()))
+ .setServiceData(expectedServiceData)
+ .setServiceStatus(
+ build(
+ serviceStatus()
+ )
+ )
);
}
- public ServiceStatus.RpcAction toRpcAction(SvcAction fromEnum){
- return fromEnum == null? null : ServiceStatus.RpcAction.valueOf(fromEnum.name());
+ public ServiceStatus.RpcAction toRpcAction(SvcAction fromEnum) {
+ return fromEnum == null ? null : ServiceStatus.RpcAction.valueOf(fromEnum.name());
}
-
-
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java
new file mode 100644
index 00000000..e7618937
--- /dev/null
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/SecurityZoneTopologyOperationRPCTest.java
@@ -0,0 +1,272 @@
+package org.onap.sdnc.northbound;
+
+import static org.junit.Assert.assertEquals;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.APP_NAME;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.INVALID_INPUT_ERROR_MESSAGE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NO_SERVICE_LOGIC_ACTIVE;
+import static org.onap.sdnc.northbound.GenericResourceApiProvider.NULL_OR_EMPTY_ERROR_PARAM;
+import static org.onap.sdnc.northbound.util.MDSALUtil.build;
+import static org.onap.sdnc.northbound.util.MDSALUtil.exec;
+import static org.onap.sdnc.northbound.util.MDSALUtil.requestInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
+import static org.onap.sdnc.northbound.util.MDSALUtil.securityZoneResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.securityZoneTopologyOperationInput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.securityZoneTopologyOperationOutput;
+import static org.onap.sdnc.northbound.util.MDSALUtil.service;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceData;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceLevelOperStatus;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
+import static org.onap.sdnc.northbound.util.MDSALUtil.serviceStatus;
+
+import java.time.Instant;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+import org.onap.sdnc.northbound.util.PropBuilder;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+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.TransactionChainClosedException;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastOrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.LastRpcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.OperStatusData.OrderStatus;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutput;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeader.SvcAction;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceData;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformation;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.model.infrastructure.Service;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+
+@RunWith(MockitoJUnitRunner.class)
+public class SecurityZoneTopologyOperationRPCTest extends GenericResourceApiProviderTest {
+
+
+ private static final String SVC_OPERATION = "security-zone-topology-operation";
+
+
+ @Before
+ public void setUp() throws Exception {
+ super.setUp();
+ svcClient.setScvOperation(SVC_OPERATION);
+ }
+
+ @Test
+ public void should_fail_when_service_instance_id_not_present() throws Exception {
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput());
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(NULL_OR_EMPTY_ERROR_PARAM, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_invalid_service_data() throws Exception {
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("404", output.getResponseCode());
+ assertEquals(INVALID_INPUT_ERROR_MESSAGE, output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+
+ @Test
+ public void should_fail_when_client_execution_failed() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ svcClient.mockExecute(new RuntimeException("test exception"));
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_client_has_no_graph() throws Exception {
+
+ svcClient.mockHasGraph(false);
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("503", output.getResponseCode());
+ assertEquals(NO_SERVICE_LOGIC_ACTIVE + APP_NAME + ": '" + SVC_OPERATION + "'", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_fail_when_failed_to_update_mdsal() throws Exception {
+
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcClient.mockExecute(svcResultProp);
+ svcClient.mockHasGraph(true);
+ WriteTransaction mockWriteTransaction = mock(WriteTransaction.class);
+ when(mockWriteTransaction.submit()).thenThrow(new TransactionChainClosedException("test exception"));
+
+ DataBroker spyDataBroker = Mockito.spy(dataBroker);
+ when(spyDataBroker.newWriteOnlyTransaction()).thenReturn(mockWriteTransaction);
+ genericResourceApiProvider.setDataBroker(spyDataBroker);
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("500", output.getResponseCode());
+ assertEquals("test exception", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+ }
+
+ @Test
+ public void should_success_when_no_errors_encountered() throws Exception {
+
+ svcClient.mockHasGraph(true);
+ PropBuilder svcResultProp = svcClient.createExecuteOKResult();
+ svcResultProp.set("security-zone-object-path", "securityZoneObjectPath: XYZ");
+ svcClient.mockExecute(svcResultProp);
+
+ SecurityZoneTopologyOperationInput input = build(securityZoneTopologyOperationInput()
+ .setSdncRequestHeader(build(sdncRequestHeader()
+ .setSvcRequestId("test-svc-request-id")
+ .setSvcAction(SvcAction.Assign)
+ ))
+ .setRequestInformation(build(requestInformation()
+ .setRequestId("test-request-id")
+ .setRequestAction(RequestInformation.RequestAction.CreateServiceInstance)
+ ))
+ .setServiceInformation(build(serviceInformationBuilder()
+ .setServiceInstanceId("test-service-instance-id")
+ ))
+ );
+
+ Service service = persistServiceInDataBroker(input);
+
+ SecurityZoneTopologyOperationOutput output =
+ exec(genericResourceApiProvider::securityZoneTopologyOperation, input, RpcResult::getResult);
+
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
+ SecurityZoneTopologyOperationOutput expectedOutput = createExpectedOutput(svcResultProp, input);
+ assertEquals(expectedOutput, output);
+
+ Service actualService = db
+ .read(input.getServiceInformation().getServiceInstanceId(), LogicalDatastoreType.CONFIGURATION);
+
+ Service expectedService = createExpectedService(input, service.getServiceData());
+ assertEquals(expectedService, actualService);
+ }
+
+ private Service persistServiceInDataBroker(SecurityZoneTopologyOperationInput input) throws Exception {
+
+ Service service = build(service()
+ .setServiceInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setServiceData(build(serviceData()
+ .setServiceLevelOperStatus(build(serviceLevelOperStatus()
+ .setOrderStatus(OrderStatus.Created)
+ .setModifyTimestamp(Instant.now().toString())
+ .setLastSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setLastRpcAction(LastRpcAction.Activate)
+ .setLastOrderStatus(LastOrderStatus.PendingAssignment)
+ .setLastAction(LastAction.ActivateNetworkInstance)
+ .setCreateTimestamp(Instant.now().toString())
+ ))
+ ))
+ );
+ db.write(true, service, LogicalDatastoreType.CONFIGURATION);
+ return service;
+ }
+
+ private SecurityZoneTopologyOperationOutput createExpectedOutput(PropBuilder propBuilder,
+ SecurityZoneTopologyOperationInput input) {
+
+ return build(securityZoneTopologyOperationOutput()
+ .setSecurityZoneResponseInformation(build(securityZoneResponseInformation()
+ .setObjectPath(propBuilder.get("security-zone-object-path"))))
+ .setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
+ .setResponseCode(propBuilder.get(svcClient.errorCode))
+ .setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
+ .setResponseMessage(propBuilder.get(svcClient.errorMessage))
+ .setServiceResponseInformation(build(serviceResponseInformation()
+ .setInstanceId(input.getServiceInformation().getServiceInstanceId())
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
+ ))
+ );
+ }
+
+ private Service createExpectedService(
+ SecurityZoneTopologyOperationInput expectedInput, ServiceData expectedServiceData) {
+
+ ServiceInformation expectedServiceInformation = expectedInput.getServiceInformation();
+
+ return build(service()
+ .setServiceInstanceId(expectedServiceInformation.getServiceInstanceId())
+ .setServiceData(build(serviceData()))
+ .setServiceData(expectedServiceData)
+ .setServiceStatus(build(serviceStatus()))
+ );
+ }
+
+}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
index ee0bdb50..faacd220 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/ServiceTopologyOperationRPCTest.java
@@ -87,26 +87,30 @@ public class ServiceTopologyOperationRPCTest extends GenericResourceApiProviderT
svcClient.mockExecute(svcResultProp);
// create the ServiceTopologyOperationInput from the template
- ServiceTopologyOperationInput serviceTopologyOperationInput = createSTOI();
+ ServiceTopologyOperationInput input = createSTOI();
//execute the mdsal exec
- ServiceTopologyOperationOutput actualServiceTopologyOperationOutput = exec(
+ ServiceTopologyOperationOutput output = exec(
genericResourceApiProvider::serviceTopologyOperation
- , serviceTopologyOperationInput
+ , input
, RpcResult::getResult
);
+ assertEquals("200", output.getResponseCode());
+ assertEquals("OK", output.getResponseMessage());
+ assertEquals("Y", output.getAckFinalIndicator());
+
//verify the returned ServiceTopologyOperationOutput
ServiceTopologyOperationOutput expectedServiceTopologyOperationOutput = createExpectedSTOO(svcResultProp,
- serviceTopologyOperationInput);
- assertEquals(expectedServiceTopologyOperationOutput, actualServiceTopologyOperationOutput);
+ input);
+ assertEquals(expectedServiceTopologyOperationOutput, output);
//verify the persisted Service
- Service actualService = db.read(serviceTopologyOperationInput.getServiceInformation().getServiceInstanceId(),
+ Service actualService = db.read(input.getServiceInformation().getServiceInstanceId(),
LogicalDatastoreType.CONFIGURATION);
Service expectedService = createExpectedService(
expectedServiceTopologyOperationOutput,
- serviceTopologyOperationInput,
+ input,
actualService);
assertEquals(expectedService, actualService);
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java
index 10b70765..facf71d6 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VfModuleTopologyOperationRPCTest.java
@@ -212,22 +212,20 @@ public class VfModuleTopologyOperationRPCTest extends GenericResourceApiProvider
assertEquals("OK", output.getResponseMessage());
assertEquals("Y", output.getAckFinalIndicator());
- VfModuleTopologyOperationOutput expectedOutput = createExpectedVMTOO(svcResultProp,
- input);
+ VfModuleTopologyOperationOutput expectedOutput = createExpectedVMTOO(svcResultProp, input);
assertEquals(expectedOutput, output);
}
private VfModuleTopologyOperationOutput createExpectedVMTOO(PropBuilder propBuilder,
VfModuleTopologyOperationInput input) {
- return build(
- vfModuleTopologyOperationOutput()
+ return build(vfModuleTopologyOperationOutput()
.setSvcRequestId(input.getSdncRequestHeader().getSvcRequestId())
.setResponseCode(propBuilder.get(svcClient.errorCode))
.setAckFinalIndicator(propBuilder.get(svcClient.ackFinal))
.setResponseMessage(propBuilder.get(svcClient.errorMessage))
.setServiceResponseInformation(build(serviceResponseInformation()
.setInstanceId(input.getServiceInformation().getServiceInstanceId())
- .setObjectPath(propBuilder.get("vnf-object-path"))
+ .setObjectPath(propBuilder.get(svcClient.serviceObjectPath))
))
);
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java
index 624dd919..645cbf29 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/VnfTopologyOperationRPCTest.java
@@ -13,6 +13,7 @@ import static org.onap.sdnc.northbound.util.MDSALUtil.sdncRequestHeader;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceInformationBuilder;
import static org.onap.sdnc.northbound.util.MDSALUtil.serviceResponseInformation;
import static org.onap.sdnc.northbound.util.MDSALUtil.vnfInformationBuilder;
+import static org.onap.sdnc.northbound.util.MDSALUtil.vnfResponseInformation;
import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyOperationInput;
import static org.onap.sdnc.northbound.util.MDSALUtil.vnfTopologyOperationOutput;
@@ -180,22 +181,22 @@ public class VnfTopologyOperationRPCTest extends GenericResourceApiProviderTest
assertEquals("OK", output.getResponseMessage());
assertEquals("Y", output.getAckFinalIndicator());
- VnfTopologyOperationOutput expectedVnfTopologyOperationOutput = createExpectedVTOO(svcResultProp,
+ VnfTopologyOperationOutput expectedVnfTopologyOperationOutput = createExpectedOutput(svcResultProp,
input);
assertEquals(expectedVnfTopologyOperationOutput, output);
}
- private VnfTopologyOperationOutput createExpectedVTOO(PropBuilder expectedSvcResultProp,
+ private VnfTopologyOperationOutput createExpectedOutput(PropBuilder svcResultProp,
VnfTopologyOperationInput vnfTopologyOperationInput) {
return build(
vnfTopologyOperationOutput()
.setSvcRequestId(vnfTopologyOperationInput.getSdncRequestHeader().getSvcRequestId())
- .setResponseCode(expectedSvcResultProp.get(svcClient.errorCode))
- .setAckFinalIndicator(expectedSvcResultProp.get(svcClient.ackFinal))
- .setResponseMessage(expectedSvcResultProp.get(svcClient.errorMessage))
+ .setResponseCode(svcResultProp.get(svcClient.errorCode))
+ .setAckFinalIndicator(svcResultProp.get(svcClient.ackFinal))
+ .setResponseMessage(svcResultProp.get(svcClient.errorMessage))
.setServiceResponseInformation(build(serviceResponseInformation()
.setInstanceId(vnfTopologyOperationInput.getServiceInformation().getServiceInstanceId())
- .setObjectPath(expectedSvcResultProp.get("vnf-object-path"))
+ .setObjectPath(svcResultProp.get(svcClient.serviceObjectPath))
))
);
}
diff --git a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
index aa533925..ef11e128 100644
--- a/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
+++ b/generic-resource-api/provider/src/test/java/org/onap/sdnc/northbound/util/MDSALUtil.java
@@ -28,16 +28,20 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ContrailRouteTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.NetworkTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.SecurityZoneTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.ServiceTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VfModuleTopologyOperationOutputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationInputBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.VnfTopologyOperationOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.contrail.route.response.information.ContrailRouteResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.information.NetworkInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.network.response.information.NetworkResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.request.information.RequestInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.sdnc.request.header.SdncRequestHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.security.zone.response.information.SecurityZoneResponseInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.data.ServiceDataBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.information.ServiceInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.level.oper.status.ServiceLevelOperStatusBuilder;
@@ -46,6 +50,7 @@ import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.re
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.service.status.ServiceStatusBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vf.module.information.VfModuleInformationBuilder;
import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.information.VnfInformationBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.sdnc.northbound.generic.resource.rev170824.vnf.response.information.VnfResponseInformationBuilder;
import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.common.RpcResult;
@@ -77,6 +82,14 @@ import org.opendaylight.yangtools.yang.common.RpcResult;
*/
public class MDSALUtil {
+ public static SecurityZoneTopologyOperationInputBuilder securityZoneTopologyOperationInput() {
+ return new SecurityZoneTopologyOperationInputBuilder();
+ }
+
+ public static SecurityZoneTopologyOperationOutputBuilder securityZoneTopologyOperationOutput() {
+ return new SecurityZoneTopologyOperationOutputBuilder();
+ }
+
public static ContrailRouteTopologyOperationInputBuilder contrailRouteTopologyOperationInput() {
return new ContrailRouteTopologyOperationInputBuilder();
}
@@ -123,6 +136,18 @@ public class MDSALUtil {
return new ServiceResponseInformationBuilder();
}
+ public static SecurityZoneResponseInformationBuilder securityZoneResponseInformation() {
+ return new SecurityZoneResponseInformationBuilder();
+ }
+
+ public static ContrailRouteResponseInformationBuilder contrailRouteResponseInformation() {
+ return new ContrailRouteResponseInformationBuilder();
+ }
+
+ public static VnfResponseInformationBuilder vnfResponseInformation() {
+ return new VnfResponseInformationBuilder();
+ }
+
public static ServiceInformationBuilder serviceInformationBuilder() {
return new ServiceInformationBuilder();
}