Search in sources :

Example 16 with ExcludeIn

use of com.querydsl.core.testutil.ExcludeIn in project querydsl by querydsl.

the class TargetRule method isExecuted.

private boolean isExecuted(Description description, Target target) {
    ExcludeIn ex = description.getAnnotation(ExcludeIn.class);
    // excluded in given targets
    if (ex != null && Arrays.asList(ex.value()).contains(target)) {
        return false;
    }
    // included only in given targets
    IncludeIn in = description.getAnnotation(IncludeIn.class);
    if (in != null && !Arrays.asList(in.value()).contains(target)) {
        return false;
    }
    return true;
}
Also used : IncludeIn(com.querydsl.core.testutil.IncludeIn) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 17 with ExcludeIn

use of com.querydsl.core.testutil.ExcludeIn in project querydsl by querydsl.

the class SelectBase method date_diff.

@Test
@ExcludeIn({ DB2, SQLITE, TERADATA })
public void date_diff() {
    QEmployee employee2 = new QEmployee("employee2");
    SQLQuery<?> query = query().from(employee).orderBy(employee.id.asc());
    SQLQuery<?> query2 = query().from(employee, employee2).orderBy(employee.id.asc(), employee2.id.desc());
    List<DatePart> dps = Lists.newArrayList();
    add(dps, DatePart.year);
    add(dps, DatePart.month);
    add(dps, DatePart.week);
    add(dps, DatePart.day);
    add(dps, DatePart.hour, HSQLDB);
    add(dps, DatePart.minute, HSQLDB);
    add(dps, DatePart.second, HSQLDB);
    LocalDate localDate = new LocalDate(1970, 1, 10);
    Date date = new Date(localDate.toDateMidnight().getMillis());
    for (DatePart dp : dps) {
        int diff1 = query.select(SQLExpressions.datediff(dp, date, employee.datefield)).fetchFirst();
        int diff2 = query.select(SQLExpressions.datediff(dp, employee.datefield, date)).fetchFirst();
        int diff3 = query2.select(SQLExpressions.datediff(dp, employee.datefield, employee2.datefield)).fetchFirst();
        assertEquals(diff1, -diff2);
    }
}
Also used : Date(java.sql.Date) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 18 with ExcludeIn

use of com.querydsl.core.testutil.ExcludeIn in project querydsl by querydsl.

the class MergeBase method merge_with_keys.

@Test
@ExcludeIn({ H2, CUBRID, SQLSERVER })
public void merge_with_keys() throws SQLException {
    ResultSet rs = merge(survey).keys(survey.id).set(survey.id, 7).set(survey.name, "Hello World").executeWithKeys();
    assertTrue(rs.next());
    assertTrue(rs.getObject(1) != null);
    rs.close();
}
Also used : ResultSet(java.sql.ResultSet) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 19 with ExcludeIn

use of com.querydsl.core.testutil.ExcludeIn in project querydsl by querydsl.

the class UnionBase method union_multiple_columns3.

@SuppressWarnings("unchecked")
@Test
@ExcludeIn(DERBY)
public void union_multiple_columns3() throws SQLException {
    SubQueryExpression<Tuple> sq1 = query().from(employee).select(employee.firstname, employee.lastname);
    SubQueryExpression<Tuple> sq2 = query().from(employee).select(employee.firstname, employee.lastname);
    SQLQuery<?> query = query();
    query.union(sq1, sq2);
    List<Tuple> list = query.select(employee.lastname, employee.firstname).fetch();
    assertFalse(list.isEmpty());
    for (Tuple row : list) {
        System.out.println(row.get(0, String.class) + " " + row.get(1, String.class));
    }
}
Also used : Tuple(com.querydsl.core.Tuple) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Example 20 with ExcludeIn

use of com.querydsl.core.testutil.ExcludeIn in project querydsl by querydsl.

the class SpatialBase method point_distance.

@Test
@ExcludeIn(MYSQL)
public void point_distance() {
    QShapes shapes1 = QShapes.shapes;
    QShapes shapes2 = new QShapes("shapes2");
    for (Tuple tuple : query().from(shapes1, shapes2).where(shapes1.id.loe(5), shapes2.id.loe(5)).select(shapes1.geometry.asPoint(), shapes2.geometry.asPoint(), shapes1.geometry.distance(shapes2.geometry)).fetch()) {
        Point point1 = tuple.get(shapes1.geometry.asPoint());
        Point point2 = tuple.get(shapes2.geometry.asPoint());
        Double distance = tuple.get(shapes1.geometry.distance(shapes2.geometry));
        assertEquals(point1.distance(point2), distance, 0.0001);
    }
}
Also used : Tuple(com.querydsl.core.Tuple) AbstractBaseTest(com.querydsl.sql.AbstractBaseTest) Test(org.junit.Test) ExcludeIn(com.querydsl.core.testutil.ExcludeIn)

Aggregations

ExcludeIn (com.querydsl.core.testutil.ExcludeIn)40 Test (org.junit.Test)38 Tuple (com.querydsl.core.Tuple)9 SQLInsertClause (com.querydsl.sql.dml.SQLInsertClause)6 ResultSet (java.sql.ResultSet)6 SAnimal (com.querydsl.jpa.domain.sql.SAnimal)4 QEmployee (com.querydsl.sql.domain.QEmployee)4 BigDecimal (java.math.BigDecimal)4 Date (java.sql.Date)4 Ignore (org.junit.Ignore)4 AbstractBaseTest (com.querydsl.sql.AbstractBaseTest)3 Group (com.querydsl.core.group.Group)2 IncludeIn (com.querydsl.core.testutil.IncludeIn)2 QCat (com.querydsl.jpa.domain.QCat)2 BigInteger (java.math.BigInteger)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 ImmutableList (com.google.common.collect.ImmutableList)1 MockTuple (com.querydsl.core.group.MockTuple)1 StringPath (com.querydsl.core.types.dsl.StringPath)1 QBookMark (com.querydsl.jpa.domain4.QBookMark)1