private void check(Expression expression, Expression parentExpression, Apint expected) {
   Instance p = (parentExpression == null) ? null : new Instance(solver, null, parentExpression);
   Instance i = new Instance(solver, p, expression);
   Object result = i.request("count");
   assertNotNull(result);
   assertEquals(Apint.class, result.getClass());
   assertEquals(expected, result);
 }
 private void checkVal(
     Expression expression, Expression parentExpression, IntVariable var, int low, int high) {
   Instance p = (parentExpression == null) ? null : new Instance(solver, null, parentExpression);
   Instance i = new Instance(solver, p, expression);
   Object result = i.request("model");
   assertNotNull(result);
   @SuppressWarnings("unchecked")
   Map<IntVariable, Object> res = (Map<IntVariable, Object>) result;
   int value = (Integer) res.get(var);
   System.out.println(" variable " + var + " = " + value + " -> [" + low + "," + high + "]");
   assertTrue(value >= low && value <= high);
 }
 @Override
 protected Boolean solve(Instance instance) {
   CPModel chocoModel = new CPModel();
   Map<Variable, IntegerVariable> variableMap = new HashMap<Variable, IntegerVariable>();
   try {
     new ChocoTranslator(chocoModel, variableMap).translate(instance.getExpression());
     CPSolver chocoSolver = new CPSolver();
     chocoSolver.read(chocoModel);
     return chocoSolver.solve();
   } catch (TranslatorUnsupportedOperation x) {
     log.log(Level.WARNING, x.getMessage(), x);
   } catch (VisitorException x) {
     log.log(Level.SEVERE, "encountered an exception -- this should not be happening!", x);
   }
   return null;
 }