real rbac-entities in booking+hosting #89

Merged
hsh-michaelhoennig merged 15 commits from real-and-rbac-entities-everywhere into master 2024-08-21 06:18:38 +02:00
Showing only changes of commit aa342d5dea - Show all commits

View File

@ -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;
}
}