Search in sources :

Example 16 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class EventDocumentConverterTest method to_and_from_document.

@Test
public void to_and_from_document() throws DocumentConverterException {
    final Geometry geo = GF.createPoint(new Coordinate(10, 10));
    final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.now());
    // An Event that will be stored.
    final Event event = Event.builder().setSubject(new RyaURI("urn:event/001")).setGeometry(geo).setTemporalInstant(instant).build();
    final Document document = new EventDocumentConverter().toDocument(event);
    // Convert the Document back into an Event.
    final Event converted = new EventDocumentConverter().fromDocument(document);
    // Ensure the original matches the round trip converted Event.
    assertEquals(event, converted);
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) Coordinate(com.vividsolutions.jts.geom.Coordinate) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) Event(org.apache.rya.indexing.geotemporal.model.Event) EventDocumentConverter(org.apache.rya.indexing.geotemporal.mongo.EventDocumentConverter) TemporalInstant(org.apache.rya.indexing.TemporalInstant) Document(org.bson.Document) Test(org.junit.Test)

Example 17 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class MongoEventStorageIT method create_and_get.

@Test
public void create_and_get() throws Exception {
    final Geometry geo = GF.createPoint(new Coordinate(10, 10));
    final TemporalInstant instant = new TemporalInstantRfc3339(DateTime.now());
    // An Event that will be stored.
    final Event event = Event.builder().setSubject(new RyaURI("urn:event/001")).setGeometry(geo).setTemporalInstant(instant).build();
    // Create it.
    final EventStorage storage = new MongoEventStorage(super.getMongoClient(), RYA_INSTANCE_NAME);
    storage.create(event);
    // Get it.
    final Optional<Event> storedEvent = storage.get(new RyaURI("urn:event/001"));
    // Verify the correct value was returned.
    assertEquals(event, storedEvent.get());
}
Also used : Geometry(com.vividsolutions.jts.geom.Geometry) RyaURI(org.apache.rya.api.domain.RyaURI) Coordinate(com.vividsolutions.jts.geom.Coordinate) TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) Event(org.apache.rya.indexing.geotemporal.model.Event) TemporalInstant(org.apache.rya.indexing.TemporalInstant) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) Test(org.junit.Test)

Example 18 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class TemporalIntervalTest method keyBeginTest.

@Test
public void keyBeginTest() throws Exception {
    // 58 seconds, earlier
    TemporalInterval beginTI01 = new TemporalInterval(// 
    new TemporalInstantRfc3339(2015, 12, 30, 12, 59, 58), // 
    new TemporalInstantRfc3339(2016, 12, 30, 13, 00, 00));
    // 59 seconds, later
    TemporalInterval beginTI02 = new TemporalInterval(// 
    new TemporalInstantRfc3339(2015, 12, 30, 12, 59, 59), // 
    new TemporalInstantRfc3339(2016, 12, 30, 13, 00, 00));
    String key01b = Arrays.toString(beginTI01.getAsKeyBeginning());
    String key02b = Arrays.toString(beginTI02.getAsKeyBeginning());
    Assert.assertEquals("key02 is later so comparesTo = 1.", 1, key02b.compareTo(key01b));
    Assert.assertEquals("key01 is first so comparesTo = -1", -1, key01b.compareTo(key02b));
}
Also used : TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Example 19 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class TemporalIntervalTest method infinitePastFutureAlwaysTest.

@Test
public void infinitePastFutureAlwaysTest() throws Exception {
    final TemporalInstant TestDateString = new TemporalInstantRfc3339(new DateTime("2015-01-01T01:59:59Z"));
    TemporalInterval tvFuture = new TemporalInterval(TestDateString, TemporalInstantRfc3339.getMaximumInstance());
    TemporalInterval tvPast = new TemporalInterval(TemporalInstantRfc3339.getMinimumInstance(), TestDateString);
    TemporalInterval tvAlways = new TemporalInterval(TemporalInstantRfc3339.getMinimumInstance(), TemporalInstantRfc3339.getMaximumInstance());
    Assert.assertTrue("The future is greater (starts after) than the past for compareTo().", tvFuture.compareTo(tvPast) > 0);
    Assert.assertTrue("The future is greater (starts after) than always for compareTo().", tvFuture.compareTo(tvAlways) > 0);
    Assert.assertTrue("The past is less (starts same, ends earlier) than always for compareTo().", tvFuture.compareTo(tvPast) > 0);
}
Also used : TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) TemporalInstant(org.apache.rya.indexing.TemporalInstant) TemporalInterval(org.apache.rya.indexing.TemporalInterval) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Example 20 with TemporalInstantRfc3339

use of org.apache.rya.indexing.TemporalInstantRfc3339 in project incubator-rya by apache.

the class TemporalIntervalTest method constructorBadArgTest.

@Test
public void constructorBadArgTest() throws Exception {
    // the end precedes the beginning:
    try {
        TemporalInterval ti = new // 
        TemporalInterval(// 
        new TemporalInstantRfc3339(2017, 12, 30, 12, 59, 59), // the invention of algebra.
        new TemporalInstantRfc3339(820, 12, 30, 12, 59, 59));
        Assert.assertFalse("Constructor should throw an error if the beginning is after the end, but no error for interval:" + ti, true);
    } catch (IllegalArgumentException e) {
    // expected to catch this error.
    }
}
Also used : TemporalInstantRfc3339(org.apache.rya.indexing.TemporalInstantRfc3339) TemporalInterval(org.apache.rya.indexing.TemporalInterval) Test(org.junit.Test)

Aggregations

TemporalInstantRfc3339 (org.apache.rya.indexing.TemporalInstantRfc3339)34 Test (org.junit.Test)26 TemporalInstant (org.apache.rya.indexing.TemporalInstant)21 RyaURI (org.apache.rya.api.domain.RyaURI)15 Geometry (com.vividsolutions.jts.geom.Geometry)13 Coordinate (com.vividsolutions.jts.geom.Coordinate)12 TemporalInterval (org.apache.rya.indexing.TemporalInterval)12 EventStorage (org.apache.rya.indexing.geotemporal.storage.EventStorage)11 URI (org.openrdf.model.URI)11 Event (org.apache.rya.indexing.geotemporal.model.Event)9 Value (org.openrdf.model.Value)9 ValueFactory (org.openrdf.model.ValueFactory)9 ValueFactoryImpl (org.openrdf.model.impl.ValueFactoryImpl)9 EventQueryNode (org.apache.rya.indexing.geotemporal.model.EventQueryNode)7 DateTime (org.joda.time.DateTime)5 MongoEventStorage (org.apache.rya.indexing.geotemporal.mongo.MongoEventStorage)4 BindingSet (org.openrdf.query.BindingSet)4 QueryEvaluationException (org.openrdf.query.QueryEvaluationException)4 MapBindingSet (org.openrdf.query.impl.MapBindingSet)4 IOException (java.io.IOException)3