@Test public void testGetByResourceReferenceShouldReturnEmptyList() { when(resourceService.findByResourceReferenceAndStatusAndType(RESOURCE_REFERENCE, REQUESTED, AZURE_MANAGED_IMAGE)).thenReturn(Optional.empty()); Optional<CloudResource> actual = underTest.findByResourceReferenceAndStatusAndType(RESOURCE_REFERENCE, REQUESTED, AZURE_MANAGED_IMAGE); assertTrue(actual.isEmpty()); verify(resourceService).findByResourceReferenceAndStatusAndType(RESOURCE_REFERENCE, REQUESTED, AZURE_MANAGED_IMAGE); verifyNoInteractions(conversionService); }
@Override public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: {} and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource .map(resource -> conversionService.convert(resource, CloudResource.class)); }
CloudResourceRetrieverService implements ResourceRetriever { @Override public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: {} and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource .map(resource -> conversionService.convert(resource, CloudResource.class)); } }
CloudResourceRetrieverService implements ResourceRetriever { @Override public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: {} and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource .map(resource -> conversionService.convert(resource, CloudResource.class)); }  }
CloudResourceRetrieverService implements ResourceRetriever { @Override public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: {} and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource .map(resource -> conversionService.convert(resource, CloudResource.class)); }  @Override Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType); }
CloudResourceRetrieverService implements ResourceRetriever { @Override public Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType) { Optional<Resource> optionalResource = resourceService.findByResourceReferenceAndStatusAndType(resourceReference, status, resourceType); LOGGER.debug("Resource retrieved by optionalResource reference: {}, status: {} and type: {}. Is present: {}", resourceReference, status, resourceType, optionalResource.isPresent()); return optionalResource .map(resource -> conversionService.convert(resource, CloudResource.class)); }  @Override Optional<CloudResource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType);  }