@Test public void testExecuteEmpty() { context.checking(new Expectations() { { oneOf(alertMapper).execute(USER_ID); will(returnValue(Collections.EMPTY_LIST)); } }); PrincipalActionContext ctx = TestContextCreator.createPrincipalActionContext(null, "whomever", USER_ID); Collection<InAppNotificationDTO> result = (Collection<InAppNotificationDTO>) sut.execute(ctx); context.assertIsSatisfied(); assertTrue(result.isEmpty()); }
@Override @SuppressWarnings("unchecked") public Serializable execute(final PrincipalActionContext inActionContext) { long userId = inActionContext.getPrincipal().getId(); List<InAppNotificationDTO> results = alertMapper.execute(userId); if (results.isEmpty()) { return (Serializable) Collections.EMPTY_LIST; } for (InAppNotificationDTO item : results) { item.setFilterCategory(notificationTypeToCategory.get(item.getNotificationType())); } Map<String, PersonModelView> personLookup = new HashMap<String, PersonModelView>(); Map<String, DomainGroupModelView> groupLookup = new HashMap<String, DomainGroupModelView>(); for (InAppNotificationDTO notif : results) { switch (notif.getAvatarOwnerType()) { case PERSON: personLookup.put(notif.getAvatarOwnerUniqueId(), null); break; case GROUP: groupLookup.put(notif.getAvatarOwnerUniqueId(), null); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } } for (PersonModelView person : personsMapper.execute(new ArrayList(personLookup.keySet()))) { personLookup.put(person.getAccountId(), person); } for (DomainGroupModelView group : groupsMapper.execute(new ArrayList(groupLookup.keySet()))) { groupLookup.put(group.getUniqueId(), group); } for (InAppNotificationDTO notif : results) { AvatarEntity entity = null; switch (notif.getAvatarOwnerType()) { case PERSON: entity = personLookup.get(notif.getAvatarOwnerUniqueId()); break; case GROUP: entity = groupLookup.get(notif.getAvatarOwnerUniqueId()); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } if (entity != null && entity.getAvatarId() != null) { notif.setAvatarId(entity.getAvatarId()); } } log.trace("Found {} notifications for user {}", results.size(), userId); return new ArrayList(results); }
GetInAppNotificationsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override @SuppressWarnings("unchecked") public Serializable execute(final PrincipalActionContext inActionContext) { long userId = inActionContext.getPrincipal().getId(); List<InAppNotificationDTO> results = alertMapper.execute(userId); if (results.isEmpty()) { return (Serializable) Collections.EMPTY_LIST; } for (InAppNotificationDTO item : results) { item.setFilterCategory(notificationTypeToCategory.get(item.getNotificationType())); } Map<String, PersonModelView> personLookup = new HashMap<String, PersonModelView>(); Map<String, DomainGroupModelView> groupLookup = new HashMap<String, DomainGroupModelView>(); for (InAppNotificationDTO notif : results) { switch (notif.getAvatarOwnerType()) { case PERSON: personLookup.put(notif.getAvatarOwnerUniqueId(), null); break; case GROUP: groupLookup.put(notif.getAvatarOwnerUniqueId(), null); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } } for (PersonModelView person : personsMapper.execute(new ArrayList(personLookup.keySet()))) { personLookup.put(person.getAccountId(), person); } for (DomainGroupModelView group : groupsMapper.execute(new ArrayList(groupLookup.keySet()))) { groupLookup.put(group.getUniqueId(), group); } for (InAppNotificationDTO notif : results) { AvatarEntity entity = null; switch (notif.getAvatarOwnerType()) { case PERSON: entity = personLookup.get(notif.getAvatarOwnerUniqueId()); break; case GROUP: entity = groupLookup.get(notif.getAvatarOwnerUniqueId()); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } if (entity != null && entity.getAvatarId() != null) { notif.setAvatarId(entity.getAvatarId()); } } log.trace("Found {} notifications for user {}", results.size(), userId); return new ArrayList(results); } }
GetInAppNotificationsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override @SuppressWarnings("unchecked") public Serializable execute(final PrincipalActionContext inActionContext) { long userId = inActionContext.getPrincipal().getId(); List<InAppNotificationDTO> results = alertMapper.execute(userId); if (results.isEmpty()) { return (Serializable) Collections.EMPTY_LIST; } for (InAppNotificationDTO item : results) { item.setFilterCategory(notificationTypeToCategory.get(item.getNotificationType())); } Map<String, PersonModelView> personLookup = new HashMap<String, PersonModelView>(); Map<String, DomainGroupModelView> groupLookup = new HashMap<String, DomainGroupModelView>(); for (InAppNotificationDTO notif : results) { switch (notif.getAvatarOwnerType()) { case PERSON: personLookup.put(notif.getAvatarOwnerUniqueId(), null); break; case GROUP: groupLookup.put(notif.getAvatarOwnerUniqueId(), null); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } } for (PersonModelView person : personsMapper.execute(new ArrayList(personLookup.keySet()))) { personLookup.put(person.getAccountId(), person); } for (DomainGroupModelView group : groupsMapper.execute(new ArrayList(groupLookup.keySet()))) { groupLookup.put(group.getUniqueId(), group); } for (InAppNotificationDTO notif : results) { AvatarEntity entity = null; switch (notif.getAvatarOwnerType()) { case PERSON: entity = personLookup.get(notif.getAvatarOwnerUniqueId()); break; case GROUP: entity = groupLookup.get(notif.getAvatarOwnerUniqueId()); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } if (entity != null && entity.getAvatarId() != null) { notif.setAvatarId(entity.getAvatarId()); } } log.trace("Found {} notifications for user {}", results.size(), userId); return new ArrayList(results); } GetInAppNotificationsExecution(final BaseArgDomainMapper<Long, List<InAppNotificationDTO>> inAlertMapper,
            final GetItemsByPointerIdsMapper<String, PersonModelView> inPersonsMapper,
            final GetItemsByPointerIds<DomainGroupModelView> inGroupsMapper,
            final Map<NotificationType, String> inNotificationTypeCategories); }
GetInAppNotificationsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override @SuppressWarnings("unchecked") public Serializable execute(final PrincipalActionContext inActionContext) { long userId = inActionContext.getPrincipal().getId(); List<InAppNotificationDTO> results = alertMapper.execute(userId); if (results.isEmpty()) { return (Serializable) Collections.EMPTY_LIST; } for (InAppNotificationDTO item : results) { item.setFilterCategory(notificationTypeToCategory.get(item.getNotificationType())); } Map<String, PersonModelView> personLookup = new HashMap<String, PersonModelView>(); Map<String, DomainGroupModelView> groupLookup = new HashMap<String, DomainGroupModelView>(); for (InAppNotificationDTO notif : results) { switch (notif.getAvatarOwnerType()) { case PERSON: personLookup.put(notif.getAvatarOwnerUniqueId(), null); break; case GROUP: groupLookup.put(notif.getAvatarOwnerUniqueId(), null); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } } for (PersonModelView person : personsMapper.execute(new ArrayList(personLookup.keySet()))) { personLookup.put(person.getAccountId(), person); } for (DomainGroupModelView group : groupsMapper.execute(new ArrayList(groupLookup.keySet()))) { groupLookup.put(group.getUniqueId(), group); } for (InAppNotificationDTO notif : results) { AvatarEntity entity = null; switch (notif.getAvatarOwnerType()) { case PERSON: entity = personLookup.get(notif.getAvatarOwnerUniqueId()); break; case GROUP: entity = groupLookup.get(notif.getAvatarOwnerUniqueId()); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } if (entity != null && entity.getAvatarId() != null) { notif.setAvatarId(entity.getAvatarId()); } } log.trace("Found {} notifications for user {}", results.size(), userId); return new ArrayList(results); } GetInAppNotificationsExecution(final BaseArgDomainMapper<Long, List<InAppNotificationDTO>> inAlertMapper,
            final GetItemsByPointerIdsMapper<String, PersonModelView> inPersonsMapper,
            final GetItemsByPointerIds<DomainGroupModelView> inGroupsMapper,
            final Map<NotificationType, String> inNotificationTypeCategories); @Override @SuppressWarnings("unchecked") Serializable execute(final PrincipalActionContext inActionContext); }
GetInAppNotificationsExecution implements ExecutionStrategy<PrincipalActionContext> { @Override @SuppressWarnings("unchecked") public Serializable execute(final PrincipalActionContext inActionContext) { long userId = inActionContext.getPrincipal().getId(); List<InAppNotificationDTO> results = alertMapper.execute(userId); if (results.isEmpty()) { return (Serializable) Collections.EMPTY_LIST; } for (InAppNotificationDTO item : results) { item.setFilterCategory(notificationTypeToCategory.get(item.getNotificationType())); } Map<String, PersonModelView> personLookup = new HashMap<String, PersonModelView>(); Map<String, DomainGroupModelView> groupLookup = new HashMap<String, DomainGroupModelView>(); for (InAppNotificationDTO notif : results) { switch (notif.getAvatarOwnerType()) { case PERSON: personLookup.put(notif.getAvatarOwnerUniqueId(), null); break; case GROUP: groupLookup.put(notif.getAvatarOwnerUniqueId(), null); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } } for (PersonModelView person : personsMapper.execute(new ArrayList(personLookup.keySet()))) { personLookup.put(person.getAccountId(), person); } for (DomainGroupModelView group : groupsMapper.execute(new ArrayList(groupLookup.keySet()))) { groupLookup.put(group.getUniqueId(), group); } for (InAppNotificationDTO notif : results) { AvatarEntity entity = null; switch (notif.getAvatarOwnerType()) { case PERSON: entity = personLookup.get(notif.getAvatarOwnerUniqueId()); break; case GROUP: entity = groupLookup.get(notif.getAvatarOwnerUniqueId()); break; default: int makeCheckstyleShutUpBecauseTheresNothingToDoHere = 1; } if (entity != null && entity.getAvatarId() != null) { notif.setAvatarId(entity.getAvatarId()); } } log.trace("Found {} notifications for user {}", results.size(), userId); return new ArrayList(results); } GetInAppNotificationsExecution(final BaseArgDomainMapper<Long, List<InAppNotificationDTO>> inAlertMapper,
            final GetItemsByPointerIdsMapper<String, PersonModelView> inPersonsMapper,
            final GetItemsByPointerIds<DomainGroupModelView> inGroupsMapper,
            final Map<NotificationType, String> inNotificationTypeCategories); @Override @SuppressWarnings("unchecked") Serializable execute(final PrincipalActionContext inActionContext);  }