@Test(expected=MessageException.class) public void testNothingInDB() throws MessageException { ejb.getStoredMessage(); }
public String getStoredMessage() throws MessageException { @SuppressWarnings("rawtypes") List messages = em.createNamedQuery("findMessages").getResultList(); if (messages.size() > 0) { Message message = (Message) messages.get(0); return "(" + message.getMessageString() + "), inside an EJB"; } else { throw new MessageException("There was nothing in the database."); } }
ModelEJB { public String getStoredMessage() throws MessageException { @SuppressWarnings("rawtypes") List messages = em.createNamedQuery("findMessages").getResultList(); if (messages.size() > 0) { Message message = (Message) messages.get(0); return "(" + message.getMessageString() + "), inside an EJB"; } else { throw new MessageException("There was nothing in the database."); } } }
ModelEJB { public String getStoredMessage() throws MessageException { @SuppressWarnings("rawtypes") List messages = em.createNamedQuery("findMessages").getResultList(); if (messages.size() > 0) { Message message = (Message) messages.get(0); return "(" + message.getMessageString() + "), inside an EJB"; } else { throw new MessageException("There was nothing in the database."); } }  }
ModelEJB { public String getStoredMessage() throws MessageException { @SuppressWarnings("rawtypes") List messages = em.createNamedQuery("findMessages").getResultList(); if (messages.size() > 0) { Message message = (Message) messages.get(0); return "(" + message.getMessageString() + "), inside an EJB"; } else { throw new MessageException("There was nothing in the database."); } }  void putUserMessage(String messageString); String getStoredMessage(); void deleteMessage(); }
ModelEJB { public String getStoredMessage() throws MessageException { @SuppressWarnings("rawtypes") List messages = em.createNamedQuery("findMessages").getResultList(); if (messages.size() > 0) { Message message = (Message) messages.get(0); return "(" + message.getMessageString() + "), inside an EJB"; } else { throw new MessageException("There was nothing in the database."); } }  void putUserMessage(String messageString); String getStoredMessage(); void deleteMessage();  }