Search in sources :

Example 6 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testOverlapsNullNest.

@Test
public void testOverlapsNullNest() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    TOverlaps overlapsFilter = new TOverlapsImpl(duringFilter.getExpression1(), duringFilter.getExpression2());
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(overlapsFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), allOf(is(notNullValue()), hasProperty("startDate", is(START_DATE)), hasProperty("endDate", is(END_DATE))));
}
Also used : TOverlaps(org.opengis.filter.temporal.TOverlaps) During(org.opengis.filter.temporal.During) TOverlapsImpl(org.geotools.filter.temporal.TOverlapsImpl) Test(org.junit.Test)

Example 7 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testDuringOrNest.

@Test
public void testDuringOrNest() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.OR);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(duringFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), is(nullValue()));
}
Also used : During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Example 8 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testDuringDates.

@Test
public void testDuringDates() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(duringFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), allOf(is(notNullValue()), hasProperty("startDate", is(START_DATE)), hasProperty("endDate", is(END_DATE))));
}
Also used : During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Example 9 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testDuringLast.

@Test
public void testDuringLast() {
    long durationInMilliSeconds = TimeUnit.DAYS.toMillis(10);
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().last(durationInMilliSeconds);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    openSearchFilterVisitorObject.setCurrentNest(NestedTypes.AND);
    Date currentDate = Calendar.getInstance().getTime();
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(duringFilter, openSearchFilterVisitorObject);
    TemporalFilter temporalSearch = result.getTemporalSearch();
    assertThat(temporalSearch, is(notNullValue()));
    Date endDate = temporalSearch.getEndDate();
    assertThat("end date should be the current date", endDate, DateMatchers.within(10, ChronoUnit.SECONDS, currentDate));
    assertThat("start date should be before the end date", temporalSearch.getStartDate(), DateMatchers.sameInstant(endDate.getTime() - durationInMilliSeconds));
}
Also used : TemporalFilter(ddf.catalog.impl.filter.TemporalFilter) During(org.opengis.filter.temporal.During) Date(java.util.Date) Test(org.junit.Test)

Example 10 with During

use of org.opengis.filter.temporal.During in project ddf by codice.

the class OpenSearchFilterVisitorTest method testDuringNullNest.

@Test
public void testDuringNullNest() {
    During duringFilter = (During) geotoolsFilterBuilder.attribute(TEMPORAL_ATTRIBUTE_NAME).during().dates(START_DATE, END_DATE);
    OpenSearchFilterVisitorObject openSearchFilterVisitorObject = new OpenSearchFilterVisitorObject();
    OpenSearchFilterVisitorObject result = (OpenSearchFilterVisitorObject) openSearchFilterVisitor.visit(duringFilter, openSearchFilterVisitorObject);
    assertThat(result.getTemporalSearch(), allOf(is(notNullValue()), hasProperty("startDate", is(START_DATE)), hasProperty("endDate", is(END_DATE))));
}
Also used : During(org.opengis.filter.temporal.During) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)12 During (org.opengis.filter.temporal.During)12 Date (java.util.Date)3 TOverlapsImpl (org.geotools.filter.temporal.TOverlapsImpl)3 TOverlaps (org.opengis.filter.temporal.TOverlaps)3 And (org.opengis.filter.And)2 Contains (org.opengis.filter.spatial.Contains)2 FilterBuilder (ddf.catalog.filter.FilterBuilder)1 GeotoolsFilterBuilder (ddf.catalog.filter.proxy.builder.GeotoolsFilterBuilder)1 TemporalFilter (ddf.catalog.impl.filter.TemporalFilter)1 QName (javax.xml.namespace.QName)1 CswQueryFactoryTest (org.codice.ddf.spatial.ogc.csw.catalog.endpoint.CswQueryFactoryTest)1 NameImpl (org.geotools.feature.NameImpl)1 AttributeExpressionImpl (org.geotools.filter.AttributeExpressionImpl)1 DefaultFilterVisitor (org.geotools.filter.visitor.DefaultFilterVisitor)1 InOrder (org.mockito.InOrder)1 Filter (org.opengis.filter.Filter)1 FilterVisitor (org.opengis.filter.FilterVisitor)1 PropertyIsGreaterThan (org.opengis.filter.PropertyIsGreaterThan)1 Expression (org.opengis.filter.expression.Expression)1