/** * Tests that after maximum amount of elements is reached we move them to persist list. */ @Test public void maxElementsReached() { aggregator.maxElements = 1; TimerData timerData1 = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); TimerData timerData2 = new TimerData(new Timestamp(System.currentTimeMillis()), 100L, 200L, 300L); aggregator.processTimerData(timerData1); aggregator.processTimerData(timerData2); assertThat(aggregator.getElementCount(), is(1)); verifyZeroInteractions(entityManager); }
/** * Tests that if we place many time same amount of elements, maximum will not be reached. */ @Test public void noMaxElementsReached() { aggregator.maxElements = 2; TimerData timerData1 = new TimerData(new Timestamp(System.currentTimeMillis()), 10L, 20L, 30L); TimerData timerData2 = new TimerData(new Timestamp(System.currentTimeMillis()), 100L, 200L, 300L); for (int i = 0; i < 100; i++) { aggregator.processTimerData(timerData1); aggregator.processTimerData(timerData2); } assertThat(aggregator.getElementCount(), is(2)); verifyZeroInteractions(entityManager); }