I am using CurrentTenantIdentifierResolver and MultiTenantConnectionProvider, everything works as expected in my test cases and same code that is used in api( controller or service), my tenant is always set to previous. tenant is going to change.
void saveAndLoadPerson() {
currentTenant.setCurrentTenant(main);
assertThat(collectionRepository.findAllByIdIn(List.of(400010521L))).extracting(Collection::getRecordStatus).containsExactly(RecordStatus.APPROVED);
currentTenant.setCurrentTenant(edit);
assertThat(collectionRepository.findAllByIdIn(List.of(400010521L))).extracting(Collection::getRecordStatus).containsExactly(RecordStatus.UNDER_EDIT);
}