### Question:
CRUDNotifier implements BroadcastReceiver { @Override public void onReceive(Event event) { final String action = event.getAction(); if (!ArrayUtils.contains(ACTIONS, action)) { return; } final String itemId = event.getIdentifier().toString(); final Resource resource = event.getData(); if (NOTIFY_ACTIONS.containsKey(action)) { if (resource == null) { logger.debug("Impossible to find type of resource (no metadata provided in the event), no notification will be sent [item="+itemId+", action="+action+"]"); } else { final Type itemType = Type.get(resource); final ProfileAttributeType itemTypeProfileAttribute = ProfileAttributeType.get(resource); if (itemType == null && itemTypeProfileAttribute == null) { logger.debug("Type is undefined, no notification will be sent [item="+resource+", action="+action+"]"); return; } final String type = (itemTypeProfileAttribute == null) ? itemType.toString() : "profileattribute"; String creatorId = null; Node creator = ModelUtils.findObject(resource.getModel(), resource, NAO.creator); if (creator != null) { creatorId = creator.toString(); } final Long tenant = Long.parseLong(event.getTenant()); final String operation = NOTIFY_ACTIONS.get(action); if(operation.equals(DimeInternalNotification.OP_CREATE) || operation.equals(DimeInternalNotification.OP_REMOVE )) try { Node rdfType = ModelUtils.findObject(resource.getModel(), resource, RDF.type); if (rdfType != null && !rdfType.asURI().equals(PPO.PrivacyPreference)) logEventManager.setLog(operation, type,Tenant.find(tenant)); else if(type.equals("profilecard")) logEventManager.setLog(operation, type,Tenant.find(tenant)); } catch (EventLoggerException e) { logger.error("A sharing process could not be logged",e); } final SystemNotification notification = new SystemNotification(tenant, operation, itemId, type, creatorId); try { logger.debug("Pushing internal notification: "+notification.toString()); notifierManager.pushInternalNotification(notification); } catch (NotifierException e) { logger.error("Error while pushing notification ["+notification+"].", e); } } } } CRUDNotifier(); @Autowired void setLogEventManager(LogEventManager logEventManager); void setNotifierManager(NotifierManager notifierManager); @Override void onReceive(Event event);  }### Answer:
@Test public void testCreatePersonGroup() { PersonGroup group = modelFactory.getPIMOFactory().createPersonGroup(); group.setCreator(new URIImpl("urn:test")); Event event = new Event(connection.getName(), Event.ACTION_RESOURCE_ADD, group); notifier.onReceive(event); assertEquals(1, notifierManager.internal.size()); DimeInternalNotification notification = notifierManager.internal.get(0); assertEquals(group.asURI().toString(), notification.getItemID()); assertEquals(DimeInternalNotification.OP_CREATE, notification.getOperation()); assertEquals(Type.get(group).getLabel(), notification.getItemType()); }
@Test public void testUpdatePersonGroup() { PersonGroup group = modelFactory.getPIMOFactory().createPersonGroup(); group.setCreator(new URIImpl("urn:test")); Event event = new Event(connection.getName(), Event.ACTION_RESOURCE_MODIFY, group); notifier.onReceive(event); assertEquals(1, notifierManager.internal.size()); DimeInternalNotification notification = notifierManager.internal.get(0); assertEquals(group.asURI().toString(), notification.getItemID()); assertEquals(DimeInternalNotification.OP_UPDATE, notification.getOperation()); assertEquals(Type.get(group).getLabel(), notification.getItemType()); }
@Test public void testRemovePersonGroup() { PersonGroup group = modelFactory.getPIMOFactory().createPersonGroup(); group.setCreator(new URIImpl("urn:test")); Event event = new Event(connection.getName(), Event.ACTION_RESOURCE_DELETE, group); notifier.onReceive(event); assertEquals(1, notifierManager.internal.size()); DimeInternalNotification notification = notifierManager.internal.get(0); assertEquals(group.toString(), notification.getItemID()); assertEquals(DimeInternalNotification.OP_REMOVE, notification.getOperation()); assertEquals(Type.get(group).getLabel(), notification.getItemType()); }