### Question:
CnfAdapterService { public ResponseEntity<InstanceResponse> createInstance(BpmnInstanceRequest bpmnInstanceRequest) throws JsonParseException, JsonMappingException, IOException { try { logger.info("CnfAdapterService createInstance called"); MulticloudInstanceRequest multicloudInstanceRequest = new MulticloudInstanceRequest(); ResponseEntity<InstanceResponse> instanceResponse = null; if (bpmnInstanceRequest.getK8sRBProfileName() != null) { multicloudInstanceRequest.setCloudRegion(bpmnInstanceRequest.getCloudRegionId()); multicloudInstanceRequest.setLabels(bpmnInstanceRequest.getLabels()); multicloudInstanceRequest.setOverrideValues(bpmnInstanceRequest.getOverrideValues()); multicloudInstanceRequest.setProfileName(bpmnInstanceRequest.getK8sRBProfileName()); multicloudInstanceRequest.setRbName(bpmnInstanceRequest.getModelInvariantId()); multicloudInstanceRequest.setRbVersion(bpmnInstanceRequest.getModelVersionId()); multicloudInstanceRequest.setVfModuleUuid(bpmnInstanceRequest.getVfModuleUUID()); } else { logger.error("k8sProfileName should not be null"); return instanceResponse; } String uri = "http: String endpoint = UriBuilder.fromUri(uri).path(INSTANCE_CREATE_PATH).build().toString(); HttpEntity<?> entity = getHttpEntity(multicloudInstanceRequest); instanceResponse = restTemplate.exchange(endpoint, HttpMethod.POST, entity, InstanceResponse.class); return instanceResponse; } catch (HttpClientErrorException e) { logger.error("Error Calling Multicloud, e"); if (HttpStatus.SC_NOT_FOUND == e.getStatusCode().value()) { throw new EntityNotFoundException(e.getResponseBodyAsString()); } throw e; } catch (HttpStatusCodeException e) { logger.error("Error in Multicloud, e"); String responseString = e.getResponseBodyAsString(); InstanceResponse result = new InstanceResponse(responseString.trim()); return ResponseEntity.status(e.getStatusCode()).body(result); } }  ResponseEntity<String> healthCheck(); ResponseEntity<InstanceResponse> createInstance(BpmnInstanceRequest bpmnInstanceRequest); ResponseEntity<InstanceResponse> getInstanceByInstanceId(String instanceId); ResponseEntity<InstanceStatusResponse> getInstanceStatusByInstanceId(String instanceId); ResponseEntity<InstanceMiniResponseList> getInstanceByRBNameOrRBVersionOrProfileName(String rbName,
            String rbVersion, String profileName); ResponseEntity<String> deleteInstanceByInstanceId(String instanceId);  }### Answer:
@Test public void createInstanceTest() throws Exception { ResponseEntity<InstanceResponse> response = new ResponseEntity<InstanceResponse>(HttpStatus.OK); BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest(); bpmnInstanceRequest.setK8sRBProfileName("k8sRBProfileName"); Mockito.when(restTemplate.exchange(Matchers.anyString(), Matchers.any(HttpMethod.class), Matchers.<HttpEntity<?>>any(), Matchers.<Class<InstanceResponse>>any())).thenReturn(response); ResponseEntity<InstanceResponse> actualResponse = cnfAdapterService.createInstance(bpmnInstanceRequest); Assert.assertNotNull(response); Assert.assertEquals(actualResponse.getStatusCode(), response.getStatusCode()); }
@Test public void createInstanceExceptionTest() throws Exception { BpmnInstanceRequest bpmnInstanceRequest = new BpmnInstanceRequest(); ResponseEntity<InstanceResponse> response = cnfAdapterService.createInstance(bpmnInstanceRequest); Assert.assertNull(response); }