static Object[] rearrangeParameters(NamedParameter[] params, List<String> pnames) {
        logger.trace("rearrangeParameters {} {}", params, pnames);
        if (pnames.isEmpty()) {
            return params;
        } else {
            Object[] actualParams = new Object[pnames.size()];
            for (int i = 0; i < actualParams.length; i++) {
                for (int j = 0; j < params.length; j++) {
                    if (params[j].getName().equals(pnames.get(i))) {
                        actualParams[i] = params[j].getValue();
                        break;
                    }
                }
            }
            return actualParams;
        }
    }
@Test
    void rearrangeParameters() {
        NamedParameter[] params = {new NamedParameter("fake", new Object())};
        Object[] retrieved = BaseFEELFunctionHelper.rearrangeParameters(params, Collections.emptyList());
        assertNotNull(retrieved);
        assertEquals(params, retrieved);

        List<String> pnames = IntStream.range(0, 3)
                .mapToObj(i -> "Parameter_" + i)
                .toList();

        // single param in correct position
        params = new NamedParameter[]{new NamedParameter(pnames.get(0), new Object())};
        retrieved = BaseFEELFunctionHelper.rearrangeParameters(params, pnames);
        assertNotNull(retrieved);
        assertEquals(pnames.size(), retrieved.length);
        for (int i = 0; i < retrieved.length; i++) {
            if (i == 0) {
                assertEquals(params[0].getValue(), retrieved[i]);
            } else {
                assertNull(retrieved[i]);
            }
        }

        // single param in wrong position
        params = new NamedParameter[]{new NamedParameter(pnames.get(2), new Object())};
        retrieved = BaseFEELFunctionHelper.rearrangeParameters(params, pnames);
        assertNotNull(retrieved);
        assertEquals(pnames.size(), retrieved.length);
        for (int i = 0; i < retrieved.length; i++) {
            if (i == 2) {
                assertEquals(params[0].getValue(), retrieved[i]);
            } else {
                assertNull(retrieved[i]);
            }
        }

        // reverting the whole order
        params = new NamedParameter[]{new NamedParameter(pnames.get(2), new Object()),
                new NamedParameter(pnames.get(1), new Object()),
                new NamedParameter(pnames.get(0), new Object())};
        retrieved = BaseFEELFunctionHelper.rearrangeParameters(params, pnames);
        assertNotNull(retrieved);
        assertEquals(pnames.size(), retrieved.length);
        for (int i = 0; i < retrieved.length; i++) {
            switch (i) {
                case 0:
                    assertEquals(params[2].getValue(), retrieved[i]);
                    break;
                case 1:
                    assertEquals(params[1].getValue(), retrieved[i]);
                    break;
                case 2:
                    assertEquals(params[0].getValue(), retrieved[i]);
                    break;
            }
        }
    }