use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class AbstractBaseTest method testQuery.
protected TestQuery<?> testQuery() {
TestQuery<Void> testQuery = new TestQuery<Void>(connection, configuration, new DefaultQueryMetadata());
testQuery.addListener(new TestLoggingListener());
return testQuery;
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class SQLListenersTest method notifyQuery_detailedListener_contexSetting.
@Test
public void notifyQuery_detailedListener_contexSetting() {
SQLListenerContext sqlListenerContext = new SQLListenerContextImpl(new DefaultQueryMetadata());
SQLDetailedListener listenerParent = new AssertingDetailedListener("keyParent", "valueParent");
SQLDetailedListener listener1 = new AssertingDetailedListener("key1", "value1");
SQLDetailedListener listener2 = new AssertingDetailedListener("key1", "value1");
SQLListeners listeners = new SQLListeners(listenerParent);
listeners.add(listener1);
listeners.add(listener2);
listeners.start(sqlListenerContext);
listeners.preRender(sqlListenerContext);
listeners.rendered(sqlListenerContext);
listeners.prePrepare(sqlListenerContext);
listeners.prepared(sqlListenerContext);
listeners.preExecute(sqlListenerContext);
listeners.preExecute(sqlListenerContext);
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class SQLListenersTest method notifyQuery.
@Test
public void notifyQuery() {
SQLListener listener = createMock(SQLListener.class);
SQLListeners listeners = new SQLListeners();
listeners.add(listener);
QueryMetadata md = new DefaultQueryMetadata();
listener.notifyQuery(md);
replay(listener);
listeners.notifyQuery(md);
verify(listener);
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class QueryMetadataTest method reusage.
@Test
public void reusage() {
QueryMetadata metadata = new DefaultQueryMetadata();
metadata.addJoin(JoinType.DEFAULT, cat);
metadata.addWhere(cat.name.startsWith("A"));
CollQuery<?> query = new CollQuery<Void>(metadata);
query.bind(cat, cats);
assertEquals(Arrays.asList(c3), query.select(cat).fetch());
}
use of com.querydsl.core.DefaultQueryMetadata in project querydsl by querydsl.
the class SerializationTest method expressions.
@Test
public void expressions() throws Exception {
Map<Class<?>, Object> args = Maps.newHashMap();
args.put(Object.class, "obj");
args.put(BeanPath.class, new EntityPathBase<Object>(Object.class, "obj"));
args.put(Class.class, Integer.class);
args.put(Class[].class, new Class<?>[] { Object.class, Object.class });
args.put(java.util.Date.class, new java.util.Date(0));
args.put(java.sql.Date.class, new java.sql.Date(0));
args.put(java.sql.Time.class, new java.sql.Time(0));
args.put(java.sql.Timestamp.class, new java.sql.Timestamp(0));
args.put(Expression.class, Expressions.enumPath(Gender.class, "e"));
args.put(Expression[].class, new Expression<?>[] { Expressions.enumPath(Gender.class, "e"), Expressions.stringPath("s") });
args.put(FactoryExpression.class, Projections.tuple(Expressions.stringPath("str")));
args.put(GroupExpression.class, GroupBy.avg(Expressions.numberPath(Integer.class, "num")));
args.put(Number.class, 1);
args.put(Operator.class, Ops.AND);
args.put(Path.class, Expressions.stringPath("str"));
args.put(PathBuilderValidator.class, PathBuilderValidator.DEFAULT);
args.put(PathMetadata.class, PathMetadataFactory.forVariable("obj"));
args.put(PathInits.class, PathInits.DEFAULT);
args.put(Predicate.class, Expressions.path(Object.class, "obj").isNull());
args.put(QueryMetadata.class, new DefaultQueryMetadata());
args.put(String.class, "obj");
Reflections reflections = new Reflections();
Set<Class<? extends Expression>> types = reflections.getSubTypesOf(Expression.class);
for (Class<?> type : types) {
if (!type.isInterface() && !type.isMemberClass() && !Modifier.isAbstract(type.getModifiers())) {
for (Constructor<?> c : type.getConstructors()) {
Object[] parameters = new Object[c.getParameterTypes().length];
for (int i = 0; i < c.getParameterTypes().length; i++) {
parameters[i] = Objects.requireNonNull(args.get(c.getParameterTypes()[i]), c.getParameterTypes()[i].getName());
}
c.setAccessible(true);
Object o = c.newInstance(parameters);
assertEquals(o, Serialization.serialize(o));
}
}
}
}
Aggregations