Search in sources :

Example 1 with EventAlreadyExistsException

use of org.apache.rya.indexing.geotemporal.storage.EventStorage.EventAlreadyExistsException in project incubator-rya by apache.

the class MongoEventStorageIT method can_not_create_with_same_subject.

@Test
public void can_not_create_with_same_subject() 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);
    // Try to create it again. This will fail.
    boolean failed = false;
    try {
        storage.create(event);
    } catch (final EventAlreadyExistsException e) {
        failed = true;
    }
    assertTrue(failed);
}
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) EventAlreadyExistsException(org.apache.rya.indexing.geotemporal.storage.EventStorage.EventAlreadyExistsException) EventStorage(org.apache.rya.indexing.geotemporal.storage.EventStorage) 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 EventStorage (org.apache.rya.indexing.geotemporal.storage.EventStorage)1 EventAlreadyExistsException (org.apache.rya.indexing.geotemporal.storage.EventStorage.EventAlreadyExistsException)1 Test (org.junit.Test)1