Messages { public static String bind(final String msgId, final Object... args) { final String pattern = getMessage(msgId); if (null == pattern) { final StringJoiner joiner = new StringJoiner(","); stream(args).map(Object::toString).forEach(joiner::add); return "!!" + msgId + "!!: " + joiner.toString(); } return MessageFormat.format(pattern, args); }  static boolean exists(final String msgId); static String getMessage(final String msgId); static String bind(final String msgId, final Object... args);  }
@Test public void testBind() { final String messageId = DirectoryNotEmptyException.class.getName() + ".0"; final String uuid = randomUUID().toString(); final String message = Messages.bind(messageId, uuid); logger.debug("Message: {}", message); assertNotNull(message); assertTrue(message.contains(uuid)); assertFalse(message.contains(messageId)); }
@Test public void shouldNotThrowException() { final String message = Messages.bind(randomUUID().toString(), randomUUID()); logger.debug("Message: {}", message); assertNotNull(message); }
@Test public void shouldKeepSpace() { final String message = Messages.bind("ship.command.TestProject.2", randomUUID()); logger.debug("Message: {}", message); assertTrue(message.startsWith(" ")); }