/** * Create a predicate testing for a false value. * * @param x * expression to be tested if false * @return predicate */ public Predicate isFalse(Expression<Boolean> x){ if (((InternalExpression)x).isPredicate()){ if (((InternalSelection)x).getCurrentNode() == null){ if (((Predicate)x).getOperator() == BooleanOperator.AND){ return (Predicate)x; }else{ return this.conjunction(); } }else{ throw new IllegalArgumentException(ExceptionLocalization.buildMessage("PREDICATE_PASSED_TO_EVALUATION")); } } return new CompoundExpressionImpl(this.metamodel, ((InternalSelection)x).getCurrentNode().equal(false), buildList(x), "equals"); }
@Test public void testGetPredicateForInClauseTwoChunks() { // Create the JPA builder, query, and entity root. CriteriaBuilder builder = entityManager.getCriteriaBuilder(); CriteriaQuery<BusinessObjectDataEntity> criteria = builder.createQuery(BusinessObjectDataEntity.class); Root<BusinessObjectDataEntity> businessObjectDataEntity = criteria.from(BusinessObjectDataEntity.class); // Get the predicate for the "in" clause with 1001 values (1 greater than the default chunking size). Predicate predicate = baseJpaDaoImpl .getPredicateForInClause(builder, businessObjectDataEntity.get(BusinessObjectDataEntity_.partitionValue), getPartitionValueList(1001)); // We expect to get back an "or" of 2 "in" expressions where each "in" expression is a list of chunked partition values. assertEquals(Predicate.BooleanOperator.OR, predicate.getOperator()); List<Expression<Boolean>> expressions = predicate.getExpressions(); assertEquals(2, expressions.size()); // The first "in" clause will have the first 1000 elements and the second "in" clause will have the extra "1" element. assertEquals(1000, ((InPredicate) expressions.get(0)).getValues().size()); assertEquals(1, ((InPredicate) expressions.get(1)).getValues().size()); }