use of org.geotools.temporal.object.DefaultPeriodDuration in project ddf by codice.
the class SolrProviderTest method testTemporalDuring.
@Test
public void testTemporalDuring() throws Exception {
deleteAllIn(provider);
Metacard metacard = new MockMetacard(Library.getFlagstaffRecord());
List<Metacard> list = Arrays.asList(metacard);
/** CREATE **/
create(list);
/** TEMPORAL QUERY - DURING FILTER (Period) - AKA ABSOLUTE **/
FilterFactory filterFactory = new FilterFactoryImpl();
int minutes = 3;
DateTime startDT = new DateTime().plusMinutes(ALL_RESULTS * minutes);
DateTime endDT = new DateTime();
CommonQueryBuilder queryBuilder = new CommonQueryBuilder();
QueryImpl query = queryBuilder.during(Metacard.MODIFIED, startDT.toDate(), endDT.toDate());
query.setStartIndex(1);
SourceResponse sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(1, sourceResponse.getResults().size());
for (Result content : sourceResponse.getResults()) {
String term = FLAGSTAFF_QUERY_PHRASE;
LOGGER.debug("RESULT returned: {}", content);
String metadata = content.getMetacard().getMetadata();
assertTrue("Testing if contents has term [" + term + "]", ALL_RESULTS != metadata.indexOf(term));
}
/** TEMPORAL QUERY - DURING FILTER (Duration) - AKA RELATIVE **/
DefaultPeriodDuration duration = new DefaultPeriodDuration(minutes * MINUTES_IN_MILLISECONDS);
Filter filter = filterFactory.during(filterFactory.property(Metacard.MODIFIED), filterFactory.literal(duration));
query = new QueryImpl(filter);
sourceResponse = provider.query(new QueryRequestImpl(query));
assertEquals(1, sourceResponse.getResults().size());
for (Result content : sourceResponse.getResults()) {
String term = FLAGSTAFF_QUERY_PHRASE;
LOGGER.debug("RESULT returned: {}", content);
String metadata = content.getMetacard().getMetadata();
assertTrue("Testing if contents has term [" + term + "]", ALL_RESULTS != metadata.indexOf(term));
}
provider.isAvailable();
}
Aggregations