mirror of
https://github.com/ebean-orm/ebean.git
synced 2026-11-20 23:05:23 +00:00
Refactor move tests from ebean-core to ebean-test
This commit is contained in:
1 parent
0b00a14fd3
commit
eab56d323b
1650 files changed
+185
-147
No files matched your search
@@ -0,0 +1,91 @@
|
||||
package io.ebeaninternal.server.expression;
|
||||
|
||||
import io.ebean.*;
|
||||
import io.ebean.event.BeanQueryRequest;
|
||||
import io.ebeaninternal.api.SpiExpression;
|
||||
import io.ebeaninternal.server.deploy.BeanDescriptor;
|
||||
import org.tests.model.basic.Customer;
|
||||
import org.tests.model.basic.Order;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public abstract class BaseExpressionTest extends BaseTestCase {
|
||||
|
||||
protected DefaultExpressionRequest newExpressionRequest() {
|
||||
BeanDescriptor<Order> desc = getBeanDescriptor(Order.class);
|
||||
return new DefaultExpressionRequest(desc);
|
||||
}
|
||||
|
||||
protected String hash(SpiExpression expression) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
if (expression != null) {
|
||||
expression.queryPlanHash(sb);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
protected void same(SpiExpression one, SpiExpression two) {
|
||||
assertThat(hash(one)).isEqualTo(hash(two));
|
||||
}
|
||||
|
||||
protected void different(SpiExpression one, SpiExpression two) {
|
||||
assertThat(hash(one)).isNotEqualTo(hash(two));
|
||||
}
|
||||
|
||||
/**
|
||||
* Request with Multi-Value support.
|
||||
*/
|
||||
protected InExpressionTest.TDQueryRequest<Customer> multi() {
|
||||
return MULTI_VALUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request with NO Multi-Value support.
|
||||
*/
|
||||
protected InExpressionTest.TDQueryRequest<Customer> noMulti() {
|
||||
return NO_MULTI_VALUE;
|
||||
}
|
||||
|
||||
|
||||
private static final TDQueryRequest<Customer> MULTI_VALUE = new TDQueryRequest<>(true);
|
||||
private static final TDQueryRequest<Customer> NO_MULTI_VALUE = new TDQueryRequest<>(false);
|
||||
|
||||
static class TDQueryRequest<T> implements BeanQueryRequest<T> {
|
||||
|
||||
final boolean supported;
|
||||
|
||||
TDQueryRequest(boolean supported) {
|
||||
this.supported = supported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EbeanServer getEbeanServer() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Transaction transaction() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Query<T> query() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPadInExpression() {
|
||||
return supported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiValueIdSupported() {
|
||||
return supported;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMultiValueSupported(Class<?> valueType) {
|
||||
return supported;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user