/** * Test of the buffer capacity. */ @Test public void testCapacityRestriction() { Assert.assertEquals(0, this.boundedTS.size()); Assert.assertEquals(this.bounds, this.boundedTS.getCapacity()); for (int i = 0; i < (this.bounds + 1); i++) { this.boundedTS.append(10 * i); } Assert.assertEquals(this.bounds, this.boundedTS.size()); }
/** * Test if values are collected in the correct order. */ @Test public void testValueSort() { final int count = 30; for (int i = 0; i < count; i++) { this.unboundTS.append(Double.valueOf(i)); } for (int i = 0; i < count; i++) { Assert.assertEquals(Double.valueOf(i), this.unboundTS.getPoints().get(i).getValue()); } Assert.assertEquals(count, this.unboundTS.size()); }
/** * Test if newer values are stored in FIFO order. */ @Test public void testKeepNewerValuesInCapacity() { Assert.assertEquals(0, this.boundedTS.size()); int i; final int lastNumber = this.bounds * 2; for (i = 0; i <= lastNumber; i++) { this.boundedTS.append(i); } Assert.assertEquals(Integer.valueOf(lastNumber), this.boundedTS.getPoints().get(this.bounds - 1).getValue()); }
/** * Test the append method of the time series. */ @Test public void testAppendAll() { final Double[] values = { 600.9, 400.2, 223.9 }; final List<Double> expectedValues = new ArrayList<Double>(values.length); for (final Double curVal : values) { expectedValues.add(curVal); } final TimeSeries<Double> ts = new TimeSeries<Double>(TimeSeriesTestNoState.STARTTIME, TimeUnit.MILLISECONDS, TimeSeriesTestNoState.DELTATIMEMILIS); ts.appendAll(values); final List<Double> tsValues = ts.getValues(); Assert.assertEquals("Unexpected size of time series", values.length, ts.size()); Assert.assertEquals("Unexpected size of values list", values.length, tsValues.size()); Assert.assertEquals("values not equal", expectedValues, tsValues); } }
/** * Test of the getter and appends methods. */ @Test public void testGettersAndAppendingValues() { Assert.assertEquals(this.timeUnit, this.unboundTS.getDeltaTimeUnit()); Assert.assertEquals(this.startTime, this.unboundTS.getStartTime()); Assert.assertEquals(0, this.unboundTS.size()); this.unboundTS.append(666.0); this.unboundTS.append(666.0); Assert.assertEquals(2, this.unboundTS.size()); }