@Test public void valid_guest_models_are_stored() throws JMSException, IOException { GuestDataUpdateReceiver receiver = new GuestDataUpdateReceiver(guestModelRepository); final String messagePayload = readValidGuestXml(); new Expectations() {{ textMessage.getBody(String.class); result = messagePayload; }}; receiver.onMessage(textMessage); new Verifications() {{ guestModelRepository.storeGuestModel(withInstanceOf(GuestModel.class)); times = 1; }}; }
@Override public void onMessage(Message message) { LOGGER.info(() -> "Received message " + message); try { GuestModel guest = JAXB.unmarshal(new StringReader(message.getBody(String.class)), GuestModel.class); LOGGER.info(() -> "Received " + guest); guestModelRepository.storeGuestModel(guest); } catch (DataBindingException | JMSException e) { LOGGER.log(SEVERE, "Cannot handle message " + message, e); } }
GuestDataUpdateReceiver implements MessageListener { @Override public void onMessage(Message message) { LOGGER.info(() -> "Received message " + message); try { GuestModel guest = JAXB.unmarshal(new StringReader(message.getBody(String.class)), GuestModel.class); LOGGER.info(() -> "Received " + guest); guestModelRepository.storeGuestModel(guest); } catch (DataBindingException | JMSException e) { LOGGER.log(SEVERE, "Cannot handle message " + message, e); } } }
GuestDataUpdateReceiver implements MessageListener { @Override public void onMessage(Message message) { LOGGER.info(() -> "Received message " + message); try { GuestModel guest = JAXB.unmarshal(new StringReader(message.getBody(String.class)), GuestModel.class); LOGGER.info(() -> "Received " + guest); guestModelRepository.storeGuestModel(guest); } catch (DataBindingException | JMSException e) { LOGGER.log(SEVERE, "Cannot handle message " + message, e); } } GuestDataUpdateReceiver(); @Inject  GuestDataUpdateReceiver(GuestModelRepository guestModelRepository); }
GuestDataUpdateReceiver implements MessageListener { @Override public void onMessage(Message message) { LOGGER.info(() -> "Received message " + message); try { GuestModel guest = JAXB.unmarshal(new StringReader(message.getBody(String.class)), GuestModel.class); LOGGER.info(() -> "Received " + guest); guestModelRepository.storeGuestModel(guest); } catch (DataBindingException | JMSException e) { LOGGER.log(SEVERE, "Cannot handle message " + message, e); } } GuestDataUpdateReceiver(); @Inject  GuestDataUpdateReceiver(GuestModelRepository guestModelRepository); @Override void onMessage(Message message); }
GuestDataUpdateReceiver implements MessageListener { @Override public void onMessage(Message message) { LOGGER.info(() -> "Received message " + message); try { GuestModel guest = JAXB.unmarshal(new StringReader(message.getBody(String.class)), GuestModel.class); LOGGER.info(() -> "Received " + guest); guestModelRepository.storeGuestModel(guest); } catch (DataBindingException | JMSException e) { LOGGER.log(SEVERE, "Cannot handle message " + message, e); } } GuestDataUpdateReceiver(); @Inject  GuestDataUpdateReceiver(GuestModelRepository guestModelRepository); @Override void onMessage(Message message); static final String GUEST_EVENT_TOPIC; }