### Question:
ServiceDiscoveryFileSystemProvider implements ServiceDiscoveryProvider { @Override public List<EndpointDefinition> loadServices(final String serviceName) { ServiceData serviceData = serviceDataMap.get(serviceName); if (serviceData == null) { File file = new File(dir, serviceName + ".json"); serviceData = new ServiceData(loadDefinitions(file), Timer.timer().now(), file.lastModified()); serviceDataMap.put(serviceName, serviceData); } else { if (Timer.timer().now() > serviceData.longLastCheck + checkIntervalMS) { File file = new File(dir, serviceName + ".json"); if (file.exists() && file.lastModified() > serviceData.lastModified) { serviceData = new ServiceData(loadDefinitions(file), Timer.timer().now(), file.lastModified()); serviceDataMap.put(serviceName, serviceData); } } } return serviceData.endpointDefinitions; } ServiceDiscoveryFileSystemProvider(final File dir, long checkIntervalMS); @Override List<EndpointDefinition> loadServices(final String serviceName);  }### Answer:
@Test public void testNone() throws Exception { ServiceDiscoveryFileSystemProvider provider = new ServiceDiscoveryFileSystemProvider(File.createTempFile("testNone", "testNone").getParentFile(), 3_000); List<EndpointDefinition> foo = provider.loadServices("baz"); assertEquals(0, foo.size()); }
@Test public void testSome() throws Exception { File dir = File.createTempFile("testSome", "testSome").getParentFile(); ServiceDiscoveryFileSystemProvider provider = new ServiceDiscoveryFileSystemProvider(dir, 3_000); List<EndpointDefinition> endpointDefinitions = EndpointDefinition.serviceDefinitions( EndpointDefinition.serviceDefinition("fooId", "foo", "www.foo.com", 9090)); JsonSerializer jsonSerializer = new JsonSerializerFactory().create(); String json = jsonSerializer.serialize(endpointDefinitions).toString(); File outputFile = new File(dir, "foo.json"); IO.write(outputFile.toPath(), json); List<EndpointDefinition> fooList = provider.loadServices("foo"); assertEquals(1, fooList.size()); EndpointDefinition endpointDefinition = fooList.get(0); assertEquals(9090, endpointDefinition.getPort()); assertEquals("fooId", endpointDefinition.getId()); assertEquals("www.foo.com", endpointDefinition.getHost()); assertEquals("foo", endpointDefinition.getName()); outputFile.delete(); }