Search in sources :

Example 16 with CreateVfModuleRequest

use of org.onap.so.adapters.vnfrest.CreateVfModuleRequest in project so by onap.

the class JAXBMarshallingTest method xmlUnMarshalTest.

@Test
public void xmlUnMarshalTest() throws IOException, JAXBException {
    JAXBContext context = JAXBContext.newInstance(CreateVfModuleRequest.class);
    CreateVfModuleRequest request = (CreateVfModuleRequest) context.createUnmarshaller().unmarshal(Files.newBufferedReader(Paths.get("src/test/resources/createVfModuleRequest-with-params.xml")));
    assertEquals("ubuntu-16-04-cloud-amd64", request.getVfModuleParams().get("vcpe_image_name"));
    assertEquals("10.2.0.0/24", request.getVfModuleParams().get("cpe_public_net_cidr"));
    assertEquals("", request.getVfModuleParams().get("workload_context"));
    assertEquals("[\"a\",\"b\",\"c\"]", request.getVfModuleParams().get("raw-json-param"));
}
Also used : CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) JAXBContext(javax.xml.bind.JAXBContext) Test(org.junit.Test)

Example 17 with CreateVfModuleRequest

use of org.onap.so.adapters.vnfrest.CreateVfModuleRequest in project so by onap.

the class VnfAdapterCreateTasks method createVfModule.

/**
 * This method is used for creating the request for the VfModule.
 *
 * @param execution
 * @return
 */
public void createVfModule(BuildingBlockExecution execution) {
    try {
        GeneralBuildingBlock gBBInput = execution.getGeneralBuildingBlock();
        ServiceInstance serviceInstance = gBBInput.getCustomer().getServiceSubscription().getServiceInstances().get(0);
        VfModule vfModule = extractPojosForBB.extractByKey(execution, ResourceKey.VF_MODULE_ID);
        GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID);
        VolumeGroup volumeGroup = null;
        try {
            volumeGroup = extractPojosForBB.extractByKey(execution, ResourceKey.VOLUME_GROUP_ID);
        } catch (BBObjectNotFoundException bbException) {
            logger.info("Volume Group not found in GBB. ");
        }
        CloudRegion cloudRegion = gBBInput.getCloudRegion();
        RequestContext requestContext = gBBInput.getRequestContext();
        OrchestrationContext orchestrationContext = gBBInput.getOrchContext();
        String sdncVfModuleQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + vfModule.getVfModuleId());
        String sdncVnfQueryResponse = execution.getVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId());
        CreateVfModuleRequest createVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, volumeGroup, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
        execution.setVariable(VNFREST_REQUEST, createVfModuleRequest.toXmlString());
    } catch (Exception ex) {
        logger.error("Exception occurred", ex);
        exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex);
    }
}
Also used : BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException) CloudRegion(org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion) CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) GeneralBuildingBlock(org.onap.so.bpmn.servicedecomposition.entities.GeneralBuildingBlock) GenericVnf(org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf) VolumeGroup(org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup) ServiceInstance(org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance) RequestContext(org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext) VfModule(org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule) OrchestrationContext(org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext) BBObjectNotFoundException(org.onap.so.client.exception.BBObjectNotFoundException)

Example 18 with CreateVfModuleRequest

use of org.onap.so.adapters.vnfrest.CreateVfModuleRequest in project so by onap.

the class VnfAdapterVfModuleResourcesTest method before.

@Before
public void before() {
    requestContext = buildRequestContext();
    serviceInstance = buildServiceInstance();
    genericVnf = buildGenericVnf();
    vfModule = buildVfModule();
    cloudRegion = buildCloudRegion();
    orchestrationContext = buildOrchestrationContext();
    orchestrationContext.setIsRollbackEnabled(true);
    sdncVnfQueryResponse = new String();
    sdncVfModuleQueryResponse = new String();
    createVfModuleRequest = new CreateVfModuleRequest();
    createVfModuleRequest.setCloudSiteId("cloudSiteId");
    deleteVfModuleRequest = new DeleteVfModuleRequest();
    deleteVfModuleRequest.setCloudSiteId("cloudSiteId");
}
Also used : CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) DeleteVfModuleRequest(org.onap.so.adapters.vnfrest.DeleteVfModuleRequest) Before(org.junit.Before)

Example 19 with CreateVfModuleRequest

use of org.onap.so.adapters.vnfrest.CreateVfModuleRequest in project so by onap.

the class VnfAdapterVfModuleResourcesTest method test_createVfModule.

@Test
public void test_createVfModule() throws Exception {
    doReturn(createVfModuleRequest).when(MOCK_vnfAdapterVfModuleObjectMapper).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    CreateVfModuleRequest actualCreateVfModuleRequest = vnfAdapterVfModuleResources.createVfModuleRequest(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    verify(MOCK_vnfAdapterVfModuleObjectMapper, times(1)).createVfModuleRequestMapper(requestContext, cloudRegion, orchestrationContext, serviceInstance, genericVnf, vfModule, null, sdncVnfQueryResponse, sdncVfModuleQueryResponse);
    assertNotNull(createVfModuleRequest);
    assertNotNull(actualCreateVfModuleRequest);
    assertEquals(createVfModuleRequest, actualCreateVfModuleRequest);
}
Also used : CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) Test(org.junit.Test)

Example 20 with CreateVfModuleRequest

use of org.onap.so.adapters.vnfrest.CreateVfModuleRequest in project so by onap.

the class VnfAdapterClientIT method createVfModuleTestThrowException.

@Test(expected = VnfAdapterClientException.class)
public void createVfModuleTestThrowException() throws JsonProcessingException, VnfAdapterClientException {
    CreateVfModuleRequest request = new CreateVfModuleRequest();
    request.setCloudSiteId(TESTING_ID);
    VfModuleExceptionResponse mockResponse = new VfModuleExceptionResponse();
    mockResponse.setMessage("Error in create Vf module");
    wireMockServer.stubFor(post(urlPathEqualTo(REST_ENDPOINT + "/" + AAI_VNF_ID + "/vf-modules")).willReturn(aResponse().withHeader("Content-Type", "application/json").withBody(mapper.writeValueAsString(mockResponse)).withStatus(500)));
    client.createVfModule(AAI_VNF_ID, request);
}
Also used : CreateVfModuleRequest(org.onap.so.adapters.vnfrest.CreateVfModuleRequest) VfModuleExceptionResponse(org.onap.so.adapters.vnfrest.VfModuleExceptionResponse) BaseIntegrationTest(org.onap.so.BaseIntegrationTest) Test(org.junit.Test)

Aggregations

CreateVfModuleRequest (org.onap.so.adapters.vnfrest.CreateVfModuleRequest)24 Test (org.junit.Test)18 VfModule (org.onap.so.bpmn.servicedecomposition.bbobjects.VfModule)14 CloudRegion (org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion)13 GenericVnf (org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf)13 ServiceInstance (org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance)13 OrchestrationContext (org.onap.so.bpmn.servicedecomposition.generalobjects.OrchestrationContext)13 RequestContext (org.onap.so.bpmn.servicedecomposition.generalobjects.RequestContext)13 HashMap (java.util.HashMap)11 ModelInfoGenericVnf (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoGenericVnf)10 ModelInfoServiceInstance (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoServiceInstance)10 ModelInfoVfModule (org.onap.so.bpmn.servicedecomposition.modelinfo.ModelInfoVfModule)10 StringReader (java.io.StringReader)3 VolumeGroup (org.onap.so.bpmn.servicedecomposition.bbobjects.VolumeGroup)3 BaseIntegrationTest (org.onap.so.BaseIntegrationTest)2 CreateNetworkRequest (org.onap.so.adapters.nwrest.CreateNetworkRequest)2 CreateVolumeGroupRequest (org.onap.so.adapters.vnfrest.CreateVolumeGroupRequest)2 DeleteVfModuleRequest (org.onap.so.adapters.vnfrest.DeleteVfModuleRequest)2 ArrayList (java.util.ArrayList)1 JAXBContext (javax.xml.bind.JAXBContext)1