org.hibernate.Session mockHibernateSession = mock(org.hibernate.Session.class);
when(mockEntityManager.getDelegate()).thenReturn(mockHibernateSession);
SessionFactory mockSessionFactory = mock(SessionFactory.class);
when(mockHibernateSession.getSessionFactory()).thenReturn(mockSessionFactory);
StatelessSession mockStatelessSession = mock(StatelessSession.class);
when(mockSessionFactory.openStatelessSession()).thenReturn(mockStatelessSession);
org.hibernate.SQLQuery mockQuery = mock(org.hibernate.SQLQuery.class);
when(mockStatelessSession.createSQLQuery(any(String.class))).thenReturn(mockQuery);
when(mockQuery.uniqueResult()).thenReturn("1000");