PmMessageApi { public static PmMessage addMessage(PmObject pm, Severity severity, String key, Object... resArgs) { PmMessage msg = new PmMessage(pm, severity, key, resArgs); pm.getPmConversation().addPmMessage(msg); return msg; }  static PmMessage addMessage(PmObject pm, Severity severity, String key, Object... resArgs); static PmMessage addStringMessage(PmObject pm, Severity severity, String msgString); static PmResourceData makeRequiredMessageResData(PmAttr<?> pm); @Deprecated static PmResourceData addRequiredMessage(PmAttr<?> pm); static List<PmMessage> getMessages(PmObject pm); static List<PmMessage> getMessages(PmObject pm, Severity severity); static List<PmMessage> clearPmTreeMessages(PmObject pm); static List<PmMessage> getPmTreeMessages(PmObject pm, Severity minSeverity);  }
@Test public void testFindMostSevereMessage() { PmConversationImpl myPm = new PmConversationImpl(); PmMessage infoMsg = PmMessageApi.addMessage(myPm, Severity.INFO, "infoMsgKey"); PmMessage warnMsg = PmMessageApi.addMessage(myPm, Severity.WARN, "warnMsgKey"); PmMessage errorMsg = PmMessageApi.addMessage(myPm, Severity.ERROR, "errorMsgKey"); assertEquals(errorMsg, PmMessageUtil.findMostSevereMessage(myPm)); myPm.clearPmMessages(null, Severity.ERROR); assertEquals(warnMsg, PmMessageUtil.findMostSevereMessage(myPm)); myPm.clearPmMessages(null, Severity.WARN); assertEquals(infoMsg, PmMessageUtil.findMostSevereMessage(myPm)); myPm.clearPmMessages(null, null); Assert.assertNull(PmMessageUtil.findMostSevereMessage(myPm)); }