From 52c7f61815d00b655b3d7ac3d19af8490d2e6405 Mon Sep 17 00:00:00 2001 From: Gavin King Date: Mon, 7 Feb 2022 13:41:05 +0100 Subject: [PATCH] add tests for avg(index) and avg(element) --- .../orm/test/query/hql/FunctionTests.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java index ff074e3dfe..ba495c343b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/query/hql/FunctionTests.java @@ -108,6 +108,16 @@ public class FunctionTests { // .getSingleResult(), is(3.0) ); + //TODO: why does this fail?? +// assertThat( session.createQuery("select avg(index eol.listOfNumbers) from EntityOfLists eol") +// .list().get(0), +//// .getSingleResult(), +// is(0.5) ); + assertThat( session.createQuery("select avg(element eol.listOfNumbers) from EntityOfLists eol") + .list().get(0), +// .getSingleResult(), + is(1.5) ); + assertThat( session.createQuery("select max(index eom.numberByNumber) from EntityOfMaps eom") .getSingleResult(), is(1) ); assertThat( session.createQuery("select max(element eom.numberByNumber) from EntityOfMaps eom") @@ -117,6 +127,11 @@ public class FunctionTests { .getSingleResult(), is(1) ); assertThat( session.createQuery("select sum(element eom.numberByNumber) from EntityOfMaps eom") .getSingleResult(), is(1.0) ); + + assertThat( session.createQuery("select avg(index eom.numberByNumber) from EntityOfMaps eom") + .getSingleResult(), is(1) ); + assertThat( session.createQuery("select avg(element eom.numberByNumber) from EntityOfMaps eom") + .getSingleResult(), is(1.0) ); } ); }