Example usage for org.hibernate.criterion LogicalExpression toString

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

Introduction

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

Prototype

@Override
    public String toString() 

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 w  w .jav  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 {//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 {// ww  w.  j  av a2s. c o m
            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());
}