Assert { public static String message(String message, Object... params) { String result = message; if (StringUtils.isNotEmpty(message)) { result = String.format(message, params); } return result; } private  Assert(); static void notNull(Object value, String comment, Object... params); static void hasLength(CharSequence value, String comment, Object... params); static void isTrue(boolean flag, String comment, Object... params); static void state(boolean flag, String comment, Object... params); static String message(String message, Object... params);  }
@Test public void messageWithNoParams() { assertThat(message(null)).isEqualTo(null); assertThat(message("")).isEqualTo(""); assertThat(message("Qwerty123")).isEqualTo("Qwerty123"); assertThatThrownBy(new ThrowableAssert.ThrowingCallable() { @Override public void call() { message("Text %s"); } }).isInstanceOf(MissingFormatArgumentException.class).hasMessage("Format specifier '%s'"); }
@Test public void messageWithParams() { assertThat(message("Qwerty123", "value")).isEqualTo("Qwerty123"); assertThat(message("Text %s", "value")).isEqualTo("Text value"); assertThat(message("Text %s %s", "value1", "value2")).isEqualTo("Text value1 value2"); assertThatThrownBy(new ThrowableAssert.ThrowingCallable() { @Override public void call() { message("Text %s %s", "value"); } }).isInstanceOf(MissingFormatArgumentException.class).hasMessage("Format specifier '%s'"); }