@Test public void testExecuteForMultipleFollowedGroups() { final long fordId = 42L; final String group1ShortName = "group1"; final String group3ShortName = "group3"; getEntityManager().clear(); getEntityManager().createQuery("UPDATE GroupFollower SET receiveNewActivityNotifications = :trueOrFalse") .setParameter("trueOrFalse", false).executeUpdate(); getEntityManager().clear(); getEntityManager().createQuery( "UPDATE GroupFollower SET receiveNewActivityNotifications = :trueOrFalse " + "WHERE followerId = :personId AND followingId = :groupId").setParameter("trueOrFalse", true) .setParameter("personId", fordId).setParameter("groupId", 1).executeUpdate(); getEntityManager().clear(); getEntityManager().createQuery( "UPDATE GroupFollower SET receiveNewActivityNotifications = :trueOrFalse " + "WHERE followerId = :personId AND followingId = :groupId").setParameter("trueOrFalse", true) .setParameter("personId", fordId).setParameter("groupId", 3).executeUpdate(); getEntityManager().clear(); ArrayList<String> groups = sut.execute(fordId); assertEquals(2, groups.size()); assertTrue(groups.contains(group1ShortName)); assertTrue(groups.contains(group3ShortName)); }
@Override public ArrayList<String> execute(final Long inPersonId) { String q = "SELECT shortName FROM DomainGroup WHERE id IN " + "(SELECT pk.followingId FROM GroupFollower WHERE pk.followerId = :personId " + "AND receiveNewActivityNotifications = :isSubscribed)"; Query query = getEntityManager().createQuery(q).setParameter("personId", inPersonId).setParameter( "isSubscribed", true); ArrayList<String> results = new ArrayList<String>(query.getResultList()); return results; }
GetSubscribedGroupsDbMapper extends BaseArgDomainMapper<Long, ArrayList<String>> { @Override public ArrayList<String> execute(final Long inPersonId) { String q = "SELECT shortName FROM DomainGroup WHERE id IN " + "(SELECT pk.followingId FROM GroupFollower WHERE pk.followerId = :personId " + "AND receiveNewActivityNotifications = :isSubscribed)"; Query query = getEntityManager().createQuery(q).setParameter("personId", inPersonId).setParameter( "isSubscribed", true); ArrayList<String> results = new ArrayList<String>(query.getResultList()); return results; } }
GetSubscribedGroupsDbMapper extends BaseArgDomainMapper<Long, ArrayList<String>> { @Override public ArrayList<String> execute(final Long inPersonId) { String q = "SELECT shortName FROM DomainGroup WHERE id IN " + "(SELECT pk.followingId FROM GroupFollower WHERE pk.followerId = :personId " + "AND receiveNewActivityNotifications = :isSubscribed)"; Query query = getEntityManager().createQuery(q).setParameter("personId", inPersonId).setParameter( "isSubscribed", true); ArrayList<String> results = new ArrayList<String>(query.getResultList()); return results; }  }
GetSubscribedGroupsDbMapper extends BaseArgDomainMapper<Long, ArrayList<String>> { @Override public ArrayList<String> execute(final Long inPersonId) { String q = "SELECT shortName FROM DomainGroup WHERE id IN " + "(SELECT pk.followingId FROM GroupFollower WHERE pk.followerId = :personId " + "AND receiveNewActivityNotifications = :isSubscribed)"; Query query = getEntityManager().createQuery(q).setParameter("personId", inPersonId).setParameter( "isSubscribed", true); ArrayList<String> results = new ArrayList<String>(query.getResultList()); return results; }  @Override ArrayList<String> execute(final Long inPersonId); }
GetSubscribedGroupsDbMapper extends BaseArgDomainMapper<Long, ArrayList<String>> { @Override public ArrayList<String> execute(final Long inPersonId) { String q = "SELECT shortName FROM DomainGroup WHERE id IN " + "(SELECT pk.followingId FROM GroupFollower WHERE pk.followerId = :personId " + "AND receiveNewActivityNotifications = :isSubscribed)"; Query query = getEntityManager().createQuery(q).setParameter("personId", inPersonId).setParameter( "isSubscribed", true); ArrayList<String> results = new ArrayList<String>(query.getResultList()); return results; }  @Override ArrayList<String> execute(final Long inPersonId);  }