### Question:
VfcManager { public RestfulResponse createNs(NSResourceInputParameter segInput) throws ApplicationException { String csarId = segInput.getNsServiceModelUUID(); LOGGER.info("serviceTemplateId is {}, id is {}", csarId, csarId); LOGGER.info("create ns -> begin"); String url = getUrl(null, CommonConstant.Step.CREATE); String methodType = CommonConstant.MethodType.POST; NsCreateReq oRequest = new NsCreateReq(); oRequest.setCsarId(csarId); oRequest.setNsName(segInput.getNsServiceName()); oRequest.setDescription(segInput.getNsServiceDescription()); CustomerModel context = new CustomerModel(); context.setGlobalCustomerId(segInput.getNsOperationKey().getGlobalSubscriberId()); context.setServiceType(segInput.getNsOperationKey().getServiceType()); oRequest.setContext(context); String createReq = JsonUtil.marshal(oRequest); RestfulResponse createRsp = restfulUtil.send(url, methodType, createReq); ValidateUtil.assertObjectNotNull(createRsp); LOGGER.info("create ns response status is : {}", createRsp.getStatus()); LOGGER.info("create ns response content is : {}", createRsp.getResponseContent()); ResourceOperationStatus status = new ResourceOperationStatus(segInput.getNsOperationKey().getServiceId(), segInput.getNsOperationKey().getOperationId(), segInput.getNsOperationKey().getNodeTemplateUUID()); status.setStatus(RequestsDbConstant.Status.PROCESSING); status = resourceOperationStatusRepository.save(status); if (!HttpCode.isSucess(createRsp.getStatus())) { LOGGER.error("update segment operation status : fail to create ns"); status.setProgress("40"); status.setStatusDescription("NS is created"); status.setStatus(RequestsDbConstant.Status.ERROR); status.setErrorCode(String.valueOf(createRsp.getStatus())); resourceOperationStatusRepository.save(status); throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.FAIL_TO_CREATE_NS); } @SuppressWarnings("unchecked") Map<String, String> rsp = JsonUtil.unMarshal(createRsp.getResponseContent(), Map.class); String nsInstanceId = rsp.get(CommonConstant.NS_INSTANCE_ID); if (ValidateUtil.isStrEmpty(nsInstanceId)) { LOGGER.error("Invalid instanceId from create operation"); throw new ApplicationException(HttpCode.INTERNAL_SERVER_ERROR, DriverExceptionID.INVALID_RESPONSEE_FROM_CREATE_OPERATION); } LOGGER.info("create ns -> end"); LOGGER.info("save segment and operaton info -> begin"); AaiUtil.addRelation(segInput.getNsOperationKey().getGlobalSubscriberId(), segInput.getNsOperationKey().getServiceType(), segInput.getNsOperationKey().getServiceId(), nsInstanceId); LOGGER.info("save segment and operation info -> end"); return createRsp; } VfcManager(); RestfulResponse createNs(NSResourceInputParameter segInput); RestfulResponse deleteNs(NsOperationKey nsOperationKey, String nsInstanceId); RestfulResponse instantiateNs(String nsInstanceId, NSResourceInputParameter segInput); RestfulResponse terminateNs(NsOperationKey nsOperationKey, String nsInstanceId); RestfulResponse getNsProgress(NsOperationKey nsOperationKey, String jobId); RestfulResponse scaleNs(String nsInstanceId, NSResourceInputParameter segInput);  }### Answer:
@Test public void createNs() throws Exception { NSResourceInputParameter segInput = new NSResourceInputParameter(); segInput.setNsOperationKey(new NsOperationKey()); RestfulResponse restfulResponse = new RestfulResponse(); restfulResponse.setStatus(HttpStatus.OK.value()); restfulResponse.setResponseContent("{\"" + CommonConstant.NS_INSTANCE_ID + "\": \"someNsInstanceId\"}"); when(restfulUtil.send(any(), any(), any())).thenReturn(restfulResponse); RestfulResponse response = vfcManager.createNs(segInput); assertEquals(HttpStatus.OK.value(), restfulResponse.getStatus()); }