CentreRegistryProvidersService implements EndpointProvidersService { @Override public List<EndpointProvider> retrieveCentreEndpoints() throws IOException { try { return lastResponse.updateAndGet(this::retrieveCentreEndpointsOrOld); } catch (Exception ex) { if (ex.getCause() instanceof IOException) { throw (IOException) ex.getCause(); } else { throw new RuntimeException(ex); } } } CentreRegistryProvidersService(VloConfig vloConfig);  CentreRegistryProvidersService(String centresJsonUrl, String endpointsJsonUrl); @Override List<EndpointProvider> retrieveCentreEndpoints();  }
@Test public void testRetrieveCentreEndpoints() throws Exception { List<EndpointProvider> providers = instance.retrieveCentreEndpoints(); assertEquals(39, providers.size()); providers.forEach(provider -> { assertNotNull(provider.getCentreKey()); assertNotNull(provider.getCentreName()); assertNotNull(provider.getCentreWebsiteUrl()); assertNotNull(provider.getEndpointUrls()); }); assertTrue( providers.stream() .filter(provider -> (provider.getCentreKey().equals(5) && provider.getCentreName().equals("Bayerisches Archiv für Sprachsignale") && provider.getCentreWebsiteUrl().equals("http: && provider.getEndpointUrls().size() == 1)) .findAny() .isPresent()); }
@Test public void testNoOldOnError() throws Exception { instance = new CentreRegistryProvidersService(centreJsonFile.toURI().toString(), endpointJsonFile.toURI().toString()) { @Override protected List<EndpointProvider> parseEndpoints() throws IOException { throw new IOException("Always fails"); } }; try { instance.retrieveCentreEndpoints(); fail("Exception should have been thrown"); } catch (Exception ex) { assertEquals(IOException.class, ex.getClass()); } }