private ITaskConfig checkConstraint( IJobKey job, AttributeAggregate aggregate, IHostAttributes hostAttributes, String constraintName, boolean expected, ValueConstraint value) { Constraint constraint = new Constraint(constraintName, TaskConstraint.value(value)); ITaskConfig task = makeTask(job, constraint); assertEquals( expected, defaultFilter .filter( new UnusedResource(DEFAULT_OFFER, hostAttributes), new ResourceRequest(task, aggregate)) .isEmpty()); Constraint negated = constraint.deepCopy(); negated.getConstraint().getValue().setNegated(!value.isNegated()); ITaskConfig negatedTask = makeTask(job, negated); assertEquals( !expected, defaultFilter .filter( new UnusedResource(DEFAULT_OFFER, hostAttributes), new ResourceRequest(negatedTask, aggregate)) .isEmpty()); return task; }
private static Constraint makeConstraint(String name, String... values) { return new Constraint( name, TaskConstraint.value(new ValueConstraint(false, ImmutableSet.copyOf(values)))); }