Merge branch 'master' of github.com:ebean-orm/ebean

This commit is contained in:
Rob Bygrave
2018-01-06 12:52:38 +13:00
6 changed files with 5 additions and 240 deletions
@@ -1,39 +0,0 @@
package io.ebeaninternal.api;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class HashQueryPlanBuilderTest {
int combine(int v0, int v1) {
return new HashQueryPlanBuilder().add(v0).add(v1).build().hashCode();
}
@Test
public void test_pair_0_1() {
assertThat(combine(0, 31)).isNotEqualTo(combine(1, 0));
}
@Test
public void test_pair_0_10_adjust_0() {
assertThat(combine(0, 310)).isNotEqualTo(combine(10, 0));
}
@Test
public void test_pair_0_10_adjust_10() {
assertThat(combine(0, 320)).isNotEqualTo(combine(10, 10));
}
@Test
public void test_pair_0_10_adjust_40() {
assertThat(combine(0, 350)).isNotEqualTo(combine(10, 40));
}
@Test
public void test_pair_0_10_adjust_90() {
assertThat(combine(0, 400)).isNotEqualTo(combine(10, 90));
}
}
@@ -1,45 +0,0 @@
package io.ebeaninternal.api;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class HashQueryPlanTest {
private HashQueryPlan hqp(String raw, int plan, int bind) {
return new HashQueryPlan(raw, plan, bind);
}
private int hc(String raw, int plan, int bind) {
return hqp(raw, plan, bind).hashCode();
}
@Test
public void testEquals() throws Exception {
assertThat(hqp("foo", 10, 7)).isEqualTo(hqp("foo", 10, 7));
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 11, 7));
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 9, 7));
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 10, 8));
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("foo", 10, 6));
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp("bar", 10, 6));
assertThat(hqp("foo", 10, 7)).isNotEqualTo(hqp(null, 10, 7));
assertThat(hqp(null, 10, 7)).isNotEqualTo(hqp("foo", 10, 7));
assertThat(hqp(null, 10, 7)).isEqualTo(hqp(null, 10, 7));
}
@Test
public void testHashCode() throws Exception {
assertThat(hc("foo", 10, 7)).isEqualTo(hc("foo", 10, 7));
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 11, 7));
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 9, 7));
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 10, 8));
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("foo", 10, 6));
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc("bar", 10, 6));
assertThat(hc("foo", 10, 7)).isNotEqualTo(hc(null, 10, 7));
assertThat(hc(null, 10, 7)).isNotEqualTo(hc("foo", 10, 7));
assertThat(hc(null, 10, 7)).isEqualTo(hc(null, 10, 7));
}
}
@@ -101,7 +101,11 @@ public class TestAggregationCount extends BaseTestCase {
assertThat(list).isNotEmpty();
String sql = sqlOf(query, 5);
assertThat(sql).contains("select distinct t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount), sum(u1.units), t0.name from tevent_one t0 ");
if (isH2()) {
assertThat(sql).contains("select distinct t0.id, t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount), sum(u1.units), t0.name from tevent_one t0 ");
} else if (isPostgres()) {
assertThat(sql).contains("t0.name, count(u1.id), sum(u1.units), sum(u1.units * u1.amount), sum(u1.units), t0.name from tevent_one t0 ");
}
assertThat(sql).contains("from tevent_one t0 join tevent_many u1 on u1.event_id = t0.id ");
assertThat(sql).contains(" group by t0.id, t0.name ");
assertThat(sql).contains(" order by sum(u1.units), t0.name");