StandardTransactionContexts implements TransactionContexts { @Override public void close() throws Exception { for (ShardingTransactionManagerEngine each : engines.values()) { each.close(); } } StandardTransactionContexts(); @Override ShardingTransactionManagerEngine getDefaultTransactionManagerEngine(); @Override void close();  }
@Test public void assertClose() throws Exception { ShardingTransactionManagerEngine shardingTransactionManagerEngine = mock(ShardingTransactionManagerEngine.class); Map<String, ShardingTransactionManagerEngine> actualEngine = new HashMap<>(); actualEngine.put(DefaultSchema.LOGIC_NAME, shardingTransactionManagerEngine); StandardTransactionContexts standardTransactionContexts = new StandardTransactionContexts(actualEngine); standardTransactionContexts.close(); verify(shardingTransactionManagerEngine).close(); }
@Test(expected = Exception.class) public void assertCloseThrowsException() throws Exception { ShardingTransactionManagerEngine shardingTransactionManagerEngine = mock(ShardingTransactionManagerEngine.class); doThrow(new RuntimeException("")).when(shardingTransactionManagerEngine).close(); Map<String, ShardingTransactionManagerEngine> actualEngine = new HashMap<>(); actualEngine.put(DefaultSchema.LOGIC_NAME, shardingTransactionManagerEngine); StandardTransactionContexts standardTransactionContexts = new StandardTransactionContexts(actualEngine); standardTransactionContexts.close(); }