### Question:
SMSMessagingServiceImpl implements MobileMessagingService { @Transactional public Map<Boolean, Set<GatewayResponse>> sendMessage(GatewayRequest gatewayRequest) { logger.debug("Sending message to gateway"); Set<GatewayResponse> responseList = null; Map<Boolean, Set<GatewayResponse>> result = new HashMap<Boolean, Set<GatewayResponse>>(); try { if ((gatewayRequest.getRecipientsNumber() == null || gatewayRequest.getRecipientsNumber().isEmpty()) && !ContactNumberType.PUBLIC.toString().equals(gatewayRequest.getMessageRequest().getPhoneNumberType())) { gatewayRequest.setMessageStatus(MStatus.INVALIDNUM); } else { responseList = this.getGatewayManager().sendMessage(gatewayRequest); result.put(true, responseList); logger.debug(responseList); logger.debug("Updating message status"); gatewayRequest.setResponseDetails(responseList); gatewayRequest.setMessageStatus(MStatus.SENT); } } catch (MotechException me) { logger.error("Error sending message", me); gatewayRequest.setMessageStatus(MStatus.SCHEDULED); GatewayMessageHandler orHandler = getGatewayManager().getMessageHandler(); responseList = orHandler.parseMessageResponse(gatewayRequest, "error: 901 - Cannot Connect to gateway | Details: " + me.getMessage()); result.put(false, responseList); } this.getCache().saveMessage(gatewayRequest); return result; }  @Transactional void scheduleMessage(GatewayRequest gatewayRequest); @Transactional void scheduleMessage(GatewayRequestDetails gatewayRequestDetails); @Transactional void scheduleTransactionalMessage(GatewayRequest gatewayRequest); @Transactional(readOnly = true) void sendScheduledMessages(); Map<Boolean, Set<GatewayResponse>> sendTransactionalMessage(GatewayRequest gatewayRequest); @Transactional Map<Boolean, Set<GatewayResponse>> sendMessage(GatewayRequest gatewayRequest); @Transactional(readOnly = true) void updateMessageStatuses(); CacheService getCache(); void setCache(CacheService cache); GatewayManager getGatewayManager(); void setGatewayManager(GatewayManager gatewayManager); CoreManager getCoreManager(); void setCoreManager(CoreManager coreManager); SMSMessagingServiceWorker getWorker(); void setWorker(SMSMessagingServiceWorker worker);  }### Answer:
@Test public void testSendMessage() { System.out.println("sendMessage"); GatewayRequest messageDetails = new GatewayRequestImpl(); messageDetails.setDateFrom(new Date()); messageDetails.setMessage("a message for testing"); messageDetails.setDateTo(new Date()); messageDetails.setRecipientsNumber("000000000000"); messageDetails.setGatewayRequestDetails(mockGatewayRequestDetails); Map<Boolean, Set<GatewayResponse>> expResult = new HashMap<Boolean, Set<GatewayResponse>>(); expResult.put(true, new HashSet<GatewayResponse>()); expect( mockWorker.sendMessage((GatewayRequest) anyObject()) ).andReturn(expResult); replay(mockWorker); Map<Boolean, Set<GatewayResponse>> result = instance.sendTransactionalMessage(messageDetails); assertEquals(expResult.get(true), result.get(true)); verify(mockWorker); }