public static void bindEnvironment(ScriptEngine engine, String requestContent, Map<String, Object> requestContext,
         StateStore stateStore) {
      // Build a map of header values.
      bindEnvironment(engine, requestContent, requestContext, stateStore, null);
   }
@Test
   void testStateStoreIsBoundAndAccessed() {
      String script = """
            def foo = store.get("foo");
            def bar = store.put("bar", "barValue");
            store.delete("baz");
            return foo;
            """;

      StateStore store = new StateStore() {
         private final Map<String, String> map = new HashMap<>();

         @Override
         public void put(String key, String value) {
            map.put(key, value);
         }

         @Override
         public void put(String key, String value, int secondsTTL) {
            map.put(key, value);
         }

         @Nullable
         @Override
         public String get(String key) {
            return map.get(key);
         }

         @Override
         public void delete(String key) {
            map.remove(key);
         }
      };

      ScriptEngineManager sem = new ScriptEngineManager();
      Map<String, Object> context = new HashMap<>();
      store.put("foo", "fooValue");
      store.put("baz", "bazValue");

      try {
         // Evaluating request with script coming from operation dispatcher rules.
         ScriptEngine se = sem.getEngineByExtension("groovy");
         ScriptEngineBinder.bindEnvironment(se, "body", context, store);
         String result = (String) se.eval(script);

         assertEquals("fooValue", result);
         assertEquals("barValue", store.get("bar"));
         assertNull(store.get("baz"));
      } catch (Exception e) {
         fail("Exception should no be thrown");
      }
   }