Example usage for org.hibernate.criterion LogicalExpression getOp

List of usage examples for org.hibernate.criterion LogicalExpression getOp

Introduction

In this page you can find the example usage for org.hibernate.criterion LogicalExpression getOp.

Prototype

public String getOp() 

Source Link

Usage

From source file:org.candlepin.model.CPRestrictionsTest.java

License:Open Source License

@Test
public void testIn() {
    List<String> items = new LinkedList<>();
    StringBuilder expected = new StringBuilder("taylor in (");

    int inBlockSize = config.getInt(DatabaseConfigFactory.IN_OPERATOR_BLOCK_SIZE);
    for (int i = 0; i < inBlockSize * 3; ++i) {
        items.add(String.valueOf(i));

        if (items.size() % inBlockSize == 0) {
            expected.append(i).append(") or taylor in (");
        } else {//from   w  ww .  j a  v a 2  s.c  o  m
            expected.append(i).append(", ");
        }
    }
    expected.setLength(expected.length() - 15);

    Criterion crit = CPRestrictions.in("taylor", items);
    LogicalExpression le = (LogicalExpression) crit;
    assertEquals("or", le.getOp());
    assertEquals(expected.toString(), le.toString());
}

From source file:org.candlepin.model.CPRestrictionsTest.java

License:Open Source License

@Test
public void testInAsArray() {
    List<String> items = new LinkedList<>();
    StringBuilder expected = new StringBuilder("taylor in (");

    int inBlockSize = config.getInt(DatabaseConfigFactory.IN_OPERATOR_BLOCK_SIZE);
    for (int i = 0; i < inBlockSize * 3; ++i) {
        items.add(String.valueOf(i));

        if (items.size() % inBlockSize == 0) {
            expected.append(i).append(") or taylor in (");
        } else {//from w w w  .  j  av  a2  s  .  c o m
            expected.append(i).append(", ");
        }
    }
    expected.setLength(expected.length() - 15);

    Criterion crit = CPRestrictions.in("taylor", items.toArray());
    LogicalExpression le = (LogicalExpression) crit;
    assertEquals("or", le.getOp());
    assertEquals(expected.toString(), le.toString());
}

From source file:org.candlepin.model.PoolCuratorTest.java

License:Open Source License

@Test
public void buildInCriteriaTestBatch() {
    List<String> items = new ArrayList<String>();
    StringBuilder expected = new StringBuilder("taylor in (");

    for (int i = 0; i < AbstractHibernateCurator.IN_OPERATOR_BLOCK_SIZE * 3; ++i) {
        items.add(String.valueOf(i));

        if (items.size() % AbstractHibernateCurator.IN_OPERATOR_BLOCK_SIZE == 0) {
            expected.append(i).append(") or taylor in (");
        } else {/*from w  w w .  ja  va2  s  . c om*/
            expected.append(i).append(", ");
        }
    }
    expected.setLength(expected.length() - 15);

    Criterion crit = poolCurator.unboundedInCriterion("taylor", items);
    LogicalExpression le = (LogicalExpression) crit;
    assertEquals("or", le.getOp());
    assertEquals(expected.toString(), le.toString());
}