Utils { @Procedure @Description("apoc.util.sleep(<duration>) | sleeps for <duration> millis, transaction termination is honored") public void sleep(@Name("duration") long duration) throws InterruptedException { long started = System.currentTimeMillis(); while (System.currentTimeMillis()-started < duration) { try { Thread.sleep(5); terminationGuard.check(); } catch (TransactionTerminatedException e) { return; } } }  @UserFunction @Description("apoc.util.sha1([values]) | computes the sha1 of the concatenation of all string values of the list") String sha1(@Name("values") List<Object> values); @UserFunction @Description("apoc.util.sha256([values]) | computes the sha256 of the concatenation of all string values of the list") String sha256(@Name("values") List<Object> values); @UserFunction @Description("apoc.util.sha384([values]) | computes the sha384 of the concatenation of all string values of the list") String sha384(@Name("values") List<Object> values); @UserFunction @Description("apoc.util.sha512([values]) | computes the sha512 of the concatenation of all string values of the list") String sha512(@Name("values") List<Object> values); @UserFunction @Description("apoc.util.md5([values]) | computes the md5 of the concatenation of all string values of the list") String md5(@Name("values") List<Object> values); @Procedure @Description("apoc.util.sleep(<duration>) | sleeps for <duration> millis, transaction termination is honored") void sleep(@Name("duration") long duration); @Procedure @Description("apoc.util.validate(predicate, message, params) | if the predicate yields to true raise an exception") void validate(@Name("predicate") boolean predicate, @Name("message") String message, @Name("params") List<Object> params); @Context
    public GraphDatabaseService db; @Context
    public TerminationGuard terminationGuard; }
@Test public void testSleep() { String cypherSleep = "call apoc.util.sleep($duration)"; testCallEmpty(db, cypherSleep, MapUtil.map("duration", 0l)); long duration = 300; TestUtil.assertDuration(Matchers.greaterThanOrEqualTo(duration), () -> { testCallEmpty(db, cypherSleep, MapUtil.map("duration", duration)); return null; }); }