### Question:
PingNetServiceDiscoveryComponent implements ResourceDiscoveryComponent, ManualAddFacet { @Override public DiscoveredResourceDetails discoverResource(Configuration config, ResourceDiscoveryContext resourceDiscoveryContext) throws InvalidPluginConfigurationException { InetAddress address = PingNetServiceComponent.createComponentConfiguration(config); DiscoveredResourceDetails details = new DiscoveredResourceDetails(resourceDiscoveryContext.getResourceType(), address.getHostAddress(), RESOURCE_NAME_PREFIX + address.getHostAddress(), null, null, config, null); return details; }  @Override Set discoverResources(ResourceDiscoveryContext resourceDiscoveryContext); @Override DiscoveredResourceDetails discoverResource(Configuration config,
        ResourceDiscoveryContext resourceDiscoveryContext);  }### Answer:
@Test public void testValidComponentConfiguration() { try { DiscoveredResourceDetails resourceDetails = pingNetServiceDiscoveryComponent.discoverResource( configuration, resourceDiscoveryContext); assertEquals(resourceDetails.getResourceType(), resourceType); } catch (InvalidPluginConfigurationException e) { fail("Component configuration should be valid", e); } }
@Test public void testMissingAddress() { try { configuration.remove(ConfigKeys.ADDRESS); pingNetServiceDiscoveryComponent.discoverResource(configuration, resourceDiscoveryContext); fail("Component configuration should be invalid"); } catch (InvalidPluginConfigurationException e) { assertEquals(e.getMessage(), "Address is not defined"); } }
@Test public void testMalformedAddress() { String configAddress = "pipomolo"; try { configuration.setSimpleValue(ConfigKeys.ADDRESS, configAddress); pingNetServiceDiscoveryComponent.discoverResource(configuration, resourceDiscoveryContext); fail("Component configuration should be invalid"); } catch (InvalidPluginConfigurationException e) { assertEquals(e.getCause().getClass(), UnknownHostException.class); } }