CentreRegistryProvidersService implements EndpointProvidersService { protected void fillInCentreDetails(List<EndpointProvider> providers) throws IOException { Collection<Integer> centreIds = providers.stream().map(EndpointProvider::getCentreKey).collect(Collectors.toSet()); final URL url = new URL(centresJsonUrl); try (InputStream is = url.openStream()) { final JSONTokener tokener = new JSONTokener(is); final JSONArray jsonArray = new JSONArray(tokener); final Stream<JSONObject> centres = jsonArrayToObjectStream(jsonArray) .filter(o -> o.has("pk") && centreIds.contains(o.getInt("pk"))); centres.forEach(o -> { final Integer centreKey = o.getInt("pk"); final JSONObject fields = o.getJSONObject("fields"); providers.stream() .filter(e -> e.getCentreKey().equals(centreKey)) .forEach(e -> { e.setName(fields.getString("name")); e.setWebsiteUrl(fields.getString("website_url")); }); }); } } CentreRegistryProvidersService(VloConfig vloConfig);  CentreRegistryProvidersService(String centresJsonUrl, String endpointsJsonUrl); @Override List<EndpointProvider> retrieveCentreEndpoints();  }
@Test public void testFillInCentreDetails() throws Exception { List<EndpointProvider> providers = instance.parseEndpoints(); instance.fillInCentreDetails(providers); 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(4) && provider.getCentreName().equals("ASV Leipzig") && provider.getCentreWebsiteUrl().equals("http: && provider.getEndpointUrls().size() == 2)) .findAny() .isPresent()); }