@Test public void testGetAllAsCloudResourceStatusWhenHasResource() { Resource resource = new Resource(); List<Resource> resources = Collections.singletonList(resource); CloudResource cloudResource = CloudResource.builder() .type(ResourceType.HEAT_STACK) .status(CommonStatus.CREATED) .name("name") .params(Collections.emptyMap()) .build(); Mockito.when(resourceRepository.findAllByStackId(1L)).thenReturn(resources); Mockito.when(conversionService.convert(resource, CloudResource.class)).thenReturn(cloudResource); List<CloudResourceStatus> actual = underTest.getAllAsCloudResourceStatus(1L); Assert.assertEquals(1L, actual.size()); Assert.assertEquals(cloudResource, actual.get(0).getCloudResource()); Assert.assertEquals(ResourceStatus.CREATED, actual.get(0).getStatus()); }
public List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId) { List<Resource> resources = repository.findAllByStackId(stackId); List<CloudResourceStatus> list = new ArrayList<>(); resources.forEach(r -> { CloudResource cloudResource = conversionService.convert(r, CloudResource.class); list.add(new CloudResourceStatus(cloudResource, ResourceStatus.CREATED)); }); return list; }
ResourceService { public List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId) { List<Resource> resources = repository.findAllByStackId(stackId); List<CloudResourceStatus> list = new ArrayList<>(); resources.forEach(r -> { CloudResource cloudResource = conversionService.convert(r, CloudResource.class); list.add(new CloudResourceStatus(cloudResource, ResourceStatus.CREATED)); }); return list; } }
ResourceService { public List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId) { List<Resource> resources = repository.findAllByStackId(stackId); List<CloudResourceStatus> list = new ArrayList<>(); resources.forEach(r -> { CloudResource cloudResource = conversionService.convert(r, CloudResource.class); list.add(new CloudResourceStatus(cloudResource, ResourceStatus.CREATED)); }); return list; }  }
ResourceService { public List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId) { List<Resource> resources = repository.findAllByStackId(stackId); List<CloudResourceStatus> list = new ArrayList<>(); resources.forEach(r -> { CloudResource cloudResource = conversionService.convert(r, CloudResource.class); list.add(new CloudResourceStatus(cloudResource, ResourceStatus.CREATED)); }); return list; }  List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId); Set<Resource> getNotInstanceRelatedByStackId(Long stackId); Collection<Resource> getAllByStackId(Long stackId); Optional<Resource> findByStackIdAndNameAndType(Long stackId, String name, ResourceType type); List<Resource> findByStackIdAndType(Long stackId,  ResourceType type); void delete(Resource resource); Resource save(Resource resource); Iterable<Resource> saveAll(Iterable<Resource> resources); Optional<Resource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType); }
ResourceService { public List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId) { List<Resource> resources = repository.findAllByStackId(stackId); List<CloudResourceStatus> list = new ArrayList<>(); resources.forEach(r -> { CloudResource cloudResource = conversionService.convert(r, CloudResource.class); list.add(new CloudResourceStatus(cloudResource, ResourceStatus.CREATED)); }); return list; }  List<CloudResourceStatus> getAllAsCloudResourceStatus(Long stackId); Set<Resource> getNotInstanceRelatedByStackId(Long stackId); Collection<Resource> getAllByStackId(Long stackId); Optional<Resource> findByStackIdAndNameAndType(Long stackId, String name, ResourceType type); List<Resource> findByStackIdAndType(Long stackId,  ResourceType type); void delete(Resource resource); Resource save(Resource resource); Iterable<Resource> saveAll(Iterable<Resource> resources); Optional<Resource> findByResourceReferenceAndStatusAndType(String resourceReference, CommonStatus status, ResourceType resourceType);  }