### Question:
SDNCQueryTasks { public void queryVnf(BuildingBlockExecution execution) throws BBObjectNotFoundException { ServiceInstance serviceInstance = extractPojosForBB.extractByKey(execution, ResourceKey.SERVICE_INSTANCE_ID); GenericVnf genericVnf = extractPojosForBB.extractByKey(execution, ResourceKey.GENERIC_VNF_ID); String selfLink = "restconf/config/GENERIC-RESOURCE-API:services/service/" + serviceInstance.getServiceInstanceId() + "/service-data/vnfs/vnf/" + genericVnf.getVnfId() + "/vnf-data/vnf-topology/"; try { if (genericVnf.getSelflink() == null) { genericVnf.setSelflink(selfLink); } String response = sdncVnfResources.queryVnf(genericVnf); execution.setVariable(SDNCQUERY_RESPONSE + genericVnf.getVnfId(), response); } catch (BadResponseException ex) { logger.error("Exception occurred", ex); if (!ex.getMessage().equals(NO_RESPONSE_FROM_SDNC)) { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SDNC); } else { exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SO); } } catch (Exception ex) { logger.error("Exception occurred", ex); exceptionUtil.buildAndThrowWorkflowException(execution, 7000, ex, ONAPComponents.SO); } }  void queryVnf(BuildingBlockExecution execution); void queryVfModule(BuildingBlockExecution execution); void queryVfModuleForVolumeGroup(BuildingBlockExecution execution); static final String SDNCQUERY_RESPONSE; }### Answer:
@Test public void queryVnfTest() throws Exception { String sdncQueryResponse = "response"; doReturn(sdncQueryResponse).when(sdncVnfResources).queryVnf(genericVnf); assertNotEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId())); sdncQueryTasks.queryVnf(execution); assertEquals(sdncQueryResponse, execution.getVariable("SDNCQueryResponse_" + genericVnf.getVnfId())); verify(sdncVnfResources, times(1)).queryVnf(genericVnf); }
@Test public void queryVnfBadResponseExceptionTest() throws Exception { BadResponseException exception = new BadResponseException("Error received from SDNC"); doThrow(exception).when(sdncVnfResources).queryVnf(genericVnf); expectedException.expect(BpmnError.class); sdncQueryTasks.queryVnf(execution); verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, ONAPComponents.SDNC); }
@Test public void queryVnfBadResponseExceptionNoResponseTest() throws Exception { BadResponseException exception = new BadResponseException("Error did not receive a response from SDNC."); doThrow(exception).when(sdncVnfResources).queryVnf(genericVnf); expectedException.expect(BpmnError.class); sdncQueryTasks.queryVnf(execution); verify(exceptionUtil, times(1)).buildAndThrowWorkflowException(execution, 700, exception, ONAPComponents.SO); }