when(session.getWorkspace()).thenReturn(workspace);
SlingRepository repository = mock(SlingRepository.class);
when(repository.loginAdministrative(null)).thenReturn(session);
EventAdmin eventAdmin = mock(EventAdmin.class);
ServiceReference serviceRef = mock(ServiceReference.class);
ServiceReference[] serviceRefs = new ServiceReference[]{serviceRef};
BundleContext bundleContext = mock(BundleContext.class);
when(bundleContext.getServiceReferences(anyString(), anyString())).thenReturn(serviceRefs);
when(bundleContext.getService(serviceRef)).thenReturn(eventAdmin);