io.ebean.mocker.delegate.DelegateQuery Maven / Gradle / Ivy
package io.ebean.mocker.delegate;
import io.ebean.*;
import java.util.Set;
/**
* Wraps an underlying EbeanServer.
*
* Can you used for testing purposes when you want to create a test double that
* only replaces some of the underlying functionality of the EbeanServer.
*/
public class DelegateQuery {
protected Database delegate;
protected Database owner;
/**
* Construct with a EbeanServer to delegate to by default.
*
* This delegate will be used on all method calls that are not overwritten.
*/
public DelegateQuery(Database delegate, Database owner) {
this.delegate = delegate;
this.owner = owner;
}
public Query delegateToThisServer(Query sourceQuery) {
return DelegateOrmQuery.copy(sourceQuery, owner);
}
public Query findNative(Class beanType, String nativeSql) {
return delegateToThisServer(delegate.findNative(beanType, nativeSql));
}
public Query createQuery(Class beanType) {
return delegateToThisServer(delegate.createQuery(beanType));
}
public Query find(Class beanType) {
return delegateToThisServer(delegate.find(beanType));
}
public Filter filter(Class beanType) {
return delegate.filter(beanType);
}
public SqlQuery sqlQuery(String sql) {
return delegate.sqlQuery(sql);
}
public T reference(Class beanType, Object id) {
return delegate.reference(beanType, id);
}
public Set validateQuery(Query query) {
return delegate.validateQuery(query);
}
public Query createQuery(Class beanType, String eql) {
return delegate.createQuery(beanType, eql);
}
public Query createNamedQuery(Class beanType, String namedQuery) {
return delegate.createNamedQuery(beanType, namedQuery);
}
public DtoQuery findDto(Class dtoType, String sql) {
return delegate.findDto(dtoType, sql);
}
public DtoQuery createNamedDtoQuery(Class dtoType, String namedQuery) {
return delegate.createNamedDtoQuery(dtoType, namedQuery);
}
}