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);
}
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());
}
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));
}
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);
}
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.
}
}
Aggregations