Refactor rename BindHash to BindValuesKey

This commit is contained in:
rbygrave
2021-08-11 13:19:44 +12:00
parent fd2e542c0b
commit ec7c7048db
40 changed files with 204 additions and 202 deletions
@@ -3,7 +3,7 @@ package io.ebeaninternal.server.expression;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
import io.ebeaninternal.api.BindHash;
import io.ebeaninternal.api.BindValuesKey;
public class RawExpressionTest extends BaseExpressionTest {
@@ -62,16 +62,16 @@ public class RawExpressionTest extends BaseExpressionTest {
}
public void assert_queryBindHash_isDifferent(RawExpression exp0, RawExpression exp1) {
assertThat(getHash(exp0)).isNotEqualTo(getHash(exp1));
assertThat(bindKey(exp0)).isNotEqualTo(bindKey(exp1));
}
public void assert_queryBindHash_isSame(RawExpression exp0, RawExpression exp1) {
assertThat(getHash(exp0)).isEqualTo(getHash(exp1));
assertThat(bindKey(exp0)).isEqualTo(bindKey(exp1));
}
private int getHash(RawExpression query) {
BindHash hash = new BindHash();
query.queryBindHash(hash);
return hash.hashCode();
private BindValuesKey bindKey(RawExpression query) {
BindValuesKey bindValuesKey = new BindValuesKey();
query.queryBindHash(bindValuesKey);
return bindValuesKey;
}
}
@@ -1,38 +0,0 @@
package io.ebeaninternal.server.querydefn;
import io.ebeaninternal.api.BindHash;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class BindHashTest {
@Test
public void update_with_null() {
BindHash hash = new BindHash();
hash.update(1).update(null).update("hello");
BindHash hash2 = new BindHash();
hash2.update(1).update(null).update("hello");
assertThat(hash).isEqualTo(hash2);
}
@Test
public void notEqual() {
BindHash hash = new BindHash();
hash.update(1).update(null).update("hello");
BindHash hash2 = new BindHash();
hash2.update(1).update("hello");
BindHash hash3 = new BindHash();
hash2.update(1).update(null);
assertThat(hash).isNotEqualTo(hash2);
assertThat(hash).isNotEqualTo(hash3);
assertThat(hash2).isNotEqualTo(hash3);
}
}
@@ -0,0 +1,38 @@
package io.ebeaninternal.server.querydefn;
import io.ebeaninternal.api.BindValuesKey;
import org.junit.Test;
import static org.assertj.core.api.Assertions.assertThat;
public class BindValuesKeyTest {
@Test
public void update_with_null() {
BindValuesKey hash = new BindValuesKey();
hash.add(1).add(null).add("hello");
BindValuesKey hash2 = new BindValuesKey();
hash2.add(1).add(null).add("hello");
assertThat(hash).isEqualTo(hash2);
}
@Test
public void notEqual() {
BindValuesKey hash = new BindValuesKey();
hash.add(1).add(null).add("hello");
BindValuesKey hash2 = new BindValuesKey();
hash2.add(1).add("hello");
BindValuesKey hash3 = new BindValuesKey();
hash2.add(1).add(null);
assertThat(hash).isNotEqualTo(hash2);
assertThat(hash).isNotEqualTo(hash3);
assertThat(hash2).isNotEqualTo(hash3);
}
}
@@ -4,7 +4,7 @@ package io.ebeaninternal.server.querydefn;
import io.ebean.BaseTestCase;
import io.ebean.CacheMode;
import io.ebean.Ebean;
import io.ebeaninternal.api.BindHash;
import io.ebeaninternal.api.BindValuesKey;
import io.ebeaninternal.api.SpiQuery;
import io.ebeaninternal.server.core.OrmQueryRequest;
import org.junit.Test;
@@ -63,7 +63,7 @@ public class DefaultOrmQueryTest extends BaseTestCase {
prepare(q1, q2);
assertThat(q1.createQueryPlanKey()).isNotEqualTo(q2.createQueryPlanKey());
assertThat(getHash(q1)).isNotEqualTo(getHash(q2));
assertThat(bindKey(q1)).isNotEqualTo(bindKey(q2));
}
@Test
@@ -74,7 +74,7 @@ public class DefaultOrmQueryTest extends BaseTestCase {
prepare(q1, q2);
assertThat(q1.createQueryPlanKey()).isEqualTo(q2.createQueryPlanKey());
assertThat(getHash(q1)).isNotEqualTo(getHash(q2));
assertThat(bindKey(q1)).isNotEqualTo(bindKey(q2));
}
@Test
@@ -85,7 +85,7 @@ public class DefaultOrmQueryTest extends BaseTestCase {
prepare(q1, q2);
assertThat(q1.createQueryPlanKey()).isEqualTo(q2.createQueryPlanKey());
assertThat(getHash(q1)).isEqualTo(getHash(q2));
assertThat(bindKey(q1)).isEqualTo(bindKey(q2));
}
@Test
@@ -112,9 +112,9 @@ public class DefaultOrmQueryTest extends BaseTestCase {
q2.prepare(r2);
}
private int getHash(DefaultOrmQuery<Order> query) {
BindHash hash = new BindHash();
query.queryBindHash(hash);
return hash.hashCode();
private BindValuesKey bindKey(DefaultOrmQuery<Order> query) {
BindValuesKey key = new BindValuesKey();
query.queryBindHash(key);
return key;
}
}