Search in sources :

Example 1 with GenericResourceApiServiceOperationInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation in project so by onap.

the class ServiceTopologyOperationMapper method reqMapper.

public GenericResourceApiServiceOperationInformation reqMapper(SDNCSvcOperation svcOperation, SDNCSvcAction svcAction, GenericResourceApiRequestActionEnumeration resourceAction, ServiceInstance serviceInstance, Customer customer, RequestContext requestContext) {
    String sdncReqId = UUID.randomUUID().toString();
    String msoRequestId = UUID.randomUUID().toString();
    if (requestContext != null && requestContext.getMsoRequestId() != null) {
        msoRequestId = requestContext.getMsoRequestId();
    }
    GenericResourceApiServiceOperationInformation servOpInput = new GenericResourceApiServiceOperationInformation();
    GenericResourceApiSdncrequestheaderSdncRequestHeader sdncRequestHeader = generalTopologyObjectMapper.buildSdncRequestHeader(svcAction, sdncReqId);
    GenericResourceApiRequestinformationRequestInformation reqInfo = generalTopologyObjectMapper.buildGenericResourceApiRequestinformationRequestInformation(msoRequestId, resourceAction);
    GenericResourceApiServiceinformationServiceInformation servInfo = generalTopologyObjectMapper.buildServiceInformation(serviceInstance, requestContext, customer, true);
    GenericResourceApiServicerequestinputServiceRequestInput servReqInfo = new GenericResourceApiServicerequestinputServiceRequestInput();
    servReqInfo.setServiceInstanceName(serviceInstance.getServiceInstanceName());
    servOpInput.setSdncRequestHeader(sdncRequestHeader);
    servOpInput.setRequestInformation(reqInfo);
    servOpInput.setServiceInformation(servInfo);
    servOpInput.setServiceRequestInput(servReqInfo);
    if (requestContext != null && requestContext.getUserParams() != null) {
        for (Map.Entry<String, Object> entry : requestContext.getUserParams().entrySet()) {
            GenericResourceApiServicerequestinputServiceRequestInput serviceRequestInput = new GenericResourceApiServicerequestinputServiceRequestInput();
            serviceRequestInput.setServiceInstanceName(serviceInstance.getServiceInstanceName());
            GenericResourceApiParam serviceInputParameters = new GenericResourceApiParam();
            GenericResourceApiParamParam paramItem = new GenericResourceApiParamParam();
            paramItem.setName(entry.getKey());
            paramItem.setValue(generalTopologyObjectMapper.mapUserParamValue(entry.getValue()));
            serviceInputParameters.addParamItem(paramItem);
            serviceRequestInput.serviceInputParameters(serviceInputParameters);
            servOpInput.setServiceRequestInput(serviceRequestInput);
        }
    }
    return servOpInput;
}
Also used : GenericResourceApiServiceinformationServiceInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation) GenericResourceApiSdncrequestheaderSdncRequestHeader(org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader) GenericResourceApiServicerequestinputServiceRequestInput(org.onap.sdnc.northbound.client.model.GenericResourceApiServicerequestinputServiceRequestInput) GenericResourceApiRequestinformationRequestInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation) GenericResourceApiServiceOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation) GenericResourceApiParam(org.onap.sdnc.northbound.client.model.GenericResourceApiParam) GenericResourceApiParamParam(org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam) Map(java.util.Map)

Example 2 with GenericResourceApiServiceOperationInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation in project so by onap.

the class SDNCChangeAssignTasks method changeModelServiceInstance.

public void changeModelServiceInstance(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID);
        GenericResourceApiServiceOperationInformation req = sdncServiceInstanceResources.changeModelServiceInstance(serviceInstance, gBBInput.getCustomer(), gBBInput.getRequestContext());
        SDNCRequest sdncRequest = new SDNCRequest();
        sdncRequest.setSDNCPayload(req);
        sdncRequest.setTopology(SDNCTopology.SERVICE);
        execution.setVariable(SDNC_REQUEST, sdncRequest);
    } catch (Exception ex) {
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : SDNCRequest(org.onap.so.client.sdnc.beans.SDNCRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericResourceApiServiceOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)

Example 3 with GenericResourceApiServiceOperationInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation in project so by onap.

the class SDNCServiceInstanceResourcesTest method assignServiceInstanceSuccessTest.

@Test
public void assignServiceInstanceSuccessTest() throws Exception {
    doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
    sdncServiceInstanceResources.assignServiceInstance(serviceInstance, customer, requestContext);
    verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.ASSIGN), eq(GenericResourceApiRequestActionEnumeration.CREATESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) GenericResourceApiServiceOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Test(org.junit.Test)

Example 4 with GenericResourceApiServiceOperationInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation in project so by onap.

the class SDNCServiceInstanceResourcesTest method unassignServiceInstanceSuccessTest.

@Test
public void unassignServiceInstanceSuccessTest() throws Exception {
    doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
    sdncServiceInstanceResources.unassignServiceInstance(serviceInstance, customer, requestContext);
    verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) GenericResourceApiServiceOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Test(org.junit.Test)

Example 5 with GenericResourceApiServiceOperationInformation

use of org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation in project so by onap.

the class SDNCServiceInstanceResourcesTest method deleteServiceInstanceSuccessTest.

@Test
public void deleteServiceInstanceSuccessTest() throws Exception {
    doReturn(new GenericResourceApiServiceOperationInformation()).when(MOCK_serviceTopologyOperationMapper).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
    sdncServiceInstanceResources.deleteServiceInstance(serviceInstance, customer, requestContext);
    verify(MOCK_serviceTopologyOperationMapper, times(1)).reqMapper(eq(SDNCSvcOperation.SERVICE_TOPOLOGY_OPERATION), eq(SDNCSvcAction.DELETE), eq(GenericResourceApiRequestActionEnumeration.DELETESERVICEINSTANCE), any(ServiceInstance.class), any(Customer.class), any(RequestContext.class));
}
Also used : Customer(org.onap.so.bpmn.servicedecomposition.bbobjects.Customer) GenericResourceApiServiceOperationInformation(org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) Test(org.junit.Test)

Aggregations

GenericResourceApiServiceOperationInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiServiceOperationInformation)16 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)10 Test (org.junit.Test)9 Customer (org.onap.so.bpmn.servicedecomposition.bbobjects.Customer)9 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)9 SDNCRequest (org.onap.so.client.sdnc.beans.SDNCRequest)9 GeneralBuildingBlock (org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 BaseTaskTest (org.onap.so.bpmn.BaseTaskTest)3 JsonParseException (com.fasterxml.jackson.core.JsonParseException)2 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)2 IOException (java.io.IOException)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 GenericResourceApiOnapmodelinformationOnapModelInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiOnapmodelinformationOnapModelInformation)1 GenericResourceApiParam (org.onap.sdnc.northbound.client.model.GenericResourceApiParam)1 GenericResourceApiParamParam (org.onap.sdnc.northbound.client.model.GenericResourceApiParamParam)1 GenericResourceApiRequestinformationRequestInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiRequestinformationRequestInformation)1 GenericResourceApiSdncrequestheaderSdncRequestHeader (org.onap.sdnc.northbound.client.model.GenericResourceApiSdncrequestheaderSdncRequestHeader)1 GenericResourceApiServiceinformationServiceInformation (org.onap.sdnc.northbound.client.model.GenericResourceApiServiceinformationServiceInformation)1