### Question:
EnergyModellerMessageListener implements MessageListener { @Override public void onMessage(Message message) { TextMessage textMessage = (TextMessage) message; try { JAXBContext jc = org.eclipse.persistence.jaxb.JAXBContextFactory.createContext(new Class[] {EnergyModellerMessage.class}, null); Unmarshaller unmarshaller = jc.createUnmarshaller(); unmarshaller.setProperty(UnmarshallerProperties.MEDIA_TYPE, "application/json"); unmarshaller.setProperty(UnmarshallerProperties.JSON_INCLUDE_ROOT, false); StreamSource jsonSource = new StreamSource(new StringReader(textMessage.getText())); EnergyModellerMessage emMessage = unmarshaller.unmarshal(jsonSource, EnergyModellerMessage.class).getValue(); controller.addMessage(emMessage, type); } catch(JAXBException exception) { logger.info("Error parsing message from Energy Modeller"); logger.info(exception.getStackTrace()); } catch(JMSException exception) { logger.info("Error reading the queue from PaaS Energy Modeller"); logger.info(exception.getStackTrace()); } } EnergyModellerMessageListener(EnergyModellerQueueController controller, String type); @Override void onMessage(Message message);  }### Answer:
@Test public void onMessageTest() throws Exception { EnergyModellerQueueController controller = mock(EnergyModellerQueueController.class); Configuration.emMeasurementsTopic = "MEASUREMENTS"; AmqpMessageReceiver receiver = new AmqpMessageReceiver(Configuration.amqpAddress, Configuration.amqpUsername, Configuration.amqpPassword, Configuration.emMeasurementsTopic, true); EnergyModellerMessageListener emListener = new EnergyModellerMessageListener(controller, "aaa"); receiver.setMessageConsumer(emListener); String message = "{" + "\"provider\":null," + "\"applicationid\":\"davidgpTestApp\"," + "\"eventid\":\"loquesea\"," + "\"deploymentid\":\"569\"," + "\"vms\":[\"1899\"]," + "\"unit\":\"SEC\"," + "\"generattiontimestamp\":\"30 Sep 2015 16:29:35 GMT\"," + "\"referredtimestamp\":\"30 Sep 2015 16:29:35 GMT\"," + "\"value\":0.0" + "}"; AmqpMessageProducer producer = new AmqpMessageProducer(Configuration.amqpAddress, Configuration.amqpUsername, Configuration.amqpPassword, Configuration.emMeasurementsTopic, true); producer.sendMessage(message); producer.close(); Thread.sleep(1000l); EnergyModellerMessage emMessage = new EnergyModellerMessage(); emMessage.setApplicationid("davidgpTestApp"); emMessage.setDeploymentid("569"); emMessage.setEventid("loquesea"); emMessage.setUnit("SEC"); emMessage.setGenerattiontimestamp("30 Sep 2015 16:29:35 GMT"); emMessage.setReferredtimestamp("30 Sep 2015 16:29:35 GMT"); emMessage.setValue("0.0"); List<String> vms = new ArrayList<String>(); vms.add("1899"); emMessage.setVms(vms); verify(controller, times(1)).addMessage(emMessage, "aaa"); receiver.close(); }