Median { @UserAggregationFunction("apoc.agg.median") @Description("apoc.agg.median(number) - returns median for non-null numeric values") public MedianFunction median() { return new MedianFunction(); }  @UserAggregationFunction("apoc.agg.median") @Description("apoc.agg.median(number) - returns median for non-null numeric values") MedianFunction median();  }
@Test public void testMedian() throws Exception { testCall(db, "UNWIND [] as value RETURN apoc.agg.median(value) as p", (row) -> { assertEquals(null, row.get("p")); }); testCall(db, "UNWIND [0,1,2,3] as value RETURN apoc.agg.median(value) as p", (row) -> { assertEquals(1.5D, row.get("p")); }); testCall(db, "UNWIND [0,1, 2 ,3,4] as value RETURN apoc.agg.median(value) as p", (row) -> { assertEquals(2D, row.get("p")); }); testCall(db, "UNWIND [1,1.5, 2,2.5 ,3, 3.5] as value RETURN apoc.agg.median(value) as p", (row) -> { assertEquals(2.25D, row.get("p")); }); testCall(db, "UNWIND [1,1.5,2,2.5,3] as value RETURN apoc.agg.median(value) as p", (row) -> { assertEquals(2D, row.get("p")); }); }