#1331 - ENH: Support Aggregation formula with findSingleAttribute() ... max, min, avg, count and count(distinct ..)

This commit is contained in:
Rob Bygrave
2018-03-06 12:58:43 +13:00
parent ec2c3b13d4
commit 3ca4efc818
23 changed files with 783 additions and 51 deletions
@@ -0,0 +1,35 @@
package io.ebeaninternal.server.deploy;
import io.ebean.BaseTestCase;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class FormulaPropertyPathTest extends BaseTestCase {
//private BeanDescriptor<Customer> customerDesc = getBeanDescriptor(Customer.class);
@Test
public void isFormula() {
assertFormula("max(foo)", "max", "foo");
assertFormula("min(bar)", "min", "bar");
assertFormula("avg(baz)", "avg", "baz");
}
@Test
public void isFormula_count() {
assertFormula("count(moo)", "count", "moo");
assertFormula("count(distinct joo)", "count", "joo");
}
private void assertFormula(String input, String aggType, String baseProperty) {
FormulaPropertyPath propertyPath = new FormulaPropertyPath(input);
assertThat(propertyPath.isFormula()).isTrue();
assertThat(propertyPath.basePropertyName()).isEqualTo(baseProperty);
assertThat(propertyPath.aggType()).isEqualTo(aggType);
}
}