fix missing lenient

This commit is contained in:
Michael Hoennig 2024-08-19 10:30:18 +02:00
parent 1da3064700
commit aa342d5dea

View File

@ -9,8 +9,8 @@ import java.util.stream.Stream;
import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
public class EntityManagerMock { public class EntityManagerMock {
public static @NotNull EntityManager createEntityManagerMockWithAssetQueryFake(final HsHostingAssetRealEntity asset) { public static @NotNull EntityManager createEntityManagerMockWithAssetQueryFake(final HsHostingAssetRealEntity asset) {
@ -18,10 +18,10 @@ public class EntityManagerMock {
final var assetQuery = mock(TypedQuery.class); final var assetQuery = mock(TypedQuery.class);
final var assetStream = mock(Stream.class); final var assetStream = mock(Stream.class);
when(em.createQuery(any(), any(Class.class))).thenReturn(assetQuery); lenient().when(em.createQuery(any(), any(Class.class))).thenReturn(assetQuery);
when(assetQuery.getResultStream()).thenReturn(assetStream); lenient().when(assetQuery.getResultStream()).thenReturn(assetStream);
when(assetQuery.setParameter(anyString(), any())).thenReturn(assetQuery); lenient().when(assetQuery.setParameter(anyString(), any())).thenReturn(assetQuery);
when(assetStream.findFirst()).thenReturn(Optional.ofNullable(asset)); lenient().when(assetStream.findFirst()).thenReturn(Optional.ofNullable(asset));
return em; return em;
} }
} }