AsyncMessageProcessHelper { public boolean processAck(final String messageId, String newStatus, final String errorStatus, final MCCIIN000002UV01 ack) { LOG.debug("Begin AsyncMessageProcessHelper.processAck()..."); boolean result = false; try { if (isAckError(ack)) { 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).setStatus(newStatus); records.get(0).setAckData(getBlobFromMCCIIN000002UV01(ack)); instance.save(records.get(0)); } result = true; } catch (final Exception e) { LOG.error("ERROR: Failed to update the async request.", e); } LOG.debug("End AsyncMessageProcessHelper.processAck()..."); 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 testProcessAck_MCCIIN000002UV01() { String messageId = "111111111"; String newStatus = AsyncMsgRecordDao.QUEUE_STATUS_RSPRCVDERR; String errorStatus = AsyncMsgRecordDao.QUEUE_STATUS_RSPRCVDERR; MCCIIN000002UV01 ack = new MCCIIN000002UV01(); MCCIMT000200UV01Acknowledgement mccAck = new MCCIMT000200UV01Acknowledgement(); CS typeCode = new CS(); typeCode.setCode(HL7AckTransforms.ACK_TYPE_CODE_ERROR); mccAck.setTypeCode(typeCode); ack.getAcknowledgement().add(mccAck); try { 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.processAck(messageId, newStatus, errorStatus, ack); assertTrue(result); } catch (Exception e) { e.printStackTrace(); fail("Error running testProcessAck_MCCIIN000002UV01: " + e.getMessage()); } }