Skip to content

Commit 7ac132d

Browse files
committed
Merge pull request #18 from innokenty/master
tiny apis improvements
2 parents 41af67b + acdbc06 commit 7ac132d

File tree

3 files changed

+29
-10
lines changed

3 files changed

+29
-10
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package ru.qatools.gridrouter.config;
2+
3+
import java.util.List;
4+
5+
import static java.util.stream.Collectors.toList;
6+
7+
/**
8+
* @author Dmitry Baev [email protected]
9+
* @author Innokenty Shuvalov [email protected]
10+
*/
11+
public interface WithHosts {
12+
13+
default List<Host> getHosts() {
14+
return getBrowsers().stream()
15+
.flatMap(b -> b.getVersions().stream())
16+
.flatMap(v -> v.getRegions().stream())
17+
.flatMap(r -> r.getHosts().stream())
18+
.collect(toList());
19+
}
20+
21+
List<Browser> getBrowsers();
22+
}
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
package ru.qatools.gridrouter.config;
22

33
import java.util.HashMap;
4-
import java.util.List;
54
import java.util.Map;
65

76
/**
87
* @author Dmitry Baev [email protected]
98
* @author Innokenty Shuvalov [email protected]
109
*/
11-
public interface WithRoutesMap {
12-
13-
List<Browser> getBrowsers();
10+
public interface WithRoutesMap extends WithHosts {
1411

1512
default Map<String, String> getRoutesMap() {
16-
HashMap<String, String> routes = new HashMap<>();
17-
getBrowsers().stream()
18-
.flatMap(b -> b.getVersions().stream())
19-
.flatMap(v -> v.getRegions().stream())
20-
.flatMap(r -> r.getHosts().stream())
21-
.forEach(h -> routes.put(h.getRouteId(), h.getRoute()));
13+
Map<String, String> routes = new HashMap<>();
14+
getHosts().forEach(h -> routes.put(h.getRouteId(), h.getRoute()));
2215
return routes;
2316
}
2417
}

proxy/src/main/java/ru/qatools/gridrouter/ConfigRepository.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,10 @@ public void beanChanged(Path filename, Browsers browsers) {
7272
}
7373
}
7474

75+
public Map<String, Browsers> getQuotaMap() {
76+
return userBrowsers;
77+
}
78+
7579
public Map<String, String> getRoutes() {
7680
return routes;
7781
}

0 commit comments

Comments
 (0)