@Test
  public void removeAllWithoutTransaction() throws Exception {
    // given
    doReturn(sessionService).when(modelService).lookupSessionService();
    doReturn(interceptorRegistry).when(modelService).lookupInterceptorRegistry();
    doReturn(converterRegistry).when(modelService).lookupConverterRegistry();
    given(converterRegistry.getModelConverterByModelType((Class) anyObject()))
        .willReturn(modelConverter);
    given(modelConverter.getType(model1)).willReturn("ItemModel");
    given(sessionService.getAttribute(DefaultModelService.ENABLE_TRANSACTIONAL_SAVES))
        .willReturn(Boolean.FALSE);

    // when (execute 2 remove* methods)
    modelService.remove(model1);
    modelService.removeAll(Arrays.asList(model1, model2));

    // then (should be 0 interactions with transaction mock)
    verify(transaction, times(0)).execute((TransactionCallback) anyObject());
  }
  @Test
  public void shouldExecuteSaveVaragsObjectsWithoutTransactionWhenGlobalTransactionFlagIsFalse()
      throws Exception {
    // given
    modelService.setTransactional(false);
    doReturn(sessionService).when(modelService).lookupSessionService();
    doReturn(interceptorRegistry).when(modelService).lookupInterceptorRegistry();
    doReturn(converterRegistry).when(modelService).lookupConverterRegistry();
    given(converterRegistry.getModelConverterByModelType((Class) anyObject()))
        .willReturn(modelConverter);
    given(modelConverter.getType(model1)).willReturn("ItemModel");

    // when (execute all 4 save* methods)
    modelService.save(model1);
    modelService.saveAll(model1, model2);
    modelService.saveAll(Collections.singletonList(model1));
    modelService.saveAll();

    // then (should be 0 interactions with transaction mock)
    verify(transaction, times(0)).execute((TransactionCallback) anyObject());
  }
  @Test
  public void
      shouldExecuteSaveVaragsObjectsWithoutTransactionWhenGlobalTransactionFlagIsTrueButLocallyTransactionsAreDisabled()
          throws Exception {
    // given
    modelService.setTransactional(true);
    doReturn(sessionService).when(modelService).lookupSessionService();
    doReturn(interceptorRegistry).when(modelService).lookupInterceptorRegistry();
    doReturn(converterRegistry).when(modelService).lookupConverterRegistry();
    given(converterRegistry.getModelConverterByModelType((Class) anyObject()))
        .willReturn(modelConverter);
    given(modelConverter.getType(model1)).willReturn("ItemModel");
    given(sessionService.getAttribute(DefaultModelService.ENABLE_TRANSACTIONAL_SAVES))
        .willReturn(Boolean.FALSE);

    // when (execute all 4 save* methods)
    modelService.save(model1);
    modelService.saveAll(model1, model2);
    modelService.saveAll(Collections.singletonList(model1));
    modelService.saveAll();

    // then (should be 0 interactions with transaction mock)
    verify(transaction, times(0)).execute((TransactionCallback) anyObject());
  }