PlacementConstraints { public static AbstractConstraint targetNotIn(String scope, TargetExpression... targetExpressions) { return new SingleConstraint(scope, 0, 0, targetExpressions); } private  PlacementConstraints(); static AbstractConstraint targetIn(String scope,
      TargetExpression... targetExpressions); static AbstractConstraint targetNotIn(String scope,
      TargetExpression... targetExpressions); static AbstractConstraint targetNodeAttribute(String scope,
      NodeAttributeOpCode opCode,
      TargetExpression... targetExpressions); static AbstractConstraint cardinality(String scope, int minCardinality,
      int maxCardinality, String... allocationTags); static AbstractConstraint cardinality(String scope, String namespace,
      int minCardinality, int maxCardinality, String... allocationTags); static AbstractConstraint minCardinality(String scope,
      int minCardinality, String... allocationTags); static AbstractConstraint minCardinality(String scope,
      String namespace, int minCardinality, String... allocationTags); static AbstractConstraint maxCardinality(String scope,
      int maxCardinality, String... allocationTags); static AbstractConstraint maxCardinality(String scope,
      String tagNamespace, int maxCardinality, String... allocationTags); static AbstractConstraint targetCardinality(String scope,
      int minCardinality, int maxCardinality,
      TargetExpression... targetExpressions); static And and(AbstractConstraint... children); static Or or(AbstractConstraint... children); static DelayedOr delayedOr(TimedPlacementConstraint... children); static TimedPlacementConstraint timedClockConstraint(
      AbstractConstraint constraint, long delay, TimeUnit timeUnit); static TimedPlacementConstraint timedOpportunitiesConstraint(
      AbstractConstraint constraint, long delay); static PlacementConstraint build(AbstractConstraint constraintExpr); static final String NODE; static final String RACK; static final String NODE_PARTITION; }
@Test public void testNodeAntiAffinityToAttribute() { AbstractConstraint constraintExpr = targetNotIn(NODE, nodeAttribute("java", "1.8")); SingleConstraint sConstraint = (SingleConstraint) constraintExpr; Assert.assertEquals(NODE, sConstraint.getScope()); Assert.assertEquals(0, sConstraint.getMinCardinality()); Assert.assertEquals(0, sConstraint.getMaxCardinality()); Assert.assertEquals(1, sConstraint.getTargetExpressions().size()); TargetExpression tExpr = sConstraint.getTargetExpressions().iterator().next(); Assert.assertEquals("java", tExpr.getTargetKey()); Assert.assertEquals(TargetType.NODE_ATTRIBUTE, tExpr.getTargetType()); Assert.assertEquals(1, tExpr.getTargetValues().size()); Assert.assertEquals("1.8", tExpr.getTargetValues().iterator().next()); }