Search in sources :

Example 1 with EventDocumentConverter

use of org.apache.rya.indexing.geotemporal.mongo.EventDocumentConverter 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)

Aggregations

Coordinate (com.vividsolutions.jts.geom.Coordinate)1 Geometry (com.vividsolutions.jts.geom.Geometry)1 RyaURI (org.apache.rya.api.domain.RyaURI)1 TemporalInstant (org.apache.rya.indexing.TemporalInstant)1 TemporalInstantRfc3339 (org.apache.rya.indexing.TemporalInstantRfc3339)1 Event (org.apache.rya.indexing.geotemporal.model.Event)1 EventDocumentConverter (org.apache.rya.indexing.geotemporal.mongo.EventDocumentConverter)1 Document (org.bson.Document)1 Test (org.junit.Test)1