### Question:
AAICreateResources extends AAIResource { public Optional<GenericVnf> getVnfInstance(String vnfId) { try { AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); AAIResultWrapper aaiResponse = getAaiClient().get(vnfURI); Optional<GenericVnf> vnf = aaiResponse.asBean(GenericVnf.class); return vnf; } catch (Exception ex) { logger.error("Exception in getVnfInstance", ex); return Optional.empty(); } }  void createAAIProject(String projectName, String serviceInstance); void createAAIOwningEntity(String owningEntityId, String owningEntityName, String serviceInstance); boolean existsOwningEntity(String owningEntityId); void connectOwningEntityandServiceInstance(String owningEntityId, String serviceInstance); void createAAIPlatform(String platformName, String vnfId); void createAAILineOfBusiness(String lineOfBusiness, String vnfId); void createAAIServiceInstance(String globalCustomerId, String serviceType, String serviceInstanceId); Optional<GenericVnf> getVnfInstance(String vnfId);  }### Answer:
@Test public void getVnfInstanceTest() { AAIResultWrapper aaiResultWrapper = new AAIResultWrapper("vnfUriAaiResponse"); doReturn(aaiResultWrapper).when(aaiResourcesClient).get(isA(AAIResourceUri.class)); Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); verify(aaiResourcesClient, times(1)).get(vnfURI); assertEquals(actualVnf, aaiResultWrapper.asBean(GenericVnf.class)); }
@Test public void getVnfInstanceExceptionTest() { doThrow(RuntimeException.class).when(aaiResourcesClient).get(isA(AAIResourceUri.class)); Optional<GenericVnf> actualVnf = aaiCreateResources.getVnfInstance(vnfId); AAIResourceUri vnfURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId)); verify(aaiResourcesClient, times(1)).get(vnfURI); assertEquals(actualVnf, Optional.empty()); }