### Question:
NegatedConstraint extends Constraint { @Override public org.chocosolver.solver.constraints.Constraint apply(final Model model) { return super.apply(model).getOpposite(); } NegatedConstraint(Constraint constraint); @Override org.chocosolver.solver.constraints.Constraint apply(final Model model);  }### Answer:
@Test void testSatisfiable() { List<TupleList> forbiddenTupleLists = Collections.singletonList(new TupleList(1, new int[]{0, 1}, Arrays.asList(new int[]{0, 0}))); TestModel ipm = new TestModel(1, new int[]{2, 2, 2}, forbiddenTupleLists, Collections.emptyList()); Constraint internalConstraint = new NegatedConstraint(new ConstraintConverter().convertAll(ipm.getForbiddenTupleLists()).get(0)); Model model = new Model(); IntVar var0 = model.intVar("0", 0, 1); IntVar var1 = model.intVar("1", 0, 1); internalConstraint.apply(model).post(); model.arithm(var0, "=", 0).post(); model.arithm(var1, "=", 0); assertTrue(model.getSolver().solve()); }
@Test void testUnsatisfiable() { List<TupleList> forbiddenTupleLists = Collections.singletonList(new TupleList(1, new int[]{0, 1}, Arrays.asList(new int[]{0, 0}))); TestModel ipm = new TestModel(1, new int[]{2, 2, 2}, forbiddenTupleLists, Collections.emptyList()); Constraint internalConstraint = new NegatedConstraint(new ConstraintConverter().convertAll(ipm.getForbiddenTupleLists()).get(0)); Model model = new Model(); IntVar var0 = model.intVar("0", 0, 1); IntVar var1 = model.intVar("1", 0, 1); internalConstraint.apply(model).post(); model.arithm(var0, "=", 1).post(); model.arithm(var1, "=", 1); assertFalse(model.getSolver().solve()); }