### Question:
SystemNotificationsImpl extends AbstractHtmlRequestInjector implements SystemNotifications, ResourceChangeListener, ExternalResourceChangeListener { @Deactivate protected void deactivate(ComponentContext ctx) { super.deactivate(ctx); if (eventHandlerRegistration != null) { eventHandlerRegistration.unregister(); eventHandlerRegistration = null; } this.osgiComponentContext = null; }  @Override List<Resource> getNotifications(final SlingHttpServletRequest request,
                                           final Resource notificationsFolder); @Override @SuppressWarnings("squid:S2070") // SHA1 not used cryptographically String getNotificationId(final Page notificationPage); @Override String getMessage(String message, String onTime, String offTime); @Override void onChange(final List<ResourceChange> changes); static final String COOKIE_NAME; }### Answer:
@Test public void testOnAuthorEmptyNotificationsFolder() throws Exception { setAuthorRunmode(); aemContext.build() .resource("/etc/acs-commons/notifications", JCR_PRIMARYTYPE, NT_PAGE) .resource("jcr:content", JCR_PRIMARYTYPE, NT_UNSTRUCTURED); commit(); aemContext.registerInjectActivateService(notifications); assertEquals(1, aemContext.getServices(ResourceChangeListener.class, null).length); assertEquals(0, aemContext.getServices(Filter.class, null).length); aemContext.create().resource("/etc/acs-commons/notifications/first", JCR_PRIMARYTYPE, NT_PAGE); commit(); sendEvent(); assertEquals(1, aemContext.getServices(Filter.class, null).length); notifications.deactivate(aemContext.componentContext()); assertEquals(0, aemContext.getServices(Filter.class, null).length); assertEquals(0, aemContext.getServices(ResourceChangeListener.class, null).length); }
@Test public void testOnAuthorPopulatedNotificationsFolder() throws Exception { setAuthorRunmode(); createEnabledNotification(); aemContext.registerInjectActivateService(notifications); assertEquals(1, aemContext.getServices(ResourceChangeListener.class, null).length); assertEquals(1, aemContext.getServices(Filter.class, null).length); delete("/etc/acs-commons/notifications/enabled"); commit(); sendEvent(); assertEquals(0, aemContext.getServices(Filter.class, null).length); notifications.deactivate(aemContext.componentContext()); assertEquals(0, aemContext.getServices(Filter.class, null).length); assertEquals(0, aemContext.getServices(ResourceChangeListener.class, null).length); }
@Test public void testOnAuthorPopulatedNotificationsSubFolder() throws Exception { setAuthorRunmode(); aemContext.build() .resource("/etc/acs-commons/notifications", JCR_PRIMARYTYPE, NT_PAGE) .resource("jcr:content", JCR_PRIMARYTYPE, NT_UNSTRUCTURED); createEnabledNotification("/etc/acs-commons/notifications/subfolder/enabled"); aemContext.registerInjectActivateService(notifications); assertEquals(1, aemContext.getServices(ResourceChangeListener.class, null).length); assertEquals(1, aemContext.getServices(Filter.class, null).length); delete("/etc/acs-commons/notifications/subfolder/enabled"); commit(); sendEvent(); assertEquals(0, aemContext.getServices(Filter.class, null).length); notifications.deactivate(aemContext.componentContext()); assertEquals(0, aemContext.getServices(Filter.class, null).length); assertEquals(0, aemContext.getServices(ResourceChangeListener.class, null).length); }