### Question:
GatewayResponseDAOImpl extends HibernateGenericDAOImpl<GatewayResponseImpl> implements GatewayResponseDAO<GatewayResponseImpl> { public GatewayResponse getMostRecentResponseByMessageId(Long messageId) { logger.debug("variable passed to getMostRecentResponseByRequestId: " + messageId); try { GatewayResponse response = null; String query = "from GatewayResponseImpl g where g.gatewayRequest.messageRequest.id = :reqId and g.gatewayRequest.messageStatus != 'PENDING' and g.gatewayRequest.messageStatus != 'PROCESSING' "; List responses = this.getSessionFactory().getCurrentSession().createQuery(query).setParameter("reqId", messageId).list(); logger.debug(responses); return responses != null && responses.size() > 0 ? (GatewayResponse) responses.get(0) : null; } catch (HibernateException he) { logger.error("Persistence or JDBC Exception in getMostRecentResponseByRequestId", he); return null; } catch (Exception ex) { logger.error("Exception in getMostRecentResponseByRequestId", ex); return new GatewayResponseImpl(); } } GatewayResponseDAOImpl(); GatewayResponse getMostRecentResponseByMessageId(Long messageId); List getByPendingMessageAndMaxTries(int maxTries);  }### Answer:
@Test public void testGetMostRecentResponseByRequestId() { System.out.println("getMostRecentResponseByRequestId"); GatewayResponse result = rDDAO.getMostRecentResponseByMessageId(grq1.getMessageRequest().getId()); System.out.println(result.getId()); Assert.assertNotNull(result); Assert.assertEquals(gr7, result); Assert.assertEquals(gr7.getId(), result.getId()); System.out.println("===================================================================================================="); System.out.println(result.toString()); }