### Question:
EurekaMetadataParser { public List<RoutedService> parseToListRoute(Map<String, String> eurekaMetadata) { Map<String, String> routeMap = new HashMap<>(); return eurekaMetadata.entrySet() .stream() .filter(this::filterMetadata) .map(metadata -> mapMetadataToRoutedService(metadata, routeMap)) .filter(Objects::nonNull) .collect(Collectors.toList()); }  List<ApiInfo> parseApiInfo(Map<String, String> eurekaMetadata); RoutedServices parseRoutes(Map<String, String> eurekaMetadata); List<RoutedService> parseToListRoute(Map<String, String> eurekaMetadata); static Map<String, String> generateMetadata(String serviceId, ApiInfo apiInfo);  }### Answer:
@Test public void testParseToListRoute() { Map<String, String> metadata = new HashMap<>(); metadata.put(ROUTES + ".api-v1." + ROUTES_GATEWAY_URL, "api/v1"); metadata.put(ROUTES + ".api-v1." + ROUTES_SERVICE_URL, "/"); metadata.put("other.parameter", "value"); metadata.put(ROUTES + ".api-v2." + ROUTES_SERVICE_URL, "/test"); metadata.put("some.garbage.again", "null"); metadata.put(ROUTES + ".api-v2." + ROUTES_GATEWAY_URL, "api/v2"); metadata.put(ROUTES + ".api-v3." + ROUTES_GATEWAY_URL, "incomplete"); metadata.put(ROUTES + ".api-v4." + ROUTES_SERVICE_URL, "incomplete"); metadata.put(ROUTES + ".api-v5." + ROUTES_GATEWAY_URL, "/api/v5/"); metadata.put(ROUTES + ".api-v5." + ROUTES_SERVICE_URL, "test"); List<RoutedService> actualRoutes = eurekaMetadataParser.parseToListRoute(metadata); List<RoutedService> expectedListRoute = Arrays.asList( new RoutedService("api-v1", "api/v1", "/"), new RoutedService("api-v2", "api/v2", "/test"), new RoutedService("api-v5", "api/v5", "/test") ); assertEquals("List route size is different", 3, actualRoutes.size()); assertThat(actualRoutes, containsInAnyOrder(expectedListRoute.toArray())); }
@Test public void testParseToListRoute_whenMetadatakeyElementsIsDifferentFrom4() { Map<String, String> metadata = new HashMap<>(); metadata.put(ROUTES + ".api-v1.test." + ROUTES_GATEWAY_URL, "api/v1"); List<RoutedService> actualRoutes = eurekaMetadataParser.parseToListRoute(metadata); assertEquals("List route is not empty", 0, actualRoutes.size()); }