I am trying to fetch a list of records between two Instants using Spring Data's @Query
.
/**
* Finds all the non-duplicate customers.
*
* @return The list of non-duplicate customers.
*/
//@formatter:off
@Query("SELECT c "
+ "FROM Customer c "
+ "WHERE c.isDuplicate = false "
+ " AND c.created BETWEEN :start AND :end "
+ "ORDER BY c.created")
//@formatter:on
List<Customer> findAllNonDuplicateCustomers(
@Param("start") Instant start,
@Param("end") Instant end
);
While testing I found that:
this.customerRepository.findAllNonDuplicateCustomers(
Instant.MIN,
Instant.MAX
)
returns an empty list, but:
this.customerRepository.findAllNonDuplicateCustomers(
this.customers.get("rob").getCreated(),
this.customers.get("robba").getCreated()
)
returns the desired results.
Test scenario:
My test inserts 6 customers into an embedded H2 database and tries to run the query.
Since Instant is Comparable, and it works fine for exact customers, is it wrong to use Instant.MIN and Instant.MAX for boundary testing?