@Test public void testSizeOK() throws InvalidClusterException { SizeConstraint sizeConstraint = new SizeConstraint(3, 10); for (int i = sizeConstraint.getMin(); i <= sizeConstraint.getMax(); i++) { sizeConstraint.verify(i); } } }
@Test(expected = InvalidClusterException.class) public void testSizeTooBig() throws InvalidClusterException { SizeConstraint sizeConstraint = new SizeConstraint(3, 10); sizeConstraint.verify(11); }
@Override public SizeConstraint deserialize(JsonElement json, Type type, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); Integer min = context.deserialize(jsonObj.get("min"), Integer.class); Integer max = context.deserialize(jsonObj.get("max"), Integer.class); return new SizeConstraint(min, max); } }
sizeConstraint.verify(numMachines); builder.setClusterTemplate(template);
@Test(expected = InvalidClusterException.class) public void testSizeTooSmall() throws InvalidClusterException { SizeConstraint sizeConstraint = new SizeConstraint(3, 10); sizeConstraint.verify(2); }
new SizeConstraint(2, 50) )).build();