### Question:
BatchMetricsImpl extends TransactionSynchronizationAdapter implements BatchMetrics { @Override public void submit(String metricName, double value) { if (TransactionSynchronizationManager.isSynchronizationActive()) { initializeMetricContainerAndRegisterTransactionSynchronizationIfNecessary(); metricContainer.get().metrics.add(Pair.of(metricName, value)); } else { set(metricName, value); } } BatchMetricsImpl(); @Override void increment(String metricName); @Override void increment(String metricName, Long value); @Override void decrement(String metricName); @Override void decrement(String metricName, Long value); @Override void reset(String metricName); @Override void submit(String metricName, double value); @Override void incrementNonTransactional(String metricName); @Override void incrementNonTransactional(String metricName, Long value); @Override void decrementNonTransactional(String metricName); @Override void decrementNonTransactional(String metricName, Long value); @Override void resetNonTransactional(String metricName); @Override void submitNonTransactional(String metricName, double value); @Override void afterCompletion(int status);  }### Answer:
@Test public void submitTransactional() throws Exception { TransactionSynchronizationManager.initSynchronization(); batchMetrics.submit("counter.test", 1L); TransactionSynchronizationUtils.triggerAfterCompletion(TransactionSynchronization.STATUS_COMMITTED); TransactionSynchronizationManager.clearSynchronization(); }