InventoryServiceIspn implements InventoryService { @Override public Optional<Resource> getResourceById(String id) { return getRawResource(id).map(r -> Resource.fromRaw(r, this::getResourceType)); } InventoryServiceIspn();   InventoryServiceIspn(Cache<String, Object> resource, Cache<String, Object> resourceType, String configPath, InventoryStatsMBean inventoryStatsMBean, ScrapeConfig scrapeConfig, File scrapeLocation); @Override void addResource(RawResource r); @Override void addResource(Collection<RawResource> resources); @Override void addResourceType(ResourceType rt); @Override void addResourceType(Collection<ResourceType> resourceTypes); @Override void deleteResources(Collection<String> ids); @Override void deleteAllResources(); @Override void deleteResourceTypes(Collection<String> typeIds); @Override void deleteAllTypes(); @Override Optional<Resource> getResourceById(String id); @Override Optional<ResourceNode> getTree(String parentId); @Override ResultSet<Resource> getResources(ResourceFilter filter, long startOffset, int maxResults); @Override ResultSet<Resource> getResources(ResourceFilter filter); @Override ResultSet<ResourceType> getResourceTypes(long startOffset, int maxResults); @Override ResultSet<ResourceType> getResourceTypes(); @Override Optional<ResourceType> getResourceType(String typeId); @Override Optional<String> getAgentConfig(String templateName); @Override Optional<String> getJMXExporterConfig(String templateName); @Override boolean isRunning(); @Override ResultSet<Resource> getChildren(String parentId); @Override ResultSet<Resource> getChildren(String parentId, long startOffset, int maxResults); @Override void buildExport(OutputStream os); @Override InventoryHealth getHealthStatus(); @Override void buildMetricsEndpoints();  }
@Test public void shouldGetResourcesById() { Optional<Resource> eap1 = service.getResourceById("EAP-1"); assertThat(eap1).isPresent() .map(Resource::getName) .hasValue("EAP-1"); assertThat(eap1) .map(Resource::getType) .hasValueSatisfying(type -> assertThat(type.getId()).isEqualTo("EAP")); assertThat(service.getResourceById("EAP-2")).isPresent() .map(Resource::getName) .hasValue("EAP-2"); assertThat(service.getResourceById("child-1")).isPresent() .map(Resource::getName) .hasValue("Child 1"); }
@Test public void shouldNotGetResourcesById() { assertThat(service.getResourceById("nada")).isNotPresent(); }