### Question:
TimeSeries implements Serializable { public void addTick(Tick tick) { if (tick == null) { throw new IllegalArgumentException("Cannot add null tick"); } final int lastTickIndex = ticks.size() - 1; if (!ticks.isEmpty()) { DateTime seriesEndTime = ticks.get(lastTickIndex).getEndTime(); if (!tick.getEndTime().isAfter(seriesEndTime)) { throw new IllegalArgumentException("Cannot add a tick with end time <= to series end time"); } } ticks.add(tick); if (beginIndex == -1) { beginIndex = 0; } endIndex++; removeExceedingTicks(); } TimeSeries(String name, List<Tick> ticks);  TimeSeries(List<Tick> ticks);  TimeSeries(String name);  TimeSeries(); private  TimeSeries(String name, List<Tick> ticks, int beginIndex, int endIndex, boolean subSeries); String getName(); Tick getTick(int i); Tick getFirstTick(); Tick getLastTick(); int getTickCount(); int getBegin(); int getEnd(); String getSeriesPeriodDescription(); void setMaximumTickCount(int maximumTickCount); int getMaximumTickCount(); int getRemovedTicksCount(); void addTick(Tick tick); TimeSeries subseries(int beginIndex, int endIndex); TimeSeries subseries(int beginIndex, Period duration); List<TimeSeries> split(int nbTicks); List<TimeSeries> split(Period splitDuration, Period sliceDuration); List<TimeSeries> split(Period duration); TradingRecord run(Strategy strategy); TradingRecord run(Strategy strategy, OrderType orderType); TradingRecord run(Strategy strategy, OrderType orderType, Decimal amount);  }### Answer:
@Test(expected = IllegalArgumentException.class) public void addNullTickShouldThrowException() { defaultSeries.addTick(null); }
@Test(expected = IllegalArgumentException.class) public void addTickWithEndTimePriorToSeriesEndTimeShouldThrowException() { defaultSeries.addTick(new MockTick(date.withDate(2000, 1, 1), 99d)); }
@Test public void addTick() { defaultSeries = new TimeSeries(); Tick firstTick = new MockTick(date.withDate(2014, 6, 13), 1d); Tick secondTick = new MockTick(date.withDate(2014, 6, 14), 2d); assertEquals(0, defaultSeries.getTickCount()); assertEquals(-1, defaultSeries.getBegin()); assertEquals(-1, defaultSeries.getEnd()); defaultSeries.addTick(firstTick); assertEquals(1, defaultSeries.getTickCount()); assertEquals(0, defaultSeries.getBegin()); assertEquals(0, defaultSeries.getEnd()); defaultSeries.addTick(secondTick); assertEquals(2, defaultSeries.getTickCount()); assertEquals(0, defaultSeries.getBegin()); assertEquals(1, defaultSeries.getEnd()); }