@Test public void testExecute() { getEntityManager().createQuery("DELETE FROM Follower").executeUpdate(); getEntityManager().persist(new Follower(42L, 98)); getEntityManager().persist(new Follower(42L, 4507)); getEntityManager().persist(new Follower(98, 142)); getEntityManager().persist(new Follower(4507, 142)); getEntityManager().persist(new Follower(98, 99)); List<PersonModelView> suggestions = sut.execute(new SuggestedStreamsRequest(42, 5)); Assert.assertEquals(2, suggestions.size()); Assert.assertEquals(142, suggestions.get(0).getId()); Assert.assertEquals("fordp2", suggestions.get(0).getAccountId()); Assert.assertEquals("Volgon-Vwatter Prefect", suggestions.get(0).getDisplayName()); Assert.assertEquals(2, suggestions.get(0).getFollowersCount()); Assert.assertEquals(99L, suggestions.get(1).getId()); Assert.assertEquals("mrburns", suggestions.get(1).getAccountId()); Assert.assertEquals("Mr.Burns Burns", suggestions.get(1).getDisplayName()); Assert.assertEquals(1, suggestions.get(1).getFollowersCount()); suggestions = sut.execute(new SuggestedStreamsRequest(42, 1)); Assert.assertEquals(1, suggestions.size()); Assert.assertEquals(142L, suggestions.get(0).getId()); Assert.assertEquals("fordp2", suggestions.get(0).getAccountId()); Assert.assertEquals("Volgon-Vwatter Prefect", suggestions.get(0).getDisplayName()); Assert.assertEquals(2, suggestions.get(0).getFollowersCount()); getEntityManager().persist(new Follower(42, 99)); suggestions = sut.execute(new SuggestedStreamsRequest(42, 5)); Assert.assertEquals(1, suggestions.size()); Assert.assertEquals(142L, suggestions.get(0).getId()); Assert.assertEquals("fordp2", suggestions.get(0).getAccountId()); Assert.assertEquals("Volgon-Vwatter Prefect", suggestions.get(0).getDisplayName()); Assert.assertEquals(2, suggestions.get(0).getFollowersCount()); }
@Override @SuppressWarnings("unchecked") public List<PersonModelView> execute(final SuggestedStreamsRequest inRequest) { Query query = getEntityManager() .createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(" + "peopleTheyFollow.pk.followingId, " + "person.accountId, person.preferredName, person.lastName, person.displayName, " + "person.displayNameSuffix, " + "COUNT(peopleTheyFollow.pk.followingId), person.dateAdded, person.streamScope.id) " + "FROM Follower peopleIFollow, Follower peopleTheyFollow, Person person " + "WHERE peopleIFollow.pk.followingId = peopleTheyFollow.pk.followerId " + "AND peopleIFollow.pk.followerId = :personId" + " AND peopleTheyFollow.pk.followingId NOT IN " + "(SELECT pk.followingId FROM Follower WHERE followerId = :personId) " + " AND person.streamScope.id NOT IN " + "(SELECT pk.scopeId FROM PersonBlockedSuggestion " + "WHERE personid = :personBlockedId) " + "AND person.id = peopleTheyFollow.pk.followingId " + "AND person.accountLocked = false AND person.accountDeactivated = false " + "GROUP BY peopleTheyFollow.pk.followingId, person.accountId, person.preferredName, " + "person.lastName, person.displayNameSuffix, person.displayName, person.dateAdded, " + "person.streamScope.id " + "ORDER BY COUNT(peopleTheyFollow.pk.followingId) DESC") .setParameter("personBlockedId", inRequest.getPersonId()) .setParameter("personId", inRequest.getPersonId()); query.setMaxResults(inRequest.getStreamCount()); return query.getResultList(); }
GetSuggestedPeopleForPersonDbMapper extends
        BaseArgDomainMapper<SuggestedStreamsRequest, List<PersonModelView>> { @Override @SuppressWarnings("unchecked") public List<PersonModelView> execute(final SuggestedStreamsRequest inRequest) { Query query = getEntityManager() .createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(" + "peopleTheyFollow.pk.followingId, " + "person.accountId, person.preferredName, person.lastName, person.displayName, " + "person.displayNameSuffix, " + "COUNT(peopleTheyFollow.pk.followingId), person.dateAdded, person.streamScope.id) " + "FROM Follower peopleIFollow, Follower peopleTheyFollow, Person person " + "WHERE peopleIFollow.pk.followingId = peopleTheyFollow.pk.followerId " + "AND peopleIFollow.pk.followerId = :personId" + " AND peopleTheyFollow.pk.followingId NOT IN " + "(SELECT pk.followingId FROM Follower WHERE followerId = :personId) " + " AND person.streamScope.id NOT IN " + "(SELECT pk.scopeId FROM PersonBlockedSuggestion " + "WHERE personid = :personBlockedId) " + "AND person.id = peopleTheyFollow.pk.followingId " + "AND person.accountLocked = false AND person.accountDeactivated = false " + "GROUP BY peopleTheyFollow.pk.followingId, person.accountId, person.preferredName, " + "person.lastName, person.displayNameSuffix, person.displayName, person.dateAdded, " + "person.streamScope.id " + "ORDER BY COUNT(peopleTheyFollow.pk.followingId) DESC") .setParameter("personBlockedId", inRequest.getPersonId()) .setParameter("personId", inRequest.getPersonId()); query.setMaxResults(inRequest.getStreamCount()); return query.getResultList(); } }
GetSuggestedPeopleForPersonDbMapper extends
        BaseArgDomainMapper<SuggestedStreamsRequest, List<PersonModelView>> { @Override @SuppressWarnings("unchecked") public List<PersonModelView> execute(final SuggestedStreamsRequest inRequest) { Query query = getEntityManager() .createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(" + "peopleTheyFollow.pk.followingId, " + "person.accountId, person.preferredName, person.lastName, person.displayName, " + "person.displayNameSuffix, " + "COUNT(peopleTheyFollow.pk.followingId), person.dateAdded, person.streamScope.id) " + "FROM Follower peopleIFollow, Follower peopleTheyFollow, Person person " + "WHERE peopleIFollow.pk.followingId = peopleTheyFollow.pk.followerId " + "AND peopleIFollow.pk.followerId = :personId" + " AND peopleTheyFollow.pk.followingId NOT IN " + "(SELECT pk.followingId FROM Follower WHERE followerId = :personId) " + " AND person.streamScope.id NOT IN " + "(SELECT pk.scopeId FROM PersonBlockedSuggestion " + "WHERE personid = :personBlockedId) " + "AND person.id = peopleTheyFollow.pk.followingId " + "AND person.accountLocked = false AND person.accountDeactivated = false " + "GROUP BY peopleTheyFollow.pk.followingId, person.accountId, person.preferredName, " + "person.lastName, person.displayNameSuffix, person.displayName, person.dateAdded, " + "person.streamScope.id " + "ORDER BY COUNT(peopleTheyFollow.pk.followingId) DESC") .setParameter("personBlockedId", inRequest.getPersonId()) .setParameter("personId", inRequest.getPersonId()); query.setMaxResults(inRequest.getStreamCount()); return query.getResultList(); }  }
GetSuggestedPeopleForPersonDbMapper extends
        BaseArgDomainMapper<SuggestedStreamsRequest, List<PersonModelView>> { @Override @SuppressWarnings("unchecked") public List<PersonModelView> execute(final SuggestedStreamsRequest inRequest) { Query query = getEntityManager() .createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(" + "peopleTheyFollow.pk.followingId, " + "person.accountId, person.preferredName, person.lastName, person.displayName, " + "person.displayNameSuffix, " + "COUNT(peopleTheyFollow.pk.followingId), person.dateAdded, person.streamScope.id) " + "FROM Follower peopleIFollow, Follower peopleTheyFollow, Person person " + "WHERE peopleIFollow.pk.followingId = peopleTheyFollow.pk.followerId " + "AND peopleIFollow.pk.followerId = :personId" + " AND peopleTheyFollow.pk.followingId NOT IN " + "(SELECT pk.followingId FROM Follower WHERE followerId = :personId) " + " AND person.streamScope.id NOT IN " + "(SELECT pk.scopeId FROM PersonBlockedSuggestion " + "WHERE personid = :personBlockedId) " + "AND person.id = peopleTheyFollow.pk.followingId " + "AND person.accountLocked = false AND person.accountDeactivated = false " + "GROUP BY peopleTheyFollow.pk.followingId, person.accountId, person.preferredName, " + "person.lastName, person.displayNameSuffix, person.displayName, person.dateAdded, " + "person.streamScope.id " + "ORDER BY COUNT(peopleTheyFollow.pk.followingId) DESC") .setParameter("personBlockedId", inRequest.getPersonId()) .setParameter("personId", inRequest.getPersonId()); query.setMaxResults(inRequest.getStreamCount()); return query.getResultList(); }  @Override @SuppressWarnings("unchecked") List<PersonModelView> execute(final SuggestedStreamsRequest inRequest); }
GetSuggestedPeopleForPersonDbMapper extends
        BaseArgDomainMapper<SuggestedStreamsRequest, List<PersonModelView>> { @Override @SuppressWarnings("unchecked") public List<PersonModelView> execute(final SuggestedStreamsRequest inRequest) { Query query = getEntityManager() .createQuery( "SELECT new org.eurekastreams.server.search.modelview.PersonModelView(" + "peopleTheyFollow.pk.followingId, " + "person.accountId, person.preferredName, person.lastName, person.displayName, " + "person.displayNameSuffix, " + "COUNT(peopleTheyFollow.pk.followingId), person.dateAdded, person.streamScope.id) " + "FROM Follower peopleIFollow, Follower peopleTheyFollow, Person person " + "WHERE peopleIFollow.pk.followingId = peopleTheyFollow.pk.followerId " + "AND peopleIFollow.pk.followerId = :personId" + " AND peopleTheyFollow.pk.followingId NOT IN " + "(SELECT pk.followingId FROM Follower WHERE followerId = :personId) " + " AND person.streamScope.id NOT IN " + "(SELECT pk.scopeId FROM PersonBlockedSuggestion " + "WHERE personid = :personBlockedId) " + "AND person.id = peopleTheyFollow.pk.followingId " + "AND person.accountLocked = false AND person.accountDeactivated = false " + "GROUP BY peopleTheyFollow.pk.followingId, person.accountId, person.preferredName, " + "person.lastName, person.displayNameSuffix, person.displayName, person.dateAdded, " + "person.streamScope.id " + "ORDER BY COUNT(peopleTheyFollow.pk.followingId) DESC") .setParameter("personBlockedId", inRequest.getPersonId()) .setParameter("personId", inRequest.getPersonId()); query.setMaxResults(inRequest.getStreamCount()); return query.getResultList(); }  @Override @SuppressWarnings("unchecked") List<PersonModelView> execute(final SuggestedStreamsRequest inRequest);  }