### Question:
MessengerServiceImpl implements MessengerService { @Override public List<Object> getInfo(String userId) { List<Object> info1 = em.createQuery("SELECT DISTINCT a.sendId FROM Messenger AS a" + " WHERE a.receiveId = :userId").setParameter("userId", userId).getResultList(); List<Object> info3 = new ArrayList<>(); for (int i = 0; i < info1.size(); i++) { String sendId = info1.get(i).toString(); Object info2 = em.createQuery("SELECT DISTINCT a.sendId, a.receiveId,a.msg,a.datetime FROM Messenger AS a" + " WHERE a.receiveId = :userId AND a.sendId = :sendId ORDER BY datetime DESC").setParameter("userId", userId).setParameter("sendId", sendId).setMaxResults(1).getResultList(); info3.add(info2); } return info3; }  @Override List<Messenger> getAll(); @Override void addMessenger(Messenger messenger); @Override List<Messenger> getMessenger(String sendId, String receiveId); @Override int seenMessage(Messenger messenger); @Override List<Object> getInfo(String userId);  }### Answer:
@Test void getInfoTest() { Messenger Messenger1 = new Messenger("Hello","12341","123423"); Messenger Messenger2 = new Messenger("Bonjour","12341","12333"); Messenger Messenger3 = new Messenger("Hi","12340","12342"); Messenger Messenger4 = new Messenger("Hello","12341","12342"); em.persist(Messenger1); em.persist(Messenger2); em.persist(Messenger3); em.persist(Messenger4); List<Object> objects = Messengerserviceimpl.getInfo("12342"); int size2 = objects.size(); assertEquals(2,size2); }