@Test public void testExecuteNeither() { UnreadInAppNotificationCountDTO result = sut.execute(4507L); assertEquals(NORMAL_MSG, 0, result.getNormalPriority()); assertEquals(HIGH_MSG, 0, result.getHighPriority()); }
@Override public UnreadInAppNotificationCountDTO execute(final Long userId) { String q = "select count(id) from InAppNotification " + "where recipient.id = :userId and highPriority = :priority and isRead = false"; Query query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", false); int normalCount = ((Long) query.getSingleResult()).intValue(); query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", true); int highCount = ((Long) query.getSingleResult()).intValue(); return new UnreadInAppNotificationCountDTO(highCount, normalCount); }
GetUnreadInAppNotificationCountsByUserId extends ReadMapper<Long, UnreadInAppNotificationCountDTO> { @Override public UnreadInAppNotificationCountDTO execute(final Long userId) { String q = "select count(id) from InAppNotification " + "where recipient.id = :userId and highPriority = :priority and isRead = false"; Query query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", false); int normalCount = ((Long) query.getSingleResult()).intValue(); query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", true); int highCount = ((Long) query.getSingleResult()).intValue(); return new UnreadInAppNotificationCountDTO(highCount, normalCount); } }
GetUnreadInAppNotificationCountsByUserId extends ReadMapper<Long, UnreadInAppNotificationCountDTO> { @Override public UnreadInAppNotificationCountDTO execute(final Long userId) { String q = "select count(id) from InAppNotification " + "where recipient.id = :userId and highPriority = :priority and isRead = false"; Query query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", false); int normalCount = ((Long) query.getSingleResult()).intValue(); query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", true); int highCount = ((Long) query.getSingleResult()).intValue(); return new UnreadInAppNotificationCountDTO(highCount, normalCount); }  }
GetUnreadInAppNotificationCountsByUserId extends ReadMapper<Long, UnreadInAppNotificationCountDTO> { @Override public UnreadInAppNotificationCountDTO execute(final Long userId) { String q = "select count(id) from InAppNotification " + "where recipient.id = :userId and highPriority = :priority and isRead = false"; Query query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", false); int normalCount = ((Long) query.getSingleResult()).intValue(); query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", true); int highCount = ((Long) query.getSingleResult()).intValue(); return new UnreadInAppNotificationCountDTO(highCount, normalCount); }  @Override UnreadInAppNotificationCountDTO execute(final Long userId); }
GetUnreadInAppNotificationCountsByUserId extends ReadMapper<Long, UnreadInAppNotificationCountDTO> { @Override public UnreadInAppNotificationCountDTO execute(final Long userId) { String q = "select count(id) from InAppNotification " + "where recipient.id = :userId and highPriority = :priority and isRead = false"; Query query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", false); int normalCount = ((Long) query.getSingleResult()).intValue(); query = getEntityManager().createQuery(q).setParameter("userId", userId).setParameter("priority", true); int highCount = ((Long) query.getSingleResult()).intValue(); return new UnreadInAppNotificationCountDTO(highCount, normalCount); }  @Override UnreadInAppNotificationCountDTO execute(final Long userId);  }