-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #829 from 52North/fix/allow_null_result_time_db
Add support for resultTime to be null in the database
- Loading branch information
Showing
19 changed files
with
2,069 additions
and
466 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,36 +28,34 @@ | |
*/ | ||
package org.n52.sos.ds.hibernate.util; | ||
|
||
/** | ||
* Test with instant as temporal filter | ||
* | ||
* @author <a href="mailto:[email protected]">Carsten Hollmann</a> | ||
* | ||
* @since 4.4.0 | ||
*/ | ||
import static org.hamcrest.Matchers.equalTo; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
|
||
import org.hibernate.criterion.Criterion; | ||
import org.joda.time.DateTime; | ||
import org.junit.Test; | ||
import org.n52.shetland.ogc.filter.FilterConstants; | ||
import org.n52.shetland.ogc.filter.TemporalFilter; | ||
import org.n52.shetland.ogc.gml.time.TimeInstant; | ||
import org.n52.shetland.ogc.ows.exception.OwsExceptionReport; | ||
import org.n52.sos.ds.hibernate.ExtendedHibernateTestCase; | ||
import org.n52.sos.ds.hibernate.util.SosTemporalRestrictions; | ||
import org.n52.sos.exception.ows.concrete.UnsupportedOperatorException; | ||
import org.n52.sos.exception.ows.concrete.UnsupportedTimeException; | ||
import org.n52.sos.exception.ows.concrete.UnsupportedValueReferenceException; | ||
|
||
public class TemporalRestrictionHqlInstantInstantTest extends ExtendedHibernateTestCase | ||
implements TemporalRestrictionTestConstants { | ||
/** | ||
* Test with instant as temporal filter | ||
* | ||
* @author <a href="mailto:[email protected]">Carsten Hollmann</a> | ||
* | ||
* @since 4.4.0 | ||
*/ | ||
public class TemporalRestrictionHqlInstantInstantTest implements TemporalRestrictionTestConstants { | ||
|
||
private static final String STE_LT_INSTANT = "samplingTimeEnd<:instant1"; | ||
|
||
private static final String STS_GT_INSTANT_AND_STE_LT_INSTANT = | ||
"samplingTimeStart>:instant1 and samplingTimeEnd<:instant1"; | ||
|
||
private static final String RT_GT_INSTANT_AND_RT_LT_INSTANT = "resultTime>:instant1 and resultTime<:instant1"; | ||
|
||
@Test | ||
public void testAfterPhenomenonTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
|
@@ -66,14 +64,6 @@ public void testAfterPhenomenonTime() | |
assertThat(filterHql.toString(), equalTo("samplingTimeStart>:instant1")); | ||
} | ||
|
||
@Test | ||
public void testAfterResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_After, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo("resultTime>:instant1")); | ||
} | ||
|
||
@Test | ||
public void testBeforePhenomenonTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
|
@@ -82,14 +72,6 @@ public void testBeforePhenomenonTime() | |
assertThat(filterHql.toString(), equalTo("samplingTimeEnd<:instant1")); | ||
} | ||
|
||
@Test | ||
public void testBeforeResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Before, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo("resultTime<:instant1")); | ||
} | ||
|
||
@Test | ||
public void testEqualsPhenomenonTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
|
@@ -98,29 +80,13 @@ public void testEqualsPhenomenonTime() | |
assertThat(filterHql.toString(), equalTo("samplingTimeStart=:instant1 and samplingTimeEnd=:instant1")); | ||
} | ||
|
||
@Test | ||
public void testEqualsResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Equals, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo("resultTime=:instant1")); | ||
} | ||
|
||
@Test | ||
public void testContainsPhenomenonTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Contains, PHENOMENON_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testContainsResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Contains, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(RT_GT_INSTANT_AND_RT_LT_INSTANT)); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testDuringPhenomenonTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
|
@@ -129,26 +95,12 @@ public void testDuringPhenomenonTime() | |
assertThat(filterHql.toString(), equalTo(STS_GT_INSTANT_AND_STE_LT_INSTANT)); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testDuringResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_During, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo("resultTime>:resultTime1 and resultTime<:resultTime1")); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testBeginsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Begins, PHENOMENON_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testBeginsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Begins, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test | ||
public void testBegunByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_BegunBy, PHENOMENON_TIME); | ||
|
@@ -157,81 +109,130 @@ public void testBegunByPhenomenonTime() throws OwsExceptionReport { | |
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testBegunByResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_BegunBy, RESULT_TIME); | ||
public void testEndsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Ends, PHENOMENON_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test | ||
public void testEndedByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_EndedBy, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo("samplingTimeEnd=:instant1")); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testEndsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Ends, PHENOMENON_TIME); | ||
public void testOverlapsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Overlaps, PHENOMENON_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testEndsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Ends, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
public void testOverlappedByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_OverlappedBy, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(STE_LT_INSTANT)); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testMeetsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Meets, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(STS_GT_INSTANT_AND_STE_LT_INSTANT)); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testMetByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_MetBy, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(STS_GT_INSTANT_AND_STE_LT_INSTANT)); | ||
} | ||
|
||
@Test | ||
public void testEndedByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_EndedBy, PHENOMENON_TIME); | ||
public void testAfterResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_After, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo("samplingTimeEnd=:instant1")); | ||
assertThat(filterHql.toString(), equalTo( | ||
"((resultTime is not null and resultTime>:instant1) or (resultTime is null and samplingTimeEnd>:instant1))")); | ||
} | ||
|
||
@Test | ||
public void testBeforeResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Before, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo( | ||
"((resultTime is not null and resultTime<:instant1) or (resultTime is null and samplingTimeEnd<:instant1))")); | ||
} | ||
|
||
@Test | ||
public void testEqualsResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Equals, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo( | ||
"((resultTime is not null and resultTime=:instant1) or (resultTime is null and samplingTimeEnd=:instant1))")); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testEndedByResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_EndedBy, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
public void testContainsResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Contains, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo( | ||
"((resultTime is not null and resultTime>:instant1 and resultTime<:instant1) or (resultTime is null and samplingTimeEnd>:instant1 and samplingTimeEnd<:instant1))")); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testOverlapsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Overlaps, PHENOMENON_TIME); | ||
public void testDuringResultTime() | ||
throws UnsupportedValueReferenceException, UnsupportedTimeException, UnsupportedOperatorException { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_During, RESULT_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo( | ||
"((resultTime is not null and resultTime>:resultTime1 and resultTime<:resultTime1) or (resultTime is null and samplingTimeEnd>:resultTime1 and samplingTimeEnd<:resultTime1))")); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testBeginsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Begins, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testOverlapsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Overlaps, RESULT_TIME); | ||
public void testBegunByResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_BegunBy, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testOverlappedByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_OverlappedBy, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(STE_LT_INSTANT)); | ||
public void testEndsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Ends, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testOverlappedByResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_OverlappedBy, RESULT_TIME); | ||
public void testEndedByResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_EndedBy, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testMeetsPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Meets, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(STS_GT_INSTANT_AND_STE_LT_INSTANT)); | ||
public void testOverlapsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Overlaps, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testMeetsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Meets, RESULT_TIME); | ||
public void testOverlappedByResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_OverlappedBy, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
public void testMetByPhenomenonTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_MetBy, PHENOMENON_TIME); | ||
Criterion filterHql = SosTemporalRestrictions.filterHql(tf, 1); | ||
assertThat(filterHql.toString(), equalTo(STS_GT_INSTANT_AND_STE_LT_INSTANT)); | ||
public void testMeetsResultTime() throws OwsExceptionReport { | ||
TemporalFilter tf = create(FilterConstants.TimeOperator.TM_Meets, RESULT_TIME); | ||
SosTemporalRestrictions.filterHql(tf, 1); | ||
} | ||
|
||
@Test(expected = UnsupportedTimeException.class) | ||
|
Oops, something went wrong.