Search in sources :

Example 1 with QueryException

use of org.qi4j.api.query.QueryException in project qi4j-sdk by Qi4j.

the class NonQueryableTest method testQueryIterable.

@Test
public void testQueryIterable() {
    UnitOfWork unitOfWork = module.newUnitOfWork();
    try {
        module.newQueryBuilder(Abc2.class);
        Assert.fail("Exception was expected.");
    } catch (QueryException e) {
    // expected!!
    } finally {
        unitOfWork.discard();
    }
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) QueryException(org.qi4j.api.query.QueryException) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Example 2 with QueryException

use of org.qi4j.api.query.QueryException in project qi4j-sdk by Qi4j.

the class NonQueryableTest method whenQuerableIsFalseOnPropertyThenExpectException.

@Test
public void whenQuerableIsFalseOnPropertyThenExpectException() {
    UnitOfWork unitOfWork = module.newUnitOfWork();
    try {
        QueryBuilder<Abc> builder = module.newQueryBuilder(Abc.class);
        Abc proto = templateFor(Abc.class);
        builder.where(eq(proto.isValid(), Boolean.TRUE));
        Assert.fail("Exception was expected.");
    } catch (QueryException e) {
    // expected!!
    } finally {
        unitOfWork.discard();
    }
}
Also used : UnitOfWork(org.qi4j.api.unitofwork.UnitOfWork) QueryException(org.qi4j.api.query.QueryException) AbstractQi4jTest(org.qi4j.test.AbstractQi4jTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 QueryException (org.qi4j.api.query.QueryException)2 UnitOfWork (org.qi4j.api.unitofwork.UnitOfWork)2 AbstractQi4jTest (org.qi4j.test.AbstractQi4jTest)2