aboutsummaryrefslogtreecommitdiffstats
path: root/mso-api-handlers/mso-api-handler-infra/src
diff options
context:
space:
mode:
Diffstat (limited to 'mso-api-handlers/mso-api-handler-infra/src')
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java596
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java10
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java894
3 files changed, 849 insertions, 651 deletions
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java
index c5827046d6..f5d068f900 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstances.java
@@ -40,7 +40,6 @@ import javax.ws.rs.core.Response;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.codehaus.jackson.map.ObjectMapper;
-import org.eclipse.jetty.io.RuntimeIOException;
import org.hibernate.Session;
import org.json.JSONObject;
import org.openecomp.mso.apihandler.common.ErrorNumbers;
@@ -69,7 +68,6 @@ import org.openecomp.mso.logger.MessageEnum;
import org.openecomp.mso.logger.MsoAlarmLogger;
import org.openecomp.mso.logger.MsoLogger;
import org.openecomp.mso.properties.MsoDatabaseException;
-import org.openecomp.mso.requestsdb.InfraActiveRequests;
import org.openecomp.mso.requestsdb.OperationStatus;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import org.openecomp.mso.requestsdb.RequestsDbSessionFactoryManager;
@@ -83,11 +81,12 @@ import com.wordnik.swagger.annotations.ApiOperation;
public class E2EServiceInstances {
private HashMap<String, String> instanceIdMap = new HashMap<>();
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.APIH);
+ private static MsoLogger msoLogger = MsoLogger
+ .getMsoLogger(MsoLogger.Catalog.APIH);
private static MsoAlarmLogger alarmLogger = new MsoAlarmLogger();
public static final String MSO_PROP_APIHANDLER_INFRA = "MSO_PROP_APIHANDLER_INFRA";
private ServiceInstancesRequest sir = null;
-
+
public static final String END_OF_THE_TRANSACTION = "End of the transaction, the final response is: ";
public static final String EXCEPTION_CREATING_DB_RECORD = "Exception while creating record in DB";
public static final String EXCEPTION_COMMUNICATE_BPMN_ENGINE = "Exception while communicate with BPMN engine";
@@ -101,9 +100,11 @@ public class E2EServiceInstances {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Create a E2E Service Instance on a version provided", response = Response.class)
- public Response createE2EServiceInstance(String request, @PathParam("version") String version) {
+ public Response createE2EServiceInstance(String request,
+ @PathParam("version") String version) {
- return processE2EserviceInstances(request, Action.createInstance, null, version);
+ return processE2EserviceInstances(request, Action.createInstance, null,
+ version);
}
/**
@@ -116,22 +117,30 @@ public class E2EServiceInstances {
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Delete E2E Service Instance on a specified version and serviceId", response = Response.class)
- public Response deleteE2EServiceInstance(String request, @PathParam("version") String version,
+ public Response deleteE2EServiceInstance(String request,
+ @PathParam("version") String version,
@PathParam("serviceId") String serviceId) {
instanceIdMap.put("serviceId", serviceId);
- return deleteE2EserviceInstances(request, Action.deleteInstance, instanceIdMap, version);
+ return deleteE2EserviceInstances(request, Action.deleteInstance,
+ instanceIdMap, version);
}
-
+
@GET
@Path("/{version:[vV][3-5]}/{serviceId}/operations/{operationId}")
@ApiOperation(value = "Find e2eServiceInstances Requests for a given serviceId and operationId", response = Response.class)
@Produces(MediaType.APPLICATION_JSON)
- public Response getE2EServiceInstances(@PathParam("serviceId") String serviceId,
- @PathParam("version") String version, @PathParam("operationId") String operationId) {
+ public Response getE2EServiceInstances(
+ @PathParam("serviceId") String serviceId,
+ @PathParam("version") String version,
+ @PathParam("operationId") String operationId) {
+ return getE2EServiceInstances(serviceId, operationId);
+ }
+
+ private Response getE2EServiceInstances(String serviceId, String operationId) {
RequestsDatabase requestsDB = RequestsDatabase.getInstance();
-
+
GetE2EServiceInstanceResponse e2eServiceResponse = new GetE2EServiceInstanceResponse();
MsoRequest msoRequest = new MsoRequest(serviceId);
@@ -141,169 +150,224 @@ public class E2EServiceInstances {
OperationStatus operationStatus = null;
try {
- operationStatus = requestsDB.getOperationStatus(serviceId, operationId);
+ operationStatus = requestsDB.getOperationStatus(serviceId,
+ operationId);
} catch (Exception e) {
- msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.AvailabilityError,
- "Exception while communciate with Request DB - Infra Request Lookup", e);
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException, e.getMessage(), ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null);
- alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
- Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ msoLogger
+ .error(MessageEnum.APIH_DB_ACCESS_EXC,
+ MSO_PROP_APIHANDLER_INFRA,
+ "",
+ "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communciate with Request DB - Infra Request Lookup",
+ e);
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ e.getMessage(),
+ ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB, null);
+ alarmLogger.sendAlarm("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL, Messages.errors
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_REQUESTS_DB));
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with Request DB");
- msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) response.getEntity());
return response;
}
if (operationStatus == null) {
- Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NO_CONTENT,
- MsoException.ServiceException, "E2E serviceId " + serviceId + " is not found in DB",
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NO_CONTENT, MsoException.ServiceException,
+ "E2E serviceId " + serviceId + " is not found in DB",
ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
- msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
"Null response from RequestDB when searching by serviceId");
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DataNotFound,
"Null response from RequestDB when searching by serviceId");
- msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) resp.getEntity());
return resp;
}
- e2eServiceResponse.setE2eRequest(operationStatus);
+ e2eServiceResponse.setOperationStatus(operationStatus);
return Response.status(200).entity(e2eServiceResponse).build();
}
- private Response deleteE2EserviceInstances(String requestJSON, Action action,
- HashMap<String, String> instanceIdMap, String version) {
- //TODO should be a new one or the same service instance Id
+ private Response deleteE2EserviceInstances(String requestJSON,
+ Action action, HashMap<String, String> instanceIdMap, String version) {
+ // TODO should be a new one or the same service instance Id
String requestId = instanceIdMap.get("serviceId");
long startTime = System.currentTimeMillis();
msoLogger.debug("requestId is: " + requestId);
E2EServiceInstanceDeleteRequest e2eDelReq = null;
MsoRequest msoRequest = new MsoRequest(requestId);
-
+
ObjectMapper mapper = new ObjectMapper();
try {
- e2eDelReq = mapper.readValue(requestJSON, E2EServiceInstanceDeleteRequest.class);
+ e2eDelReq = mapper.readValue(requestJSON,
+ E2EServiceInstanceDeleteRequest.class);
} catch (Exception e) {
msoLogger.debug("Mapping of request to JSON object failed : ", e);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_REQUEST,
- MsoException.ServiceException, "Mapping of request to JSON object failed. " + e.getMessage(),
- ErrorNumbers.SVC_BAD_PARAMETER, null);
- msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_REQUEST,
+ MsoException.ServiceException,
+ "Mapping of request to JSON object failed. "
+ + e.getMessage(), ErrorNumbers.SVC_BAD_PARAMETER,
+ null);
+ msoLogger.error(MessageEnum.APIH_REQUEST_VALIDATION_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.SchemaError, requestJSON, e);
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.SchemaError,
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.SchemaError,
"Mapping of request to JSON object failed");
- msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) response.getEntity());
createOperationStatusRecordForError(action, requestId);
return response;
}
-
+
CatalogDatabase db = null;
RecipeLookupResult recipeLookupResult = null;
try {
db = CatalogDatabase.getInstance();
recipeLookupResult = getServiceInstanceOrchestrationURI(db, action);
} catch (Exception e) {
- msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.AvailabilityError, "Exception while communciate with Catalog DB", e);
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException, "No communication to catalog DB " + e.getMessage(),
+ msoLogger.error(MessageEnum.APIH_DB_ACCESS_EXC,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
+ "Exception while communciate with Catalog DB", e);
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ "No communication to catalog DB " + e.getMessage(),
ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
- alarmLogger.sendAlarm("MsoDatabaseAccessError", MsoAlarmLogger.CRITICAL,
- Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
+ alarmLogger.sendAlarm("MsoDatabaseAccessError",
+ MsoAlarmLogger.CRITICAL, Messages.errors
+ .get(ErrorNumbers.NO_COMMUNICATION_TO_CATALOG_DB));
msoRequest.createRequestRecord(Status.FAILED, action);
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DBAccessError,
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DBAccessError,
"Exception while communciate with DB");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) response.getEntity());
return response;
} finally {
closeCatalogDB(db);
}
if (recipeLookupResult == null) {
- msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND, MSO_PROP_APIHANDLER_INFRA, "", "",
+ msoLogger.error(MessageEnum.APIH_DB_ATTRIBUTE_NOT_FOUND,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
MsoLogger.ErrorCode.DataError, "No recipe found in DB");
- msoRequest.setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_NOT_FOUND,
- MsoException.ServiceException, "Recipe does not exist in catalog DB",
+ msoRequest
+ .setStatus(org.openecomp.mso.apihandlerinfra.vnfbeans.RequestStatusType.FAILED);
+ Response response = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_NOT_FOUND, MsoException.ServiceException,
+ "Recipe does not exist in catalog DB",
ErrorNumbers.SVC_GENERAL_SERVICE_ERROR, null);
msoRequest.createRequestRecord(Status.FAILED, action);
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataNotFound,
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.DataNotFound,
"No recipe found in DB");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) response.getEntity());
createOperationStatusRecordForError(action, requestId);
return response;
}
-
RequestClient requestClient = null;
HttpResponse response = null;
long subStartTime = System.currentTimeMillis();
- //String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
+ // String sirRequestJson = mapReqJsonToSvcInstReq(e2eSir, requestJSON);
try {
- requestClient = RequestClientFactory.getRequestClient(recipeLookupResult.getOrchestrationURI(),
+ requestClient = RequestClientFactory.getRequestClient(
+ recipeLookupResult.getOrchestrationURI(),
MsoPropertiesUtils.loadMsoProperties());
JSONObject jjo = new JSONObject(requestJSON);
jjo.put("operationId", UUIDChecker.generateUUID(msoLogger));
-
+
String bpmnRequest = jjo.toString();
-
- // Capture audit event
- msoLogger.debug("MSO API Handler Posting call to BPEL engine for url: " + requestClient.getUrl());
- String serviceId = instanceIdMap.get("serviceId");
- String serviceInstanceType = e2eDelReq.getServiceType();
- response = requestClient.post(requestId, false, recipeLookupResult.getRecipeTimeout(), action.name(),
- serviceId, null, null, null, null, serviceInstanceType, null, null, null, bpmnRequest);
- msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
- "Successfully received response from BPMN engine", "BPMN", recipeLookupResult.getOrchestrationURI(),
- null);
+ // Capture audit event
+ msoLogger
+ .debug("MSO API Handler Posting call to BPEL engine for url: "
+ + requestClient.getUrl());
+ String serviceId = instanceIdMap.get("serviceId");
+ String serviceInstanceType = e2eDelReq.getServiceType();
+ response = requestClient.post(requestId, false,
+ recipeLookupResult.getRecipeTimeout(), action.name(),
+ serviceId, null, null, null, null, serviceInstanceType,
+ null, null, null, bpmnRequest);
+
+ msoLogger.recordMetricEvent(subStartTime,
+ MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ "Successfully received response from BPMN engine", "BPMN",
+ recipeLookupResult.getOrchestrationURI(), null);
} catch (Exception e) {
- msoLogger.recordMetricEvent(subStartTime, MsoLogger.StatusCode.ERROR,
- MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with BPMN engine", "BPMN",
+ msoLogger.recordMetricEvent(subStartTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine", "BPMN",
recipeLookupResult.getOrchestrationURI(), null);
- Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "Failed calling bpmn " + e.getMessage(),
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "Failed calling bpmn " + e.getMessage(),
ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
- alarmLogger.sendAlarm("MsoConfigurationError", MsoAlarmLogger.CRITICAL,
+ alarmLogger.sendAlarm("MsoConfigurationError",
+ MsoAlarmLogger.CRITICAL,
Messages.errors.get(ErrorNumbers.NO_COMMUNICATION_TO_BPEL));
- msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.AvailabilityError, "Exception while communicate with BPMN engine");
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError,
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.AvailabilityError,
"Exception while communicate with BPMN engine");
- msoLogger.debug("End of the transaction, the final response is: " + (String) resp.getEntity());
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.CommunicationError,
+ "Exception while communicate with BPMN engine");
+ msoLogger.debug("End of the transaction, the final response is: "
+ + (String) resp.getEntity());
createOperationStatusRecordForError(action, requestId);
return resp;
}
if (response == null) {
- Response resp = msoRequest.buildServiceErrorResponse(HttpStatus.SC_BAD_GATEWAY,
- MsoException.ServiceException, "bpelResponse is null", ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
- msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR, MSO_PROP_APIHANDLER_INFRA, "", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Null response from BPEL");
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ Response resp = msoRequest.buildServiceErrorResponse(
+ HttpStatus.SC_BAD_GATEWAY, MsoException.ServiceException,
+ "bpelResponse is null",
+ ErrorNumbers.SVC_NO_SERVER_RESOURCES, null);
+ msoLogger.error(MessageEnum.APIH_BPEL_COMMUNICATE_ERROR,
+ MSO_PROP_APIHANDLER_INFRA, "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
+ "Null response from BPEL");
+ msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
"Null response from BPMN");
msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
createOperationStatusRecordForError(action, requestId);
return resp;
}
- ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
+ ResponseHandler respHandler = new ResponseHandler(response,
+ requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action);
+ return beplStatusUpdate(requestId, startTime, msoRequest,
+ requestClient, respHandler, bpelStatus, action, instanceIdMap);
}
private Response processE2EserviceInstances(String requestJSON, Action action,
@@ -356,10 +420,8 @@ public class E2EServiceInstances {
msoLogger.debug("End of the transaction, the final response is: " + (String) response.getEntity());
return response;
}
-
- InfraActiveRequests dup = null;
-// String instanceName = sir.getService().getName();
-// String requestScope = sir.getService().getParameters().getNodeType();
+
+ OperationStatus dup = null;
String instanceName = sir.getRequestDetails().getRequestInfo().getInstanceName();
String requestScope = sir.getRequestDetails().getModelInfo().getModelType().name();
try {
@@ -367,8 +429,7 @@ public class E2EServiceInstances {
&& (action == Action.createInstance || action == Action.activateInstance))) {
//TODO : Need to check for the duplicate record from the operation status,
//TODO : commenting this check for unblocking current testing for now... induces dead code...
-// dup = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
-// requestScope);
+ dup = chkDuplicateServiceNameInOperStatus( instanceName);
}
} catch (Exception e) {
msoLogger.error(MessageEnum.APIH_DUPLICATE_CHECK_EXC, MSO_PROP_APIHANDLER_INFRA, "", "",
@@ -392,8 +453,8 @@ public class E2EServiceInstances {
instance = instanceIdMap.get(requestScope + "InstanceId");
}
String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
- + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
- + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
+ + "already has a request being worked with a status of " + dup.getProgress() + " (ServiceId - "
+ + dup.getServiceId() + "). The existing request must finish or be cleaned up before proceeding.";
Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT,
MsoException.ServiceException, dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
@@ -447,7 +508,6 @@ public class E2EServiceInstances {
createOperationStatusRecordForError(action, requestId);
return response;
}
-
// try {
// msoRequest.createRequestRecord(Status.PENDING, action);
// //createOperationStatusRecord(action, requestId);
@@ -518,7 +578,7 @@ public class E2EServiceInstances {
ResponseHandler respHandler = new ResponseHandler(response, requestClient.getType());
int bpelStatus = respHandler.getStatus();
- return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action);
+ return beplStatusUpdate(requestId, startTime, msoRequest, requestClient, respHandler, bpelStatus, action, instanceIdMap);
}
private void closeCatalogDB(CatalogDatabase db) {
@@ -527,91 +587,87 @@ public class E2EServiceInstances {
}
}
- private InfraActiveRequests checkForDuplicateRecord(Action action, HashMap<String, String> instanceIdMap,
- String instanceName, String requestScope) {
- InfraActiveRequests dupValue = null;
- if (!(instanceName == null && "service".equals(requestScope)
- && (action == Action.createInstance || action == Action.activateInstance))) {
- dupValue = (RequestsDatabase.getInstance()).checkInstanceNameDuplicate(instanceIdMap, instanceName,
- requestScope);
- }
- return dupValue;
- }
-
- private Response duplicateRecordFound(Action action, HashMap<String, String> instanceIdMap, long startTime,
- MsoRequest msoRequest, InfraActiveRequests dup, String instanceName, String requestScope) {
- String instance = null;
- if (instanceName != null) {
- instance = instanceName;
- } else {
- instance = instanceIdMap.get(requestScope + "InstanceId");
- }
- String dupMessage = "Error: Locked instance - This " + requestScope + " (" + instance + ") "
- + "already has a request being worked with a status of " + dup.getRequestStatus() + " (RequestId - "
- + dup.getRequestId() + "). The existing request must finish or be cleaned up before proceeding.";
-
- Response response = msoRequest.buildServiceErrorResponse(HttpStatus.SC_CONFLICT, MsoException.ServiceException,
- dupMessage, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, null);
-
- msoLogger.warn(MessageEnum.APIH_DUPLICATE_FOUND, dupMessage, "", "", MsoLogger.ErrorCode.SchemaError,
- "Duplicate request - Subscriber already has a request for this service");
- msoRequest.createRequestRecord(Status.FAILED, action);
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.Conflict, dupMessage);
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) response.getEntity());
- return response;
- }
-
- private Response beplStatusUpdate(String requestId, long startTime, MsoRequest msoRequest,
- RequestClient requestClient, ResponseHandler respHandler, int bpelStatus, Action action) {
+ private Response beplStatusUpdate(String requestId, long startTime,
+ MsoRequest msoRequest, RequestClient requestClient,
+ ResponseHandler respHandler, int bpelStatus, Action action,
+ HashMap<String, String> instanceIdMap) {
// BPMN accepted the request, the request is in progress
if (bpelStatus == HttpStatus.SC_ACCEPTED) {
String camundaJSONResponseBody = respHandler.getResponseBody();
- msoLogger.debug("Received from Camunda: " + camundaJSONResponseBody);
-
+ msoLogger
+ .debug("Received from Camunda: " + camundaJSONResponseBody);
+
// currently only for delete case we update the status here
- if(action == Action.deleteInstance){
+ if (action == Action.deleteInstance) {
ObjectMapper mapper = new ObjectMapper();
- try{
- DelE2ESvcResp jo = mapper.readValue(camundaJSONResponseBody, DelE2ESvcResp.class);
+ try {
+ DelE2ESvcResp jo = mapper.readValue(
+ camundaJSONResponseBody, DelE2ESvcResp.class);
String operationId = jo.getOperationId();
-
- this.createOperationStatusRecord("DELETE", requestId, operationId);
- }
- catch(Exception ex)
- {
- msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
+ OperationStatus operStatus = chkDuplicateServiceInOperStatus(instanceIdMap
+ .get("serviceId"));
+ if (null != operStatus) {
+ msoLogger
+ .debug("One task is already in progress state for this service id");
+ } else {
+ this.createOperationStatusRecord("DELETE", requestId,
+ operationId);
+ }
+ } catch (Exception ex) {
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
+ requestClient.getUrl(), "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
- "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
+ "Response from BPEL engine is failed with HTTP Status="
+ + bpelStatus);
}
}
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
+ msoLogger.recordAuditEvent(startTime,
+ MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc,
"BPMN accepted the request, the request is in progress");
msoLogger.debug(END_OF_THE_TRANSACTION + camundaJSONResponseBody);
- return Response.status(HttpStatus.SC_ACCEPTED).entity(camundaJSONResponseBody).build();
+ return Response.status(HttpStatus.SC_ACCEPTED)
+ .entity(camundaJSONResponseBody).build();
} else {
List<String> variables = new ArrayList<>();
variables.add(bpelStatus + "");
String camundaJSONResponseBody = respHandler.getResponseBody();
- if (camundaJSONResponseBody != null && !camundaJSONResponseBody.isEmpty()) {
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1 " + '\n' + camundaJSONResponseBody,
+ if (camundaJSONResponseBody != null
+ && !camundaJSONResponseBody.isEmpty()) {
+ Response resp = msoRequest.buildServiceErrorResponse(
+ bpelStatus, MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1 "
+ + '\n' + camundaJSONResponseBody,
ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
- msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
+ requestClient.getUrl(), "", "",
MsoLogger.ErrorCode.BusinessProcesssError,
- "Response from BPEL engine is failed with HTTP Status=" + bpelStatus);
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ "Response from BPEL engine is failed with HTTP Status="
+ + bpelStatus);
+ msoLogger.recordAuditEvent(startTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
"Response from BPMN engine is failed");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) resp.getEntity());
return resp;
} else {
- Response resp = msoRequest.buildServiceErrorResponse(bpelStatus, MsoException.ServiceException,
- "Request Failed due to BPEL error with HTTP Status= %1",
- ErrorNumbers.SVC_DETAILED_SERVICE_ERROR, variables);
- msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR, requestClient.getUrl(), "", "",
- MsoLogger.ErrorCode.BusinessProcesssError, "Response from BPEL engine is empty");
- msoLogger.recordAuditEvent(startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.InternalError,
+ Response resp = msoRequest
+ .buildServiceErrorResponse(
+ bpelStatus,
+ MsoException.ServiceException,
+ "Request Failed due to BPEL error with HTTP Status= %1",
+ ErrorNumbers.SVC_DETAILED_SERVICE_ERROR,
+ variables);
+ msoLogger.error(MessageEnum.APIH_BPEL_RESPONSE_ERROR,
+ requestClient.getUrl(), "", "",
+ MsoLogger.ErrorCode.BusinessProcesssError,
"Response from BPEL engine is empty");
- msoLogger.debug(END_OF_THE_TRANSACTION + (String) resp.getEntity());
+ msoLogger.recordAuditEvent(startTime,
+ MsoLogger.StatusCode.ERROR,
+ MsoLogger.ResponseCode.InternalError,
+ "Response from BPEL engine is empty");
+ msoLogger.debug(END_OF_THE_TRANSACTION
+ + (String) resp.getEntity());
return resp;
}
}
@@ -624,13 +680,16 @@ public class E2EServiceInstances {
* @param action
* @return
*/
- private RecipeLookupResult getServiceInstanceOrchestrationURI(CatalogDatabase db, Action action) {
+ private RecipeLookupResult getServiceInstanceOrchestrationURI(
+ CatalogDatabase db, Action action) {
RecipeLookupResult recipeLookupResult = getServiceURI(db, action);
if (recipeLookupResult != null) {
- msoLogger.debug("Orchestration URI is: " + recipeLookupResult.getOrchestrationURI()
- + ", recipe Timeout is: " + Integer.toString(recipeLookupResult.getRecipeTimeout()));
+ msoLogger.debug("Orchestration URI is: "
+ + recipeLookupResult.getOrchestrationURI()
+ + ", recipe Timeout is: "
+ + Integer.toString(recipeLookupResult.getRecipeTimeout()));
} else {
msoLogger.debug("No matching recipe record found");
}
@@ -648,13 +707,16 @@ public class E2EServiceInstances {
String defaultServiceModelName = "UUI_DEFAULT";
- Service serviceRecord = db.getServiceByModelName(defaultServiceModelName);
- ServiceRecipe recipe = db.getServiceRecipeByModelUUID(serviceRecord.getModelUUID(), action.name());
+ Service serviceRecord = db
+ .getServiceByModelName(defaultServiceModelName);
+ ServiceRecipe recipe = db.getServiceRecipeByModelUUID(
+ serviceRecord.getModelUUID(), action.name());
if (recipe == null) {
return null;
}
- return new RecipeLookupResult(recipe.getOrchestrationUri(), recipe.getRecipeTimeout());
+ return new RecipeLookupResult(recipe.getOrchestrationUri(),
+ recipe.getRecipeTimeout());
}
@@ -665,7 +727,8 @@ public class E2EServiceInstances {
* @param e2eSir
* @return
*/
- private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) {
+ private String mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir,
+ String requestJSON) {
sir = new ServiceInstancesRequest();
@@ -679,14 +742,15 @@ public class E2EServiceInstances {
// modelNameVersionId
modelInfo.setModelNameVersionId(e2eSir.getService().getTemplateId());
-// String modelInfoValue = e2eSir.getService().getParameters().getNodeTemplateName();
-// String[] arrayOfInfo = modelInfoValue.split(":");
-// String modelName = arrayOfInfo[0];
-// String modelVersion = arrayOfInfo[1];
+ // String modelInfoValue =
+ // e2eSir.getService().getParameters().getNodeTemplateName();
+ // String[] arrayOfInfo = modelInfoValue.split(":");
+ // String modelName = arrayOfInfo[0];
+ // String modelVersion = arrayOfInfo[1];
-// TODO: To ensure, if we dont get the values from the UUI
- String modelName = "voLTE";
- String modelVersion = "1.0";
+ // TODO: To ensure, if we dont get the values from the UUI
+ String modelName = "voLTE";
+ String modelVersion = "1.0";
// modelName
modelInfo.setModelName(modelName);
@@ -702,10 +766,12 @@ public class E2EServiceInstances {
SubscriberInfo subscriberInfo = new SubscriberInfo();
// globalsubscriberId
- subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getParameters().getGlobalSubscriberId());
+ subscriberInfo.setGlobalSubscriberId(e2eSir.getService()
+ .getParameters().getGlobalSubscriberId());
// subscriberName
- subscriberInfo.setSubscriberName(e2eSir.getService().getParameters().getSubscriberName());
+ subscriberInfo.setSubscriberName(e2eSir.getService().getParameters()
+ .getSubscriberName());
// setting subscriberInfo to requestDetails
requestDetails.setSubscriberInfo(subscriberInfo);
@@ -731,18 +797,19 @@ public class E2EServiceInstances {
// Userparams
List<E2EUserParam> userParams;
- //userParams = e2eSir.getService().getParameters().getRequestParameters().getUserParams();
+ // userParams =
+ // e2eSir.getService().getParameters().getRequestParameters().getUserParams();
List<Map<String, String>> userParamList = new ArrayList<>();
Map<String, String> userParamMap = new HashMap<>();
- //complete json request updated in the camunda
+ // complete json request updated in the camunda
userParamMap.put("UUIRequest", requestJSON);
userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
-// Map<String, String> userParamMap3 = null;
-// for (E2EUserParam userp : userParams) {
-// userParamMap.put(userp.getName(), userp.getValue());
-//
-// }
+ // Map<String, String> userParamMap3 = null;
+ // for (E2EUserParam userp : userParams) {
+ // userParamMap.put(userp.getName(), userp.getValue());
+ //
+ // }
userParamList.add(userParamMap);
requestParameters.setUserParams(userParamList);
@@ -756,84 +823,111 @@ public class E2EServiceInstances {
try {
returnString = mapper.writeValueAsString(sir);
} catch (IOException e) {
- msoLogger.debug("Exception while converting ServiceInstancesRequest object to string", e);
+ msoLogger
+ .debug("Exception while converting ServiceInstancesRequest object to string",
+ e);
}
return returnString;
}
-
- private void createOperationStatusRecordForError(Action action, String requestId) throws MsoDatabaseException{
-
- AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
-
- Session session = null;
- try {
-
- session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
- session.beginTransaction();
-
- OperationStatus os = new OperationStatus();
- os.setOperation(action.name());
- os.setOperationContent("");
- os.setOperationId("");
- os.setProgress("100");
- os.setReason("");
- os.setResult("error");
- os.setServiceId(requestId);
- os.setUserId("");
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- os.setFinishedAt(endTimeStamp);
- os.setOperateAt(startTimeStamp);
-
- session.save(os);
- session.getTransaction().commit();
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e);
- throw new MsoDatabaseException("Data did inserted in Operatus Status Table for failure", e);
- } finally {
- if (null != session) {
- session.close();
- }
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+
+ Session session = null;
+ try {
+
+ session = requestsDbSessionFactoryManager.getSessionFactory()
+ .openSession();
+ session.beginTransaction();
+
+ OperationStatus os = new OperationStatus();
+ os.setOperation(action.name());
+ os.setOperationContent("");
+ os.setOperationId("");
+ os.setProgress("100");
+ os.setReason("");
+ os.setResult("error");
+ os.setServiceId(requestId);
+ os.setUserId("");
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ os.setFinishedAt(endTimeStamp);
+ os.setOperateAt(startTimeStamp);
+
+ session.save(os);
+ session.getTransaction().commit();
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_INSERT_EXC, "", "",
+ MsoLogger.ErrorCode.DataError,
+ "Exception when creation record request in Operation", e);
+ throw new MsoDatabaseException(
+ "Data did inserted in Operatus Status Table for failure", e);
+ } finally {
+ if (null != session) {
+ session.close();
}
}
- private void createOperationStatusRecord(String actionNm, String serviceId, String operationId) throws MsoDatabaseException{
+ }
- AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
+ private void createOperationStatusRecord(String actionNm, String serviceId,
+ String operationId) throws MsoDatabaseException {
- Session session = null;
- try {
+ AbstractSessionFactoryManager requestsDbSessionFactoryManager = new RequestsDbSessionFactoryManager();
- session = requestsDbSessionFactoryManager.getSessionFactory().openSession();
- session.beginTransaction();
-
- OperationStatus os = new OperationStatus();
- os.setOperation(actionNm);
- os.setOperationContent("");
- os.setOperationId(operationId);
- os.setProgress("0");
- os.setReason("");
- os.setResult("processing");
- os.setServiceId(serviceId);
- //TODO : to be updated...
- os.setUserId("");
- Timestamp startTimeStamp = new Timestamp (System.currentTimeMillis());
- Timestamp endTimeStamp = new Timestamp (System.currentTimeMillis());
- os.setFinishedAt(endTimeStamp);
- os.setOperateAt(startTimeStamp);
-
- session.save(os);
- session.getTransaction().commit();
-
- } catch (Exception e) {
- msoLogger.error (MessageEnum.APIH_DB_INSERT_EXC, "", "", MsoLogger.ErrorCode.DataError, "Exception when creation record request in Operation", e);
- throw new MsoDatabaseException("Data did inserted in Operatus Status Table", e);
- } finally {
- if (null != session) {
- session.close();
- }
+ Session session = null;
+ try {
+
+ session = requestsDbSessionFactoryManager.getSessionFactory()
+ .openSession();
+ session.beginTransaction();
+
+ OperationStatus os = new OperationStatus();
+ os.setOperation(actionNm);
+ os.setOperationContent("");
+ os.setOperationId(operationId);
+ os.setProgress("0");
+ os.setReason("");
+ os.setResult("processing");
+ os.setServiceId(serviceId);
+ // TODO : to be updated...
+ os.setUserId("");
+ Timestamp startTimeStamp = new Timestamp(System.currentTimeMillis());
+ Timestamp endTimeStamp = new Timestamp(System.currentTimeMillis());
+ os.setFinishedAt(endTimeStamp);
+ os.setOperateAt(startTimeStamp);
+
+ session.save(os);
+ session.getTransaction().commit();
+
+ } catch (Exception e) {
+ msoLogger.error(MessageEnum.APIH_DB_INSERT_EXC, "", "",
+ MsoLogger.ErrorCode.DataError,
+ "Exception when creation record request in Operation", e);
+ throw new MsoDatabaseException(
+ "Data did inserted in Operatus Status Table", e);
+ } finally {
+ if (null != session) {
+ session.close();
}
+ }
+ }
+
+ private OperationStatus chkDuplicateServiceInOperStatus(String serviceId) {
+ OperationStatus dupServiceName = (RequestsDatabase.getInstance())
+ .getOperationStatusByServiceId(serviceId);
+
+ return dupServiceName;
+ }
+
+ private OperationStatus chkDuplicateServiceNameInOperStatus(
+ String serviceName) {
+ OperationStatus dupServiceName = (RequestsDatabase.getInstance())
+ .getOperationStatusByServiceName(serviceName);
+
+ return dupServiceName;
}
} \ No newline at end of file
diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java
index 4c749b7e58..64af30b1ee 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/openecomp/mso/apihandlerinfra/e2eserviceinstancebeans/GetE2EServiceInstanceResponse.java
@@ -27,14 +27,14 @@ import org.openecomp.mso.requestsdb.OperationStatus;
@JsonSerialize(include=JsonSerialize.Inclusion.NON_DEFAULT)
public class GetE2EServiceInstanceResponse {
- protected OperationStatus e2eRequest;
+ protected OperationStatus operation;
- public OperationStatus getE2eRequest() {
- return e2eRequest;
+ public OperationStatus getOperationStatus() {
+ return operation;
}
- public void setE2eRequest(OperationStatus requestDB) {
- this.e2eRequest = requestDB;
+ public void setOperationStatus(OperationStatus requestDB) {
+ this.operation = requestDB;
}
}
diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
index cb8dda5628..238b6b677c 100644
--- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
+++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/openecomp/mso/apihandlerinfra/E2EServiceInstancesTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
+import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -47,8 +48,10 @@ import org.openecomp.mso.apihandler.common.RequestClientFactory;
import org.openecomp.mso.db.catalog.CatalogDatabase;
import org.openecomp.mso.db.catalog.beans.Service;
import org.openecomp.mso.db.catalog.beans.ServiceRecipe;
+import org.openecomp.mso.properties.MsoDatabaseException;
import org.openecomp.mso.properties.MsoJavaProperties;
import org.openecomp.mso.requestsdb.InfraActiveRequests;
+import org.openecomp.mso.requestsdb.OperationStatus;
import org.openecomp.mso.requestsdb.RequestsDatabase;
import mockit.Mock;
@@ -56,454 +59,555 @@ import mockit.MockUp;
public class E2EServiceInstancesTest {
-
@Test
- public void createE2EServiceInstanceTestSuccess(){
+ public void createE2EServiceInstanceTestSuccess() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 0;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,202, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"response\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 202,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("success") != -1);
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestBpelHTTPException(){
+ public void createE2EServiceInstanceTestBpelHTTPException() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 0;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"response\":\"success\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 500,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"success\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestBpelHTTPExceptionWithNullREsponseBody(){
+ public void createE2EServiceInstanceTestBpelHTTPExceptionWithNullREsponseBody() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- new MockUp<RequestsDatabase>() {
- @Mock
- public int updateInfraStatus (String requestId, String requestStatus, long progress, String lastModifiedBy) {
- return 0;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
- ProtocolVersion pv = new ProtocolVersion("HTTP",1,1);
- HttpResponse resp = new BasicHttpResponse(pv,500, "test response");
- BasicHttpEntity entity = new BasicHttpEntity();
- String body = "{\"response\":\"\",\"message\":\"success\"}";
- InputStream instream = new ByteArrayInputStream(body.getBytes());
- entity.setContent(instream);
- resp.setEntity(entity);
- return resp;
- }
- };
-
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails) {
+ ProtocolVersion pv = new ProtocolVersion("HTTP", 1, 1);
+ HttpResponse resp = new BasicHttpResponse(pv, 500,
+ "test response");
+ BasicHttpEntity entity = new BasicHttpEntity();
+ String body = "{\"response\":\"\",\"message\":\"success\"}";
+ InputStream instream = new ByteArrayInputStream(body.getBytes());
+ entity.setContent(instream);
+ resp.setEntity(entity);
+ return resp;
+ }
+ };
+
E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestNullBPELResponse(){
+ public void createE2EServiceInstanceTestNullBPELResponse() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(String requestId, boolean isBaseVfModule,
- int recipeTimeout, String requestAction, String serviceInstanceId,
- String vnfId, String vfModuleId, String volumeGroupId, String networkId,
- String serviceType, String vnfType, String vfModuleType, String networkType,
- String requestDetails){
- HttpResponse resp = null;
- return resp;
- }
- };
-
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String requestId, boolean isBaseVfModule,
+ int recipeTimeout, String requestAction,
+ String serviceInstanceId, String vnfId, String vfModuleId,
+ String volumeGroupId, String networkId, String serviceType,
+ String vnfType, String vfModuleType, String networkType,
+ String requestDetails) {
+ HttpResponse resp = null;
+ return resp;
+ }
+ };
+
E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC1000") != -1);
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestBPMNNullREsponse(){
+ public void createE2EServiceInstanceTestBPMNNullREsponse() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
-
- new MockUp<RequestClientFactory>() {
- @Mock
- public RequestClient getRequestClient(String orchestrationURI, MsoJavaProperties props) throws IllegalStateException{
- RequestClient client = new CamundaClient();
- client.setUrl("/test/url");
- return client;
- }
- };
-
- new MockUp<CamundaClient>() {
- @Mock
- public HttpResponse post(String camundaReqXML, String requestId,
- String requestTimeout, String schemaVersion, String serviceInstanceId, String action){
- HttpResponse resp = null;
- return resp;
- }
- };
- try{
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC1000") != -1);
- }catch(Exception e){
- //TODO: need to catch
- }
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+
+ new MockUp<RequestClientFactory>() {
+ @Mock
+ public RequestClient getRequestClient(String orchestrationURI,
+ MsoJavaProperties props) throws IllegalStateException {
+ RequestClient client = new CamundaClient();
+ client.setUrl("/test/url");
+ return client;
+ }
+ };
+
+ new MockUp<CamundaClient>() {
+ @Mock
+ public HttpResponse post(String camundaReqXML, String requestId,
+ String requestTimeout, String schemaVersion,
+ String serviceInstanceId, String action) {
+ HttpResponse resp = null;
+ return resp;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestNullBpmn(){
+ public void createE2EServiceInstanceTestNullBpmn() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- new MockUp<CatalogDatabase>() {
- @Mock
- public Service getServiceByModelName (String modelName) {
- Service svc = new Service();
- return svc;
- }
- };
-
- new MockUp<CatalogDatabase>() {
- @Mock
- public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID, String action) {
- ServiceRecipe rec = new ServiceRecipe();
- return rec;
- }
- };
- try{
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC1000") != -1);
- }catch(Exception e){
- //TODO: need to catch
- }
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public Service getServiceByModelName(String modelName) {
+ Service svc = new Service();
+ return svc;
+ }
+ };
+
+ new MockUp<CatalogDatabase>() {
+ @Mock
+ public ServiceRecipe getServiceRecipeByModelUUID(String modelUUID,
+ String action) {
+ ServiceRecipe rec = new ServiceRecipe();
+ return rec;
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestNullReceipe(){
+ public void createE2EServiceInstanceTestNullReceipe() {
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- try{
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"modelInvariantId value from SDC?\",\"templateId\":\"modelVersionId value from SDC??\",\"parameters\":{\"domainHost\":\"localhost\",\"nodeTemplateName\":\"modelName:v3\",\"nodeType\":\"service\",\"globalSubscriberId\":\"NEED THIS UUI - AAI\",\"subscriberName\":\"NEED THIS UUI - AAI\",\"requestParameters\":{\"subscriptionServiceType\":\"MOG\",\"userParams\":[{\"name\":\"someUserParam\",\"value\":\"someValue\"},{\"name\":\"segments\",\"value\":\"value\"},{\"name\":\"nsParameters\",\"value\":\"othervalue\"}]}}}}";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- //assertTrue(respStr.indexOf("Recipe could not be retrieved from catalog DB null") != -1);
- assertTrue(true);
- }catch(Exception e){
- //TODO: need to catch
- }
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestNullDBResponse(){
+ public void createE2EServiceInstanceTestNullDBResponse() {
+
new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return null;
- }
- };
- try{
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"domainHost\":\"localhost\",\"nodeTemplateName\":\"modelName:v3\",\"nodeType\":\"service\",\"globalSubscriberId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"subscriberName\":\"NEED THIS UUI - AAI\",\"requestParameters\":{\"subscriptionServiceType\":\"MOG\",\"userParams\":[{\"name\":\"someUserParam\",\"value\":\"someValue\"},{\"name\":\"segments\",\"value\":\"value\"},{\"name\":\"nsParameters\",\"value\":\"othervalue\"}]}}}}";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- //assertTrue(respStr.indexOf("Recipe could not be retrieved from catalog DB ") !=-1);
- assertTrue(true);
- }catch(Exception e){
- //TODO: need to catch
- }
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestInvalidRequest(){
- try{
- new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- List<InfraActiveRequests> activeReqlist = new ArrayList<>();
- InfraActiveRequests req = new InfraActiveRequests();
- req.setAaiServiceId("39493992");
-
- activeReqlist.add(req);
- return activeReqlist;
- }
- };
+ public void createE2EServiceInstanceTestInvalidRequest() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
Response resp = instance.createE2EServiceInstance(request, "v3");
String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC1000") != -1);
- }catch(Exception e){
- //TODO: need to catch
- }
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestEmptyDBQuery(){
- try{
- new MockUp<RequestsDatabase>() {
- @Mock
- private List<InfraActiveRequests> executeInfraQuery (List <Criterion> criteria, Order order) {
- return Collections.EMPTY_LIST;
- }
- };
-
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"domainHost\":\"localhost\",\"nodeTemplateName\":\"modelName:v3\",\"nodeType\":\"service\",\"globalSubscriberId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"subscriberName\":\"NEED THIS UUI - AAI\",\"requestParameters\":{\"subscriptionServiceType\":\"MOG\",\"userParams\":[{\"name\":\"someUserParam\",\"value\":\"someValue\"},{\"name\":\"segments\",\"value\":\"value\"},{\"name\":\"nsParameters\",\"value\":\"othervalue\"}]}}}}";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- //assertTrue(respStr.indexOf("Recipe could not be retrieved from catalog DB ") != -1);
- assertTrue(true);
- }catch(Exception e){
- //TODO: need to catch
- }
+ public void createE2EServiceInstanceTestEmptyDBQuery() {
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
+ // assertTrue(true);
}
-
+
@Test
- public void createE2EServiceInstanceTestDBQueryFail(){
- try{
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "{\"service\":{\"name\":\"service\",\"description\":\"so_test1\",\"serviceDefId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"templateId\":\"4050083f-465f-4838-af1e-47a545222ad1\",\"parameters\":{\"globalSubscriberId\":\"123457\", \"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"MOG\",\"resourceDefId\":\"MOG\",\"resourceId\":\"MOG\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}}]}}}";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("SVC1000") != -1);
- }catch(Exception e){
- //TODO: need to catch
- }
+ public void createE2EServiceInstanceTestDBQueryFail() {
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatusByServiceName(
+ String serviceName) {
+ OperationStatus operationStatus = new OperationStatus();
+ return operationStatus;
+ }
+ };
+
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "{\"service\":{\"name\":\"so_test4\",\"description\":\"so_test2\",\"serviceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561519\",\"templateId\":\"592f9437-a9c0-4303-b9f6-c445bb7e9814\",\"parameters\":{\"globalSubscriberId\":\"123457\",\"subscriberName\":\"Customer1\",\"serviceType\":\"voLTE\",\"templateName\":\"voLTE Service:1.0\",\"resources\":[{\"resourceName\":\"vIMS\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-vBAS-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}},{\"vnfProfileId\":\"zte-vMME-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad0\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"vEPC\",\"resourceDefId\":\"61c3e96e-0970-4871-b6e0-3b6de7561516\",\"resourceId\":\"62c3e96e-0970-4871-b6e0-3b6de7561512\",\"nsParameters\":{\"locationConstraints\":[{\"vnfProfileId\":\"zte-CSCF-1.0\",\"locationConstraints\":{\"vimId\":\"4050083f-465f-4838-af1e-47a545222ad1\"}}],\"additionalParamForNs\":{}}},{\"resourceName\":\"underlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561513\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561514\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}},{\"resourceName\":\"overlayvpn\",\"resourceDefId\":\"60c3e96e-0970-4871-b6e0-3b6de7561517\",\"resourceId\":\"60c3e96e-0970-4871-b6e0-3b6de7561518\",\"nsParameters\":{\"locationConstraints\":[],\"additionalParamForNs\":{\"externalDataNetworkName\":\"Flow_out_net\",\"m6000_mng_ip\":\"181.18.20.2\",\"externalCompanyFtpDataNetworkName\":\"Flow_out_net\",\"externalPluginManageNetworkName\":\"plugin_net_2014\",\"externalManageNetworkName\":\"mng_net_2017\",\"sfc_data_network\":\"sfc_data_net_2016\",\"NatIpRange\":\"210.1.1.10-210.1.1.20\",\"location\":\"4050083f-465f-4838-af1e-47a545222ad0\",\"sdncontroller\":\"9b9f02c0-298b-458a-bc9c-be3692e4f35e\"}}}]}}}";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr.indexOf("SVC2000") != -1);
}
-
+
@Test
- public void createE2EServiceInstanceTestForEmptyRequest(){
- try{
- E2EServiceInstances instance = new E2EServiceInstances();
- String request = "";
- Response resp = instance.createE2EServiceInstance(request, "v3");
- String respStr = resp.getEntity().toString();
- assertTrue(respStr.indexOf("Mapping of request to JSON object failed. No content to map to Object due to end of input") != -1);
- }catch(Exception e){
- //TODO: need to catch
- }
+ public void createE2EServiceInstanceTestForEmptyRequest() {
+
+ new MockUp<E2EServiceInstances>() {
+ @Mock
+ private void createOperationStatusRecordForError(Action action,
+ String requestId) throws MsoDatabaseException {
+
+ }
+ };
+ E2EServiceInstances instance = new E2EServiceInstances();
+ String request = "";
+ Response resp = instance.createE2EServiceInstance(request, "v3");
+ String respStr = resp.getEntity().toString();
+ assertTrue(respStr
+ .indexOf("Mapping of request to JSON object failed. No content to map to Object due to end of input") != -1);
}
-
+
@Test
- public void deleteE2EServiceInstanceTestNormal(){
+ public void deleteE2EServiceInstanceTestNormal() {
E2EServiceInstances instance = new E2EServiceInstances();
String request = "{\"globalSubscriberId\":\"299392392\",\"serviceType\":\"VoLTE\"}";
- Response resp = instance.deleteE2EServiceInstance(request, "v3", "12345678");
+ Response resp = instance.deleteE2EServiceInstance(request, "v3",
+ "12345678");
String respStr = resp.getEntity().toString();
assertTrue(respStr.indexOf("SVC1000") != -1);
}
+
+ @Test
+ public void getE2EServiceInstanceTest() {
+
+ new MockUp<RequestsDatabase>() {
+ @Mock
+ public OperationStatus getOperationStatus(String serviceId,
+ String operationId) {
+ OperationStatus os = new OperationStatus();
+ os.setOperation("");
+ os.setOperationContent("");
+ os.setOperationId("123456");
+ os.setProgress("");
+ os.setServiceId("12345");
+ os.setServiceName("VoLTE");
+ os.setReason("");
+ os.setResult("");
+ os.setUserId("");
+ return os;
+ }
+ };
+
+ E2EServiceInstances instance = new E2EServiceInstances();
+ Response resp = instance
+ .getE2EServiceInstances("12345", "v3", "123456");
+
+ }
}