TimestampRangeConstraint extends AbstractValueConstraint<Long> { @Override public Map<Parameter<?>, Object> parameters() { Map<Parameter<?>, Object> params = new HashMap<>(2); if (minTimestamp != null) params.put(MIN_TIMESTAMP, minTimestamp); if (maxTimestamp != null) params.put(MAX_TIMESTAMP, maxTimestamp); return params; } TimestampRangeConstraint(String theId, boolean nullAllowed, String theMin, String theMax);  TimestampRangeConstraint(String theId, boolean nullAllowed, Long theMin, Long theMax); @Override String typeTag(); @Override Map<Parameter<?>, Object> parameters(); @Override Violation typedErrorFor(Long value); static final String TypeTag; static final String Docs; static final ConstraintBuilder<Long> Builder; }
@Test public void parameters() { Map<String,String> paramsByKey = asParams( TimestampRangeConstraint.MIN_TIMESTAMP, "2016-02-01 00:00:00", TimestampRangeConstraint.MAX_TIMESTAMP, "2016-03-01 00:00:00"); Collection<Constraint<?>> vcs = TimestampRangeConstraint.Builder.constraintsFrom(Schema.Type.LONG, false, paramsByKey); ValueConstraint<?> vc = (ValueConstraint<?>)vcs.iterator().next(); Map<Parameter<?>, Object> params = vc.parameters(); assertEquals(2, params.size()); }