Skip to content

Commit

Permalink
Merge branch '4.0.x'
Browse files Browse the repository at this point in the history
  • Loading branch information
spencergibb committed Dec 5, 2023
2 parents a26f652 + 8263985 commit 733ce03
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ public AbstractGatewayControllerEndpoint(RouteDefinitionLocator routeDefinitionL
List<GlobalFilter> globalFilters, List<GatewayFilterFactory> gatewayFilters,
List<RoutePredicateFactory> routePredicates, RouteDefinitionWriter routeDefinitionWriter,
RouteLocator routeLocator) {
this(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates,
routeDefinitionWriter, routeLocator, new WebEndpointProperties());
this(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates, routeDefinitionWriter,
routeLocator, new WebEndpointProperties());
}

public AbstractGatewayControllerEndpoint(RouteDefinitionLocator routeDefinitionLocator,
Expand Down Expand Up @@ -126,8 +126,7 @@ Mono<List<GatewayEndpointInfo>> getEndpoints() {
.collectList();
}

private List<GatewayEndpointInfo> mergeEndpoints(List<GatewayEndpointInfo> listA,
List<GatewayEndpointInfo> listB) {
private List<GatewayEndpointInfo> mergeEndpoints(List<GatewayEndpointInfo> listA, List<GatewayEndpointInfo> listB) {
Map<String, List<String>> mergedMap = new HashMap<>();

Stream.concat(listA.stream(), listB.stream()).forEach(e -> mergedMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ public GatewayControllerEndpoint(List<GlobalFilter> globalFilters, List<GatewayF
List<RoutePredicateFactory> routePredicates, RouteDefinitionWriter routeDefinitionWriter,
RouteLocator routeLocator, RouteDefinitionLocator routeDefinitionLocator,
WebEndpointProperties webEndpointProperties) {
super(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates,
routeDefinitionWriter, routeLocator, webEndpointProperties);
super(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates, routeDefinitionWriter,
routeLocator, webEndpointProperties);
}

@GetMapping("/routedefinitions")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public Map<String, Object> normalize(Map<String, String> args, ShortcutConfigura
// strip boolean flag if last entry is true or false
int lastIdx = values.size() - 1;
String lastValue = values.get(lastIdx);
if (lastValue.equalsIgnoreCase("true") || lastValue.equalsIgnoreCase("false")) {
if ("true".equalsIgnoreCase(lastValue) || "false".equalsIgnoreCase(lastValue) || lastValue == null) {
values = values.subList(0, lastIdx);
map.put(fieldOrder.get(1), getValue(parser, beanFactory, lastValue));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,29 +70,21 @@ public class GatewayControllerEndpointTests {

@Test
public void testEndpoints() {
testClient.get().uri("http://localhost:" + port + "/actuator/gateway").exchange()
.expectStatus().isOk().expectBodyList(Map.class).consumeWith(result -> {
testClient.get().uri("http://localhost:" + port + "/actuator/gateway").exchange().expectStatus().isOk()
.expectBodyList(Map.class).consumeWith(result -> {
List<Map> responseBody = result.getResponseBody();
assertThat(responseBody).isNotEmpty();
assertThat(responseBody).contains(
Map.of("href", "/actuator/gateway/", "methods",
List.of("GET")),
Map.of("href", "/actuator/gateway/globalfilters", "methods",
List.of("GET")),
Map.of("href", "/actuator/gateway/refresh", "methods",
List.of("POST")),
Map.of("href", "/actuator/gateway/routedefinitions",
"methods", List.of("GET")),
Map.of("href", "/actuator/gateway/routefilters", "methods",
List.of("GET")),
Map.of("href", "/actuator/gateway/routepredicates", "methods",
List.of("GET")),
Map.of("href", "/actuator/gateway/routes", "methods",
List.of("POST", "GET")),
Map.of("href", "/actuator/gateway/routes/test-service",
"methods", List.of("POST", "DELETE", "GET")),
Map.of("href", "/actuator/gateway/routes/route_with_metadata",
"methods", List.of("POST", "DELETE", "GET")));
assertThat(responseBody).contains(Map.of("href", "/actuator/gateway/", "methods", List.of("GET")),
Map.of("href", "/actuator/gateway/globalfilters", "methods", List.of("GET")),
Map.of("href", "/actuator/gateway/refresh", "methods", List.of("POST")),
Map.of("href", "/actuator/gateway/routedefinitions", "methods", List.of("GET")),
Map.of("href", "/actuator/gateway/routefilters", "methods", List.of("GET")),
Map.of("href", "/actuator/gateway/routepredicates", "methods", List.of("GET")),
Map.of("href", "/actuator/gateway/routes", "methods", List.of("POST", "GET")),
Map.of("href", "/actuator/gateway/routes/test-service", "methods",
List.of("POST", "DELETE", "GET")),
Map.of("href", "/actuator/gateway/routes/route_with_metadata", "methods",
List.of("POST", "DELETE", "GET")));
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,32 @@ public ShortcutType shortcutType() {
}
}

@Test
public void testNormalizeGatherListTailFlagFlagIsNull() {
parser = new SpelExpressionParser();
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
@Override
public List<String> shortcutFieldOrder() {
return Arrays.asList("values", "flag");
}

@Override
public ShortcutType shortcutType() {
return ShortcutType.GATHER_LIST_TAIL_FLAG;
}
};
Map<String, String> args = new HashMap<>();
args.put("1", "val0");
args.put("2", "val1");
args.put("3", "val2");
args.put("4", null);
Map<String, Object> map = ShortcutType.GATHER_LIST_TAIL_FLAG.normalize(args, shortcutConfigurable, parser,
this.beanFactory);
assertThat(map).isNotNull().containsKey("values");
assertThat((List) map.get("values")).containsExactly("val0", "val1", "val2");
assertThat(map.get("flag")).isNull();
}

@SpringBootConfiguration
protected static class TestConfig {

Expand Down

0 comments on commit 733ce03

Please sign in to comment.