### Question:
DatePartition extends BasePartition implements JdbcFragmentMetadata { @Override public String toSqlConstraint(String quoteString, DbProduct dbProduct) { if (quoteString == null) { throw new RuntimeException("Quote string cannot be null"); } if (dbProduct == null) { throw new RuntimeException(String.format( "DbProduct cannot be null for partitions of type '%s'", PartitionType.DATE )); } return generateRangeConstraint( quoteString + column + quoteString, Stream.of(boundaries).map(b -> b == null ? null : dbProduct.wrapDate(b)).toArray(String[]::new) ); } DatePartition(String column, LocalDate start, LocalDate end); @Override String toSqlConstraint(String quoteString, DbProduct dbProduct); Date[] getBoundaries();  }### Answer:
@Test public void testNormal() { DatePartition partition = new DatePartition(COL_RAW, LocalDate.parse("2000-01-01"), LocalDate.parse("2000-01-02")); String constraint = partition.toSqlConstraint(QUOTE, dbProduct); assertEquals( COL + " >= date'2000-01-01' AND " + COL + " < date'2000-01-02'", constraint ); assertEquals(COL_RAW, partition.getColumn()); }
@Test public void testRightBounded() { DatePartition partition = new DatePartition(COL_RAW, null, LocalDate.parse("2000-01-01")); String constraint = partition.toSqlConstraint(QUOTE, dbProduct); assertEquals( COL + " < date'2000-01-01'", constraint ); }
@Test public void testLeftBounded() { DatePartition partition = new DatePartition(COL_RAW, LocalDate.parse("2000-01-01"), null); String constraint = partition.toSqlConstraint(QUOTE, dbProduct); assertEquals( COL + " >= date'2000-01-01'", constraint ); }
@Test public void testSpecialDateValue() { DatePartition partition = new DatePartition(COL_RAW, LocalDate.parse("0001-01-01"), LocalDate.parse("1970-01-02")); String constraint = partition.toSqlConstraint(QUOTE, dbProduct); assertEquals( COL + " >= date'0001-01-01' AND " + COL + " < date'1970-01-02'", constraint ); }
@Test public void testInvalidNullQuoteString() { DatePartition partition = new DatePartition(COL_RAW, LocalDate.parse("2000-01-01"), LocalDate.parse("2000-01-02")); thrown.expect(RuntimeException.class); partition.toSqlConstraint(null, dbProduct); }
@Test public void testInvalidNullDbProduct() { DatePartition partition = new DatePartition(COL_RAW, LocalDate.parse("2000-01-01"), LocalDate.parse("2000-01-02")); thrown.expect(RuntimeException.class); partition.toSqlConstraint(COL, null); }