AsyncMessageProcessHelper { public boolean processPatientDiscoveryResponse(final String messageId, String newStatus, final String errorStatus, final RespondingGatewayPRPAIN201306UV02RequestType response) { LOG.debug("Begin AsyncMessageProcessHelper.processPatientDiscoveryResponse()..."); boolean result = false; try { if (response == null) { newStatus = errorStatus; } final AsyncMsgRecordDao instance = createAsyncMsgRecordDao(); final String direction = getInitialDirectionFromStatus(newStatus); final List<AsyncMsgRecord> records = instance.queryByMessageIdAndDirection(messageId, direction); if (records != null && !records.isEmpty()) { records.get(0).setResponseTime(new Date()); Long duration = records.get(0).getResponseTime().getTime() - records.get(0).getCreationTime().getTime(); records.get(0).setDuration(duration); records.get(0).setStatus(newStatus); records.get(0).setRspData(getBlobFromPRPAIN201306UV02RequestType(response)); instance.save(records.get(0)); result = true; } } catch (final Exception e) { LOG.error("ERROR: Failed to update the async response.", e); } LOG.debug("End AsyncMessageProcessHelper.processPatientDiscoveryResponse()..."); return result; }  boolean addPatientDiscoveryRequest(final PRPAIN201305UV02 request, final AssertionType assertion,
            final String direction); boolean addPatientDiscoveryRequest(final RespondingGatewayPRPAIN201305UV02RequestType request,
            final String direction); boolean processAck(final String messageId, String newStatus, final String errorStatus,
            final MCCIIN000002UV01 ack); boolean processMessageStatus(final String messageId, final String newStatus); boolean processPatientDiscoveryResponse(final String messageId, String newStatus, final String errorStatus,
            final RespondingGatewayPRPAIN201306UV02RequestType response); AssertionType copyAssertionTypeObject(final AssertionType orig); String marshalAssertionTypeObject(final AssertionType assertion);  }
@Test public void testProcessPatientDiscoveryResponse() { context.checking(new Expectations() { { exactly(1).of(mockDao).save(with(any(AsyncMsgRecord.class))); exactly(1).of(mockDao).queryByMessageIdAndDirection(with(any(String.class)), with(any(String.class))); will(returnValue(returnMockRecords())); } }); AsyncMessageProcessHelper asyncHelper = createAsyncMessageProcessHelper(); boolean result = asyncHelper.processPatientDiscoveryResponse("1.1", AsyncMsgRecordDao.QUEUE_STATUS_REQPROCESS, AsyncMsgRecordDao.QUEUE_STATUS_REQRCVDERR, null); assertTrue(result); }