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"));
}
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);
}
}
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");
}
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);
}
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);
}
Aggregations