package com.marcosbarbero.cloud.autoconfigure.zuul.ratelimit.filters.commons;

import java.util.Collection;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.netflix.zuul.filters.Route;
import org.springframework.cloud.netflix.zuul.filters.RouteLocator;

/**
 * @author Marcos Barbero
 * @since 2017-06-23
 */
@RequiredArgsConstructor
public class TestRouteLocator implements RouteLocator {

    private final Collection<String> ignoredPaths;
    private final List<Route> routes;

    @Override
    public Collection<String> getIgnoredPaths() {
        return this.ignoredPaths;
    }

    @Override
    public List<Route> getRoutes() {
        return this.routes;
    }

    @Override
    public Route getMatchingRoute(String path) {
        for (Route route : this.routes) {
            if (path.startsWith(route.getPrefix())) {
                return route;
            }
        }
        return null;
    }
}

@@ -76,60 +76,8 @@
 s;%0A%0A
-import java.util.Collection;%0Aimport java.util.List;%0A
 impo
@@ -241,16 +241,69 @@
 cator;%0A%0A
+import java.util.Collection;%0Aimport java.util.List;%0A%0A
 /**%0A * @
@@ -787,26 +787,14 @@
     
-for (Route route :
+return
  thi
@@ -801,19 +801,25 @@
 s.routes
-) %7B
+.stream()
 %0A       
@@ -827,12 +827,29 @@
     
-if (
+    .filter(route -%3E 
 path
@@ -879,18 +879,16 @@
 efix()))
- %7B
 %0A       
@@ -900,21 +900,20 @@
     
-return route;
+.findFirst()
 %0A   
@@ -925,39 +925,25 @@
     
-%7D%0A
     
-    %7D%0A        return 
+.orElse(
 null
+)
 ;%0A  

Refactor support test classes