/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Second s = new Second(50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-623289610000L, s.getFirstMillisecond(zone)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Second s = new Second(55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); assertEquals(955762855000L, s.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Second s = new Second(55, 1, 2, 7, 7, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); assertEquals(-614962684001L, s.getLastMillisecond(zone)); // try null calendar boolean pass = false; try { s.getLastMillisecond((TimeZone) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Second s = new Second(50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); assertEquals(987885950999L, s.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
private IntervalXYDataset createDatasetNumberRequestsUntampered() { Date currentDate; long currentMsTs; final TimeSeries series = new TimeSeries( "Sent Untampered Requests per Second" ); if ( model.getMapLogEntryIntervalUntampered() != null ) { for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalUntampered().entrySet() ) { // Create TS from model.startTime and log.getIntervalNumber(); currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber(); currentDate = new Date( currentMsTs ); series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) ); } } final TimeSeriesCollection dataset = new TimeSeriesCollection( series ); dataset.setXPosition( TimePeriodAnchor.MIDDLE ); return dataset; }
private IntervalXYDataset createDatasetNumberRequestsTampered() { Date currentDate; long currentMsTs; final TimeSeries series = new TimeSeries( "Sent Tampered Requests per Second" ); if ( model.getMapLogEntryIntervalTampered() != null ) { for ( Map.Entry<Integer, LogEntryInterval> log : model.getMapLogEntryIntervalTampered().entrySet() ) { // Create TS from model.startTime and log.getIntervalNumber(); currentMsTs = model.getTsAttackStart() + log.getValue().getIntervalNumber(); currentDate = new Date( currentMsTs ); series.add( new Second( currentDate ), ( log.getValue().getNumberRequests() ) ); } } final TimeSeriesCollection dataset = new TimeSeriesCollection( series ); dataset.setXPosition( TimePeriodAnchor.MIDDLE ); return dataset; }
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithTimeZone() { Second s = new Second(50, 59, 15, 1, 4, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-623289610000L, s.getFirstMillisecond(c)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getFirstMillisecond(TimeZone) method. */ public void testGetFirstMillisecondWithCalendar() { Second s = new Second(55, 40, 2, 15, 4, 2000); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(955766455000L, s.getFirstMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getFirstMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithTimeZone() { Second s = new Second(55, 1, 2, 7, 7, 1950); TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); Calendar c = new GregorianCalendar(zone); assertEquals(-614962684001L, s.getLastMillisecond(c)); // try null calendar boolean pass = false; try { s.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
/** * Some checks for the getLastMillisecond(TimeZone) method. */ public void testGetLastMillisecondWithCalendar() { Second s = new Second(50, 45, 21, 21, 4, 2001); GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); assertEquals(987889550999L, s.getLastMillisecond(calendar)); // try null calendar boolean pass = false; try { s.getLastMillisecond((Calendar) null); } catch (NullPointerException e) { pass = true; } assertTrue(pass); }
private XYDataset createDataset(TimeSeries timeseries[], TimeSeries timeSeriesSensibilidad[]){ TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.setDomainIsPointsInTime(true); for(int i = 0; i < timeseries.length;i++){ timeseries[i] = new TimeSeries("Path" + (i+1), Second.class); //path1.add(new Second(0, 0, 0, 7, 12, 2011), 0.0); dataset.addSeries(timeseries[i]); } for(int i = 0; i < timeSeriesSensibilidad.length;i++){ timeSeriesSensibilidad[i] = new TimeSeries("Sensibilidad Rx", Second.class); //path1.add(new Second(0, 0, 0, 7, 12, 2011), 0.0); dataset.addSeries(timeSeriesSensibilidad[i]); } /* fecha = new Date(); timeSeriesSensibilidad.addOrUpdate(new Second(fecha.getSeconds(), fecha.getMinutes(), fecha.getHours(), fecha.getDate(), fecha.getMonth()+1, 2012), -80); */ return dataset; }
private XYDataset createTimeDataset(ChartValue[] values) { TimeSeries series = null; TimeSeriesCollection seriesCollection = new TimeSeriesCollection(); for (int i = 0; i < values.length; i++) { TimeChartValue value = (TimeChartValue) values[i]; if (series == null || !series.getKey().equals(value.getSeries())) { if (series != null) { seriesCollection.addSeries(series); } series = new TimeSeries(value.getSeries(), Second.class); } series.add(new Second(value.getTime()), value.getValue()); } seriesCollection.addSeries(series); return seriesCollection; }
/** * Builds an additional JFreeChart dataset from a ta4j time series. * @param series a time series * @return an additional dataset */ private static TimeSeriesCollection createAdditionalDataset(TimeSeries series) { ClosePriceIndicator indicator = new ClosePriceIndicator(series); TimeSeriesCollection dataset = new TimeSeriesCollection(); org.jfree.data.time.TimeSeries chartTimeSeries = new org.jfree.data.time.TimeSeries("Btc price"); for (int i = 0; i < series.getTickCount(); i++) { Tick tick = series.getTick(i); chartTimeSeries.add(new Second(new Date(tick.getEndTime().toEpochSecond() * 1000)), indicator.getValue(i).toDouble()); } dataset.addSeries(chartTimeSeries); return dataset; }
/** * Tests the equals method. */ public void testEquals() { final Day day1 = new Day(29, SerialDate.MARCH, 2002); final Hour hour1 = new Hour(15, day1); final Minute minute1 = new Minute(15, hour1); final Second second1 = new Second(34, minute1); final Millisecond milli1 = new Millisecond(999, second1); final Day day2 = new Day(29, SerialDate.MARCH, 2002); final Hour hour2 = new Hour(15, day2); final Minute minute2 = new Minute(15, hour2); final Second second2 = new Second(34, minute2); final Millisecond milli2 = new Millisecond(999, second2); assertTrue(milli1.equals(milli2)); }
/** * Tests the equals method. */ public void testEquals() { final Day day1 = new Day(29, SerialDate.MARCH, 2002); final Hour hour1 = new Hour(15, day1); final Minute minute1 = new Minute(15, hour1); final Second second1 = new Second(34, minute1); final Day day2 = new Day(29, SerialDate.MARCH, 2002); final Hour hour2 = new Hour(15, day2); final Minute minute2 = new Minute(15, hour2); final Second second2 = new Second(34, minute2); assertTrue(second1.equals(second2)); }
/** * In GMT, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016729759000L). * Use this to check the Second constructor. */ public void testDateConstructor1() { final TimeZone zone = TimeZone.getTimeZone("GMT"); final Second s1 = new Second(new Date(1016729758999L), zone); final Second s2 = new Second(new Date(1016729759000L), zone); assertEquals(58, s1.getSecond()); assertEquals(1016729758999L, s1.getLastMillisecond(zone)); assertEquals(59, s2.getSecond()); assertEquals(1016729759000L, s2.getFirstMillisecond(zone)); }
/** * In Chicago, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016751359000L). * Use this to check the Second constructor. */ public void testDateConstructor2() { final TimeZone zone = TimeZone.getTimeZone("America/Chicago"); final Second s1 = new Second(new Date(1016751358999L), zone); final Second s2 = new Second(new Date(1016751359000L), zone); assertEquals(58, s1.getSecond()); assertEquals(1016751358999L, s1.getLastMillisecond(zone)); assertEquals(59, s2.getSecond()); assertEquals(1016751359000L, s2.getFirstMillisecond(zone)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { final Second s1 = new Second(13, 45, 5, 1, 2, 2003); final Second s2 = new Second(13, 45, 5, 1, 2, 2003); assertTrue(s1.equals(s2)); final int h1 = s1.hashCode(); final int h2 = s2.hashCode(); assertEquals(h1, h2); }
/** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Second second1 = new Second(34, minute1); Millisecond milli1 = new Millisecond(999, second1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); Second second2 = new Second(34, minute2); Millisecond milli2 = new Millisecond(999, second2); assertTrue(milli1.equals(milli2)); }
/** * Tests the equals method. */ public void testEquals() { Day day1 = new Day(29, MonthConstants.MARCH, 2002); Hour hour1 = new Hour(15, day1); Minute minute1 = new Minute(15, hour1); Second second1 = new Second(34, minute1); Day day2 = new Day(29, MonthConstants.MARCH, 2002); Hour hour2 = new Hour(15, day2); Minute minute2 = new Minute(15, hour2); Second second2 = new Second(34, minute2); assertTrue(second1.equals(second2)); }
/** * In GMT, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016729759000L). * Use this to check the Second constructor. */ public void testDateConstructor1() { TimeZone zone = TimeZone.getTimeZone("GMT"); Second s1 = new Second(new Date(1016729758999L), zone); Second s2 = new Second(new Date(1016729759000L), zone); assertEquals(58, s1.getSecond()); assertEquals(1016729758999L, s1.getLastMillisecond(zone)); assertEquals(59, s2.getSecond()); assertEquals(1016729759000L, s2.getFirstMillisecond(zone)); }
/** * In Chicago, the 4.55:59pm on 21 Mar 2002 is * java.util.Date(1016751359000L). Use this to check the Second constructor. */ public void testDateConstructor2() { TimeZone zone = TimeZone.getTimeZone("America/Chicago"); Second s1 = new Second(new Date(1016751358999L), zone); Second s2 = new Second(new Date(1016751359000L), zone); assertEquals(58, s1.getSecond()); assertEquals(1016751358999L, s1.getLastMillisecond(zone)); assertEquals(59, s2.getSecond()); assertEquals(1016751359000L, s2.getFirstMillisecond(zone)); }
/** * Two objects that are equal are required to return the same hashCode. */ public void testHashcode() { Second s1 = new Second(13, 45, 5, 1, 2, 2003); Second s2 = new Second(13, 45, 5, 1, 2, 2003); assertTrue(s1.equals(s2)); int h1 = s1.hashCode(); int h2 = s2.hashCode(); assertEquals(h1, h2); }
/** * Some checks for the getFirstMillisecond() method. */ public void testGetFirstMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); Second s = new Second(15, 43, 15, 1, 4, 2006); assertEquals(1143902595000L, s.getFirstMillisecond()); Locale.setDefault(saved); }
/** * Some checks for the getLastMillisecond() method. */ public void testGetLastMillisecond() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.UK); Second s = new Second(1, 1, 1, 1, 1, 1970); assertEquals(61999L, s.getLastMillisecond()); Locale.setDefault(saved); }
/** * Some checks for the getStart() method. */ public void testGetStart() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 0); Second s = new Second(55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), s.getStart()); Locale.setDefault(saved); }
/** * Some checks for the getEnd() method. */ public void testGetEnd() { Locale saved = Locale.getDefault(); Locale.setDefault(Locale.ITALY); Calendar cal = Calendar.getInstance(Locale.ITALY); cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); cal.set(Calendar.MILLISECOND, 999); Second s = new Second(55, 47, 3, 16, 1, 2006); assertEquals(cal.getTime(), s.getEnd()); Locale.setDefault(saved); }