Capacity { public static Capacity from(ClusterResources resources) { return from(resources, resources); } private  Capacity(ClusterResources min, ClusterResources max, boolean required, boolean canFail, NodeType type); ClusterResources minResources(); ClusterResources maxResources(); boolean isRequired(); boolean canFail(); NodeType type(); Capacity withGroups(int groups); @Override String toString(); static Capacity from(ClusterResources resources); static Capacity from(ClusterResources min, ClusterResources max); static Capacity from(ClusterResources resources, boolean required, boolean canFail); static Capacity from(ClusterResources min, ClusterResources max, boolean required, boolean canFail); static Capacity fromRequiredNodeType(NodeType type);  }
@Test public void testCapacityValidation() { Capacity.from(new ClusterResources(4, 2, new NodeResources(1,2,3,4)), new ClusterResources(4, 2, new NodeResources(1,2,3,4)), false, true); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1,2,3,4)), new ClusterResources(2, 2, new NodeResources(1,2,3,4))); assertValidationFailure(new ClusterResources(4, 4, new NodeResources(1,2,3,4)), new ClusterResources(4, 2, new NodeResources(1,2,3,4))); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(2,2,3,4)), new ClusterResources(4, 2, new NodeResources(1,2,3,4))); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1,3,3,4)), new ClusterResources(4, 2, new NodeResources(1,2,3,4))); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1,2,4,4)), new ClusterResources(4, 2, new NodeResources(1,2,3,4))); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1,2,3,5)), new ClusterResources(4, 2, new NodeResources(1,2,3,4))); assertValidationFailure(new ClusterResources(4, 2, new NodeResources(1,2,3,4)), new ClusterResources(8, 4, new NodeResources(2,1,6,8))); }