AbstractSearchRequest extends DirectBean implements PagedRequest { public boolean matches(AbstractDocument document) { if (getVersionCorrection() == null) { return true; } Instant versionFrom = Objects.firstNonNull(document.getVersionFromInstant(), Instant.MIN); Instant versionTo = Objects.firstNonNull(document.getVersionToInstant(), Instant.MAX); Instant correctionFrom = Objects.firstNonNull(document.getCorrectionFromInstant(), Instant.MIN); Instant correctionTo = Objects.firstNonNull(document.getCorrectionToInstant(), Instant.MAX); VersionCorrection locked = getVersionCorrection().withLatestFixed(OpenGammaClock.getInstance().instant()); Instant versionPoint = locked.getVersionAsOf(); Instant corrrectionPoint = locked.getCorrectedTo(); return versionPoint.isBefore(versionTo) && !versionFrom.isAfter(versionPoint) && corrrectionPoint.isBefore(correctionTo) && !correctionFrom.isAfter(corrrectionPoint); } AbstractSearchRequest(); void setVersionCorrection(VersionCorrection versionCorrection); boolean matches(AbstractDocument document); static AbstractSearchRequest.Meta meta(); @Override AbstractSearchRequest.Meta metaBean(); String getUniqueIdScheme(); void setUniqueIdScheme(String uniqueIdScheme); final Property<String> uniqueIdScheme(); PagingRequest getPagingRequest(); void setPagingRequest(PagingRequest pagingRequest); final Property<PagingRequest> pagingRequest(); VersionCorrection getVersionCorrection(); final Property<VersionCorrection> versionCorrection(); @Override AbstractSearchRequest clone(); @Override boolean equals(Object obj); @Override int hashCode(); @Override String toString();  }
@Test(dataProvider = "timeBounds") public void test_matches_versions(Instant instant, Instant start, Instant end, boolean expected) { Mock mock = new Mock(); MockDoc mockDoc = new MockDoc(); mockDoc.setVersionFromInstant(start); mockDoc.setVersionToInstant(end); mockDoc.setCorrectionFromInstant(Instant.MIN); mockDoc.setCorrectionToInstant(Instant.MAX); assertEquals(expected, mock.matches(mockDoc)); }
@Test(dataProvider = "timeBounds") public void test_matches_corrections(Instant instant, Instant start, Instant end, boolean expected) { Mock mock = new Mock(); MockDoc mockDoc = new MockDoc(); mockDoc.setVersionFromInstant(Instant.MIN); mockDoc.setVersionToInstant(Instant.MAX); mockDoc.setCorrectionFromInstant(start); mockDoc.setCorrectionToInstant(end); assertEquals(expected, mock.matches(mockDoc)); }