Search in sources :

Example 1 with SubscriberInfo

use of org.onap.so.serviceinstancebeans.SubscriberInfo in project so by onap.

the class SubscriberInfoValidation method validate.

@Override
public ValidationInformation validate(ValidationInformation info) throws ValidationException {
    String requestScope = info.getRequestScope();
    int reqVersion = info.getReqVersion();
    Actions action = info.getAction();
    if (reqVersion > 4 && requestScope.equalsIgnoreCase(ModelType.service.name()) && action == Action.createInstance || action == Action.assignInstance) {
        SubscriberInfo subscriberInfo = info.getSir().getRequestDetails().getSubscriberInfo();
        if (subscriberInfo == null) {
            throw new ValidationException("subscriberInfo");
        }
        if (empty(subscriberInfo.getGlobalSubscriberId())) {
            throw new ValidationException("globalSubscriberId");
        }
    }
    return info;
}
Also used : ValidationException(org.onap.so.exceptions.ValidationException) Actions(org.onap.so.apihandlerinfra.Actions) SubscriberInfo(org.onap.so.serviceinstancebeans.SubscriberInfo)

Example 2 with SubscriberInfo

use of org.onap.so.serviceinstancebeans.SubscriberInfo in project so by onap.

the class E2EServiceInstances method mapReqJsonToSvcInstReq.

/**
 * Converting E2EServiceInstanceRequest to ServiceInstanceRequest and passing it to camunda engine.
 *
 * @param e2eSir
 * @return
 */
private ServiceInstancesRequest mapReqJsonToSvcInstReq(E2EServiceInstanceRequest e2eSir, String requestJSON) {
    ServiceInstancesRequest sir = new ServiceInstancesRequest();
    RequestDetails requestDetails = new RequestDetails();
    ModelInfo modelInfo = new ModelInfo();
    // ModelInvariantId
    modelInfo.setModelInvariantId(e2eSir.getService().getServiceInvariantUuid());
    // modelNameVersionId
    modelInfo.setModelNameVersionId(e2eSir.getService().getServiceUuid());
    // 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";
    // modelName
    modelInfo.setModelName(modelName);
    // modelVersion
    modelInfo.setModelVersion(modelVersion);
    // modelType
    modelInfo.setModelType(ModelType.service);
    // setting modelInfo to requestDetails
    requestDetails.setModelInfo(modelInfo);
    SubscriberInfo subscriberInfo = new SubscriberInfo();
    // globalsubscriberId
    subscriberInfo.setGlobalSubscriberId(e2eSir.getService().getGlobalSubscriberId());
    // setting subscriberInfo to requestDetails
    requestDetails.setSubscriberInfo(subscriberInfo);
    RequestInfo requestInfo = new RequestInfo();
    // instanceName
    requestInfo.setInstanceName(e2eSir.getService().getName());
    // source
    requestInfo.setSource("UUI");
    // suppressRollback
    requestInfo.setSuppressRollback(true);
    // setting requestInfo to requestDetails
    requestDetails.setRequestInfo(requestInfo);
    RequestParameters requestParameters = new RequestParameters();
    // subscriptionServiceType
    requestParameters.setSubscriptionServiceType("MOG");
    List<Map<String, Object>> userParamList = new ArrayList<>();
    Map<String, Object> userParamMap = new HashMap<>();
    // complete json request updated in the camunda
    userParamMap.put("UUIRequest", requestJSON);
    userParamMap.put("ServiceInstanceName", e2eSir.getService().getName());
    userParamList.add(userParamMap);
    requestParameters.setUserParams(userParamList);
    // setting requestParameters to requestDetails
    requestDetails.setRequestParameters(requestParameters);
    sir.setRequestDetails(requestDetails);
    return sir;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) RequestInfo(org.onap.so.serviceinstancebeans.RequestInfo) ServiceInstancesRequest(org.onap.so.serviceinstancebeans.ServiceInstancesRequest) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) JSONObject(org.json.JSONObject) Map(java.util.Map) HashMap(java.util.HashMap) SubscriberInfo(org.onap.so.serviceinstancebeans.SubscriberInfo)

Example 3 with SubscriberInfo

use of org.onap.so.serviceinstancebeans.SubscriberInfo in project so by onap.

the class AaiResourceIdValidatorTest method setupRequestDetails.

private RequestDetails setupRequestDetails() {
    RequestDetails reqDetails = new RequestDetails();
    SubscriberInfo subInfo = new SubscriberInfo();
    subInfo.setGlobalSubscriberId("id123");
    reqDetails.setSubscriberInfo(subInfo);
    RequestParameters reqParams = new RequestParameters();
    reqParams.setSubscriptionServiceType("subServiceType123");
    reqDetails.setRequestParameters(reqParams);
    ModelInfo modelInfo = new ModelInfo();
    modelInfo.setModelCustomizationId("1234567");
    reqDetails.setModelInfo(modelInfo);
    return reqDetails;
}
Also used : ModelInfo(org.onap.so.serviceinstancebeans.ModelInfo) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) SubscriberInfo(org.onap.so.serviceinstancebeans.SubscriberInfo) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters)

Example 4 with SubscriberInfo

use of org.onap.so.serviceinstancebeans.SubscriberInfo in project so by onap.

the class BBInputSetupTest method testGetCustomerAndServiceSubscription.

@Test
public void testGetCustomerAndServiceSubscription() throws JsonParseException, JsonMappingException, IOException {
    RequestDetails requestDetails = mapper.readValue(new File(RESOURCE_PATH + "RequestDetailsInput_withRelatedInstanceList.json"), RequestDetails.class);
    SubscriberInfo subscriberInfo = new SubscriberInfo();
    subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
    RequestParameters requestParams = new RequestParameters();
    requestParams.setSubscriptionServiceType("subscriptionServiceType");
    requestDetails.setRequestParameters(requestParams);
    requestDetails.setSubscriberInfo(subscriberInfo);
    String resourceId = "resourceId";
    Customer expected = new Customer();
    expected.setGlobalCustomerId("globalCustomerId");
    ServiceSubscription serviceSubscription = new ServiceSubscription();
    serviceSubscription.setServiceType("subscriptionServiceType");
    doReturn(expected).when(this.SPY_bbInputSetup).getCustomerFromRequest(requestDetails);
    doReturn(serviceSubscription).when(this.SPY_bbInputSetup).getServiceSubscription(requestDetails, expected);
    Customer actual = this.SPY_bbInputSetup.getCustomerAndServiceSubscription(requestDetails, resourceId);
    assertThat(actual, sameBeanAs(expected));
    requestDetails.setSubscriberInfo(null);
    assertThat(actual, sameBeanAs(expected));
}
Also used : ServiceSubscription(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription) Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) File(java.io.File) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) SubscriberInfo(org.onap.so.serviceinstancebeans.SubscriberInfo) RequestParameters(org.onap.so.serviceinstancebeans.RequestParameters) Test(org.junit.Test)

Example 5 with SubscriberInfo

use of org.onap.so.serviceinstancebeans.SubscriberInfo in project so by onap.

the class BBInputSetupTest method testGetCustomer.

@Test
public void testGetCustomer() throws IOException {
    Customer expected = new Customer();
    RequestDetails requestDetails = new RequestDetails();
    SubscriberInfo subscriberInfo = new SubscriberInfo();
    subscriberInfo.setGlobalSubscriberId("globalSubscriberId");
    requestDetails.setSubscriberInfo(subscriberInfo);
    org.onap.aai.domain.yang.Customer aaiCustomer = new org.onap.aai.domain.yang.Customer();
    doReturn(aaiCustomer).when(SPY_bbInputSetupUtils).getAAICustomer(requestDetails.getSubscriberInfo().getGlobalSubscriberId());
    doReturn(expected).when(bbInputSetupMapperLayer).mapAAICustomer(aaiCustomer);
    Customer actual = SPY_bbInputSetup.getCustomerFromRequest(requestDetails);
    assertThat(actual, sameBeanAs(expected));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) RequestDetails(org.onap.so.serviceinstancebeans.RequestDetails) SubscriberInfo(org.onap.so.serviceinstancebeans.SubscriberInfo) Test(org.junit.Test)

Aggregations

SubscriberInfo (org.onap.so.serviceinstancebeans.SubscriberInfo)5 RequestDetails (org.onap.so.serviceinstancebeans.RequestDetails)4 RequestParameters (org.onap.so.serviceinstancebeans.RequestParameters)3 Test (org.junit.Test)2 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)2 ModelInfo (org.onap.so.serviceinstancebeans.ModelInfo)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 JSONObject (org.json.JSONObject)1 Actions (org.onap.so.apihandlerinfra.Actions)1 ServiceSubscription (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription)1 ValidationException (org.onap.so.exceptions.ValidationException)1 RequestInfo (org.onap.so.serviceinstancebeans.RequestInfo)1 ServiceInstancesRequest (org.onap.so.serviceinstancebeans.ServiceInstancesRequest)1