protected Period period(String d1, String d2) throws ParseException { return new DefaultPeriod(instant(d1), instant(d2)); } }
/** Test of setBegining method, of class DefaultPeriod. */ @Test public void testSetBegining_Instant() { Instant result = period1.getBeginning(); Instant newInstant = new DefaultInstant(new DefaultPosition(new Date())); ((DefaultPeriod) period1).setBegining(newInstant); assertFalse(period1.getBeginning().equals(result)); }
/** Test of setEnding method, of class DefaultPeriod. */ @Test public void testSetEnding_Instant() { Instant result = period1.getEnding(); Instant newInstant = new DefaultInstant(new DefaultPosition(new Date())); ((DefaultPeriod) period1).setEnding(newInstant); assertFalse(period1.getEnding().equals(result)); }
/** * Decode a DefaultPeriod object. * * @param objValue the obj value */ public void decode(DefaultPeriod objValue) { DefaultPeriod defaultPeriod = objValue; Instant beginning = defaultPeriod.getBeginning(); Duration startDuration = new Duration(); startDuration.setDate( beginning.getPosition().getDate().toInstant().atZone(ZoneId.systemDefault())); setStart(startDuration); Instant localEnd = defaultPeriod.getEnding(); Duration endDuration = new Duration(); endDuration.setDate( localEnd.getPosition().getDate().toInstant().atZone(ZoneId.systemDefault())); setEnd(endDuration); } }
protected Period period(String d1, String d2) throws ParseException { return new DefaultPeriod(instant(d1), instant(d2)); } }
/** Test of setBegining method, of class DefaultPeriod. */ @Test public void testSetBegining_Date() { Date result = period1.getBeginning().getPosition().getDate(); ((DefaultPeriod) period1).setBegining(new Date()); assertFalse(period1.getBeginning().getPosition().getDate().equals(result)); }
/** Test of setEnding method, of class DefaultPeriod. */ @Test public void testSetEnding_Date() { Date result = period1.getEnding().getPosition().getDate(); ((DefaultPeriod) period1).setEnding(new Date()); assertFalse(period1.getEnding().getPosition().getDate().equals(result)); }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Instant begining = new DefaultInstant((Position) node.getChild("beginPosition").getValue()); Instant ending = new DefaultInstant((Position) node.getChild("endPosition").getValue()); Period timePeriod = new DefaultPeriod(begining, ending); return timePeriod; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated modifiable */ public Object parse(ElementInstance instance, Node node, Object value) throws Exception { Instant begining = new DefaultInstant((Position) node.getChild("BeginPosition").getValue()); Instant ending = new DefaultInstant((Position) node.getChild("EndPosition").getValue()); Period timePeriod = new DefaultPeriod(begining, ending); return timePeriod; }
@Before public void setUp() { Calendar cal = Calendar.getInstance(); cal.set(1995, 1, 1); Instant begining1 = new DefaultInstant(new DefaultPosition(cal.getTime())); cal.set(2000, 1, 1); Instant ending1 = new DefaultInstant(new DefaultPosition(cal.getTime())); cal.set(2000, 1, 1); Instant begining2 = new DefaultInstant(new DefaultPosition(cal.getTime())); cal.set(2012, 1, 1); Instant ending2 = new DefaultInstant(new DefaultPosition(cal.getTime())); period1 = new DefaultPeriod(begining1, ending1); period2 = new DefaultPeriod(begining2, ending2); }
return new DefaultPeriod(begin, end);
/** Test of setEpochOfUse method, of class DefaultCalendarEra. */ @Test public void testSetEpochOfUse() { Period result = calendarEra1.getEpochOfUse(); cal.set(1900, 10, 10); ((DefaultCalendarEra) calendarEra1) .setEpochOfUse( new DefaultPeriod( new DefaultInstant(new DefaultPosition(cal.getTime())), new DefaultInstant(new DefaultPosition(new Date())))); assertFalse(calendarEra1.getEpochOfUse().equals(result)); }
/** Test of length method, of class DefaultTemporalGeometricPrimitive. */ @Test public void testLength() { cal.set(2020, 0, 1); temporalGeomericPrimitive1 = new DefaultPeriod(new DefaultInstant(position1), new DefaultInstant(position2)); temporalGeomericPrimitive2 = new DefaultPeriod( new DefaultInstant(position2), new DefaultInstant(new DefaultPosition(cal.getTime()))); Duration result = temporalGeomericPrimitive1.length(); assertFalse(temporalGeomericPrimitive2.length().equals(result)); }
public Period popPeriod() throws CQLException { Result item = null; try { item = stack.pop(); PeriodNode periodNode = (PeriodNode) item.getBuilt(); Literal begin = periodNode.getBeginning(); Literal end = periodNode.getEnding(); Position ip1 = new DefaultPosition((Date) begin.getValue()); Position ip2 = new DefaultPosition((Date) end.getValue()); Period period = new DefaultPeriod(new DefaultInstant(ip1), new DefaultInstant(ip2)); return period; } catch (ClassCastException cce) { throw new CQLException("Expecting Period", item.getToken(), cce, this.cqlSource); } catch (EmptyStackException ese) { throw new CQLException("No items on stack"); } }
/** Test of distance method, of class DefaultTemporalGeometricPrimitive. */ @Test public void testDistance() { TemporalGeometricPrimitive other; // calcul Distance with instant objects cal.set(2000, 0, 1); Position position = new DefaultPosition(cal.getTime()); other = new DefaultInstant(position); Duration result = temporalGeomericPrimitive1.distance(other); assertFalse(temporalGeomericPrimitive2.distance(other).equals(result)); // calcul Distance with instant and period cal.set(2009, 1, 1); Instant i1 = new DefaultInstant(new DefaultPosition(cal.getTime())); cal.set(2012, 1, 1); Instant i2 = new DefaultInstant(new DefaultPosition(cal.getTime())); other = new DefaultPeriod(i1, i2); result = temporalGeomericPrimitive1.distance(other); assertFalse(temporalGeomericPrimitive2.distance(other).equals(result)); // calcul Distance between Period objects temporalGeomericPrimitive1 = new DefaultPeriod(new DefaultInstant(position1), new DefaultInstant(position2)); temporalGeomericPrimitive2 = new DefaultPeriod(i1, new DefaultInstant(position2)); result = temporalGeomericPrimitive1.distance(other); assertTrue(temporalGeomericPrimitive2.distance(other).equals(result)); }
public void testCapabilities_BegunBy() throws ParseException { Capabilities capabilities = new Capabilities(); capabilities.addType(BegunBy.class); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS"); dateFormat.setTimeZone(TimeZone.getTimeZone("UTC")); Date date1 = dateFormat.parse("1970-07-19T01:02:03.456Z"); Instant temporalInstant = new DefaultInstant(new DefaultPosition(date1)); Date date2 = dateFormat.parse("1970-07-19T07:08:09.101Z"); Instant temporalInstant2 = new DefaultInstant(new DefaultPosition(date2)); Period period = new DefaultPeriod(temporalInstant, temporalInstant2); FilterFactory2 ff = CommonFactoryFinder.getFilterFactory2(null); BegunBy filter = ff.begunBy(ff.literal(period), ff.property("dateAttr")); assertTrue("supports", capabilities.supports(filter)); assertTrue("fullySupports", capabilities.fullySupports(filter)); } }
/** Test of relativePosition method, of class DefaultTemporalPrimitive. */ @Test public void testRelativePosition() { TemporalPrimitive other; // relative position between Instant objects cal.set(2000, 0, 1); Position position = new DefaultPosition(cal.getTime()); other = new DefaultInstant(position); RelativePosition result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); // relative position between Instant and Period Instant instant1 = new DefaultInstant(new DefaultPosition(cal.getTime())); Instant instant2 = (DefaultInstant) temporalPrimitive2; other = new DefaultPeriod(instant1, instant2); result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); // relative position between Period onbjects temporalPrimitive1 = new DefaultPeriod(new DefaultInstant(position1), instant1); cal.set(2200, 9, 1); temporalPrimitive2 = new DefaultPeriod(instant2, new DefaultInstant(new DefaultPosition(cal.getTime()))); result = temporalPrimitive1.relativePosition(other); assertFalse(temporalPrimitive2.relativePosition(other).equals(result)); } }
Instant ending2 = new DefaultInstant(new DefaultPosition(cal.getTime())); Period epochOfUse1 = new DefaultPeriod(begining1, ending1); Period epochOfUse2 = new DefaultPeriod(begining2, ending2);
/** Test of setBasis method, of class DefaultCalendar. */ @Test public void testSetBasis() throws ParseException { Collection<CalendarEra> result = calendar1.getBasis(); int[] calendarDate = {1, 1, 1}; CalendarEra calendarEra = new DefaultCalendarEra( new SimpleInternationalString("Babylonian calendar"), new SimpleInternationalString( "Ascension of Nebuchadnezzar II to the throne of Babylon"), new DefaultCalendarDate(calendar1, null, null, calendarDate), new DefaultJulianDate(calendar1, null, 1721423.25), new DefaultPeriod( new DefaultInstant( new DefaultPosition( new DefaultJulianDate(calendar1, null, 2087769))), new DefaultInstant( new DefaultPosition( new DefaultJulianDate(calendar1, null, 2299160))))); Collection<CalendarEra> collection = new ArrayList<CalendarEra>(); collection.add(calendarEra); ((DefaultCalendar) calendar1).setBasis(collection); assertFalse(calendar1.getBasis().equals(result)); }
public static Filter toDuringFilter( final long startTimeMillis, final long endTimeMillis, final String singleTimeField) { final FilterFactory2 factory = CommonFactoryFinder.getFilterFactory2(); final Position ip1 = new DefaultPosition(new Date(startTimeMillis)); final Position ip2 = new DefaultPosition(new Date(endTimeMillis)); final Period period = new DefaultPeriod(new DefaultInstant(ip1), new DefaultInstant(ip2)); return factory.during(factory.property(singleTimeField), factory.literal(period)); }