@Override
  public DbSession openSession(boolean batch) {
    if (!CACHING_ENABLED.get()) {
      return myBatis.openSession(batch);
    }
    if (batch) {
      return new NonClosingDbSession(batchDbSession.get().get());
    }
    return new NonClosingDbSession(regularDbSession.get().get());
  }
@Test
  void openSession_without_caching_always_returns_a_new_batch_session_when_parameter_is_true() {
    DbSession[] expected = {mock(DbSession.class), mock(DbSession.class), mock(DbSession.class), mock(DbSession.class)};
    when(myBatis.openSession(true))
      .thenReturn(expected[0])
      .thenReturn(expected[1])
      .thenReturn(expected[2])
      .thenReturn(expected[3])
      .thenThrow(oneCallTooMuch());

    assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).toList())
      .containsExactly(expected);
  }