@Test public void saveAllInPersistList() { 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); aggregator.saveAllInPersistList(); ArgumentCaptor<DatabaseAggregatedTimerData> argument = ArgumentCaptor.forClass(DatabaseAggregatedTimerData.class); verify(entityManager, times(1)).persist(argument.capture()); assertThat(argument.getValue(), is(instanceOf(DatabaseAggregatedTimerData.class))); assertThat(argument.getValue().getPlatformIdent(), is(timerData1.getPlatformIdent())); assertThat(argument.getValue().getSensorTypeIdent(), is(timerData1.getSensorTypeIdent())); assertThat(argument.getValue().getMethodIdent(), is(timerData1.getMethodIdent())); }
void saveAllInPersistList() { if (!persistList.isEmpty()) { tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { TimerData last = persistList.poll(); while (last != null) { TimerDataAggregator.super.create(last); last = persistList.poll(); } } }); } }
TimerDataAggregator extends AbstractJpaDao<TimerData> { void saveAllInPersistList() { if (!persistList.isEmpty()) { tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { TimerData last = persistList.poll(); while (last != null) { TimerDataAggregator.super.create(last); last = persistList.poll(); } } }); } } }
TimerDataAggregator extends AbstractJpaDao<TimerData> { void saveAllInPersistList() { if (!persistList.isEmpty()) { tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { TimerData last = persistList.poll(); while (last != null) { TimerDataAggregator.super.create(last); last = persistList.poll(); } } }); } } @Autowired  TimerDataAggregator(PlatformTransactionManager transactionManager); }
TimerDataAggregator extends AbstractJpaDao<TimerData> { void saveAllInPersistList() { if (!persistList.isEmpty()) { tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { TimerData last = persistList.poll(); while (last != null) { TimerDataAggregator.super.create(last); last = persistList.poll(); } } }); } } @Autowired  TimerDataAggregator(PlatformTransactionManager transactionManager); void processTimerData(TimerData timerData); void removeAndPersistAll(); @PostConstruct void postConstruct(); long getAggregationPeriod(); int getMaxElements(); long getCacheCleanSleepingPeriod(); int getElementCount(); }
TimerDataAggregator extends AbstractJpaDao<TimerData> { void saveAllInPersistList() { if (!persistList.isEmpty()) { tt.execute(new TransactionCallbackWithoutResult() { @Override protected void doInTransactionWithoutResult(TransactionStatus status) { TimerData last = persistList.poll(); while (last != null) { TimerDataAggregator.super.create(last); last = persistList.poll(); } } }); } } @Autowired  TimerDataAggregator(PlatformTransactionManager transactionManager); void processTimerData(TimerData timerData); void removeAndPersistAll(); @PostConstruct void postConstruct(); long getAggregationPeriod(); int getMaxElements(); long getCacheCleanSleepingPeriod(); int getElementCount();  }