Skip to content

Commit

Permalink
Fix unstubbed Exception for spring-test-6.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rwinch committed Nov 15, 2024
1 parent 14c344d commit ff1bd60
Showing 1 changed file with 0 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,8 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.BDDMockito.given;
import static org.mockito.BDDMockito.willAnswer;
import static org.mockito.Mockito.spy;

/**
Expand Down Expand Up @@ -68,10 +66,6 @@ void findByIdWhenSessionDeletedWhileSavingDeltaThenThrowIllegalStateException()

BoundHashOperations<String, Object, Object> opsForHash = spy(this.spyOperations.boundHashOps(anyString()));
given(this.spyOperations.boundHashOps(anyString())).willReturn(opsForHash);
willAnswer((invocation) -> {
this.sessionRepository.deleteById(session.getId());
return invocation.callRealMethod();
}).given(opsForHash).putAll(any());

this.sessionRepository.save(session);
assertThatIllegalStateException().isThrownBy(() -> this.sessionRepository.findById(session.getId()))
Expand All @@ -87,10 +81,6 @@ void findByIdWhenSessionDeletedWhileSavingDeltaAndSafeMapperThenSessionIsNull()

BoundHashOperations<String, Object, Object> opsForHash = spy(this.spyOperations.boundHashOps(anyString()));
given(this.spyOperations.boundHashOps(anyString())).willReturn(opsForHash);
willAnswer((invocation) -> {
this.sessionRepository.deleteById(session.getId());
return invocation.callRealMethod();
}).given(opsForHash).putAll(any());

this.sessionRepository.save(session);
assertThat(this.sessionRepository.findById(session.getId())).isNull();
Expand Down

0 comments on commit ff1bd60

Please sign in to comment.