@Test public void testGetHighestMessageLevel() { List<Message.MessageLevel> levels = Arrays.asList(Message.MessageLevel.values()); Collections.reverse(levels); assertEquals(0, container.getAllMessages().size()); assertNull(MessagesUtils.getHighestMessageLevel(container.getAllMessages())); for (Message.MessageLevel val : levels) { Message m = new Message("test " + val, Collections.singleton("test" + val), val, Duration.ofMinutes(10)); container.addMessage(m); } assertEquals(Message.MessageLevel.values().length, container.getAllMessages().size()); assertEquals(Message.MessageLevel.ERROR.toString(), MessagesUtils.getHighestMessageLevel(container.getAllMessages())); }
static String getHighestMessageLevel(Collection<MessagesContainer.AcceptedMessage> messages) { return messages. stream(). map(MessagesContainer.AcceptedMessage::getMessageLevel). max(Message.MessageLevel.VALUE_COMPARATOR). map(Message.MessageLevel::toString). orElse(null); }
MessagesUtils { static String getHighestMessageLevel(Collection<MessagesContainer.AcceptedMessage> messages) { return messages. stream(). map(MessagesContainer.AcceptedMessage::getMessageLevel). max(Message.MessageLevel.VALUE_COMPARATOR). map(Message.MessageLevel::toString). orElse(null); } }
MessagesUtils { static String getHighestMessageLevel(Collection<MessagesContainer.AcceptedMessage> messages) { return messages. stream(). map(MessagesContainer.AcceptedMessage::getMessageLevel). max(Message.MessageLevel.VALUE_COMPARATOR). map(Message.MessageLevel::toString). orElse(null); }  }
MessagesUtils { static String getHighestMessageLevel(Collection<MessagesContainer.AcceptedMessage> messages) { return messages. stream(). map(MessagesContainer.AcceptedMessage::getMessageLevel). max(Message.MessageLevel.VALUE_COMPARATOR). map(Message.MessageLevel::toString). orElse(null); }  static void printMessages(Writer out, SortedSet<MessagesContainer.AcceptedMessage> set); static String messagesToJson(String... tags); static String messagesToJson(Project project, String... additionalTags); static String messagesToJson(Project project); static String messagesToJson(Group group); static String getMessageLevel(String... tags); }
MessagesUtils { static String getHighestMessageLevel(Collection<MessagesContainer.AcceptedMessage> messages) { return messages. stream(). map(MessagesContainer.AcceptedMessage::getMessageLevel). max(Message.MessageLevel.VALUE_COMPARATOR). map(Message.MessageLevel::toString). orElse(null); }  static void printMessages(Writer out, SortedSet<MessagesContainer.AcceptedMessage> set); static String messagesToJson(String... tags); static String messagesToJson(Project project, String... additionalTags); static String messagesToJson(Project project); static String messagesToJson(Group group); static String getMessageLevel(String... tags);  }