Search in sources :

Example 1 with ShortcutConfigurable

use of org.springframework.cloud.gateway.support.ShortcutConfigurable in project spring-cloud-gateway by spring-cloud.

the class RouteDefinitionRouteLocatorTests method testGetTupleWithSpel.

@Test
public void testGetTupleWithSpel() {
    parser = new SpelExpressionParser();
    ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {

        @Override
        public List<String> shortcutFieldOrder() {
            return Arrays.asList("bean", "arg1");
        }
    };
    Map<String, String> args = new HashMap<>();
    args.put("bean", "#{@foo}");
    args.put("arg1", "val1");
    Tuple tuple = RouteDefinitionRouteLocator.getTuple(shortcutConfigurable, args, parser, this.beanFactory);
    assertThat(tuple).isNotNull();
    assertThat(tuple.getValue("bean", Integer.class)).isEqualTo(42);
    assertThat(tuple.getString("arg1")).isEqualTo("val1");
}
Also used : SpelExpressionParser(org.springframework.expression.spel.standard.SpelExpressionParser) HashMap(java.util.HashMap) ShortcutConfigurable(org.springframework.cloud.gateway.support.ShortcutConfigurable) Tuple(org.springframework.tuple.Tuple) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

HashMap (java.util.HashMap)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 ShortcutConfigurable (org.springframework.cloud.gateway.support.ShortcutConfigurable)1 SpelExpressionParser (org.springframework.expression.spel.standard.SpelExpressionParser)1 Tuple (org.springframework.tuple.Tuple)1