real rbac-entities in booking+hosting #89
@ -9,8 +9,8 @@ import java.util.stream.Stream;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.lenient;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class EntityManagerMock {
|
||||
public static @NotNull EntityManager createEntityManagerMockWithAssetQueryFake(final HsHostingAssetRealEntity asset) {
|
||||
@ -18,10 +18,10 @@ public class EntityManagerMock {
|
||||
final var assetQuery = mock(TypedQuery.class);
|
||||
final var assetStream = mock(Stream.class);
|
||||
|
||||
when(em.createQuery(any(), any(Class.class))).thenReturn(assetQuery);
|
||||
when(assetQuery.getResultStream()).thenReturn(assetStream);
|
||||
when(assetQuery.setParameter(anyString(), any())).thenReturn(assetQuery);
|
||||
when(assetStream.findFirst()).thenReturn(Optional.ofNullable(asset));
|
||||
lenient().when(em.createQuery(any(), any(Class.class))).thenReturn(assetQuery);
|
||||
lenient().when(assetQuery.getResultStream()).thenReturn(assetStream);
|
||||
lenient().when(assetQuery.setParameter(anyString(), any())).thenReturn(assetQuery);
|
||||
lenient().when(assetStream.findFirst()).thenReturn(Optional.ofNullable(asset));
|
||||
return em;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user