FloatRangeScale extends RestrictedScale { public boolean validateAndSetRestriction(String restriction) { if (p.matcher(restriction).matches()) { setRestriction(restriction); return true; } else { return false; } }  @Override String getDisplayName(); @Override FloatRangeValue createValue(); boolean validateAndSetRestriction(String restriction); void setLowerBound(double lower); double getLowerBound(); void setUpperBound(double upper); double getUpperBound(); @Override String getRestriction(); @Override String getReadableRestriction(); @Override void setRestriction(String restriction); @Override boolean isEvaluated(Value value); static final String floatPattern; static final String pattern; }
@Test public void testValidateAndSetRestriction_Valid() { FloatRangeScale scale = new FloatRangeScale(); assertEquals(true, scale.validateAndSetRestriction("1/1")); assertEquals(true, scale.validateAndSetRestriction(".1/1")); assertEquals(true, scale.validateAndSetRestriction("1/.1")); assertEquals(true, scale.validateAndSetRestriction("1/1.1")); assertEquals(true, scale.validateAndSetRestriction("1.1/1")); assertEquals(true, scale.validateAndSetRestriction("1/1.112312321")); assertEquals(true, scale.validateAndSetRestriction("1.25/4.8723")); }
@Test public void testValidateAndSetRestriction_Invalid() { FloatRangeScale scale = new FloatRangeScale(); assertEquals(false, scale.validateAndSetRestriction("1/")); assertEquals(false, scale.validateAndSetRestriction("11")); assertEquals(false, scale.validateAndSetRestriction("/")); assertEquals(false, scale.validateAndSetRestriction("/1")); }