Static { @UserFunction("apoc.static.get") @Description("apoc.static.get(name) - returns statically stored value from config (apoc.static.<key>) or server lifetime storage") public Object get(@Name("key") String key) { return storage.getOrDefault(key, fromConfig(key)); }  @Procedure("apoc.static.get") @Deprecated @Description("apoc.static.get(name) - returns statically stored value from config (apoc.static.<key>) or server lifetime storage") Stream<ObjectResult> getProcedure(@Name("key") String key); @UserFunction("apoc.static.get") @Description("apoc.static.get(name) - returns statically stored value from config (apoc.static.<key>) or server lifetime storage") Object get(@Name("key") String key); @UserFunction("apoc.static.getAll") @Description("apoc.static.getAll(prefix) - returns statically stored values from config (apoc.static.<prefix>.*) or server lifetime storage") Map<String,Object> getAll(@Name("prefix") String prefix); @Procedure("apoc.static.list") @Description("apoc.static.list(prefix) - returns statically stored values from config (apoc.static.<prefix>.*) or server lifetime storage") Stream<KeyValueResult> list(@Name("prefix") String prefix); @Procedure("apoc.static.set") @Description("apoc.static.set(name, value) - stores value under key for server lifetime storage, returns previously stored or configured value") Stream<ObjectResult> set(@Name("key") String key, @Name("value") Object value); static void clear(); @Context
    public GraphDatabaseAPI db; @Context
    public ApocConfig apocConfig; }
@Test public void testGetAllFromConfig() throws Exception { TestUtil.testCall(db, "return apoc.static.getAll('all') as value", r -> assertEquals(map("test",VALUE),r.get("value"))); TestUtil.testCall(db, "call apoc.static.set('all.test2',42)", r -> assertNull(r.get("value"))); TestUtil.testCall(db, "return apoc.static.getAll('all') as value", r -> assertEquals(map("test",VALUE,"test2",42L),r.get("value"))); TestUtil.testCall(db, "return apoc.static.getAll('') as value", r -> assertEquals(map("test",VALUE,"all.test",VALUE,"all.test2",42L),r.get("value"))); }
@Test public void testListFromConfig() throws Exception { TestUtil.testCall(db, "call apoc.static.set('all.test2',42)", r -> assertNull(r.get("value"))); TestUtil.testResult(db, "call apoc.static.list('all') yield key, value return * order by key", r -> { assertEquals(map("key","test","value",VALUE),r.next()); assertEquals(map("key","test2","value",42L),r.next()); assertFalse(r.hasNext()); }); TestUtil.testResult(db, "call apoc.static.list('') yield key, value return * order by key", r -> { assertEquals(map("key","all.test","value",VALUE),r.next()); assertEquals(map("key","all.test2","value",42L),r.next()); assertEquals(map("key","test","value",VALUE),r.next()); assertFalse(r.hasNext()); }); }
@Test public void testOverrideConfig() throws Exception { TestUtil.testCall(db, "call apoc.static.get('test')", r -> assertEquals(VALUE,r.get("value"))); TestUtil.testCall(db, "return apoc.static.get('test') as value", r -> assertEquals(VALUE,r.get("value"))); TestUtil.testCall(db, "call apoc.static.set('test',42)", r -> assertEquals(VALUE,r.get("value"))); TestUtil.testCall(db, "call apoc.static.get('test')", r -> assertEquals(42L,r.get("value"))); TestUtil.testCall(db, "return apoc.static.get('test') as value", r -> assertEquals(42L,r.get("value"))); TestUtil.testCall(db, "call apoc.static.set('test',null)", r -> assertEquals(42L,r.get("value"))); TestUtil.testCall(db, "call apoc.static.get('test')", r -> assertEquals(VALUE,r.get("value"))); TestUtil.testCall(db, "return apoc.static.get('test') as value", r -> assertEquals(VALUE,r.get("value"))); }