@Test
    public void testForEachFollowedByGetVar() {
        String expressionString =
                """
                input uris | for_each {
                    if ((_ | substring 0 7) == "http://") {
                         _ | substring 7 1000 | set_var selected
                    } else {
                        _
                    }
                    } | get_var selected | attribute id
                """;

        var tester = new ScriptTester();
        var expression = tester.expressionFrom(expressionString);

        SimpleTestAdapter adapter = new SimpleTestAdapter();
        var uris = new Field("uris", new ArrayDataType(DataType.STRING));
        var id = new Field("id", DataType.STRING);
        adapter.createField(uris);
        adapter.createField(id);
        var array = new Array<StringFieldValue>(uris.getDataType());
        array.add(new StringFieldValue("value1"));
        array.add(new StringFieldValue("http://value2"));
        adapter.setValue("uris", array);

        expression.resolve(adapter);

        ExecutionContext context = new ExecutionContext(adapter);
        expression.execute(context);
        assertTrue(adapter.values.containsKey("id"));
        assertEquals("value2", ((StringFieldValue)adapter.values.get("id")).getString());
    }
@author Simon Thoresen Hult
@author bratseth
indexinglanguage/src/test/java/com/yahoo/vespa/indexinglanguage/ScriptTestCase.java