ParameterPlaceholder extends ArgumentPlaceholder { protected String formatAll(Object[] parameters) { return super.formatAll(Arrays.asList(parameters)); }  void setContext(Method method, int idx, Object[] parameters); String process(String formatPattern);  }
@Test public void testFormatAllHandleNullNullCorrectly() { final Object[] parameters = new Object[] { null, null }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("<null>, <null>"); }
@Test public void testFormatAllDoesNotThrowNullPointerExceptionIfParamsToStringReturningNull() { final Object[] parameters = new Object[] { new TestToString(null) }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("<null>"); }
@Test public void testFormatAllHandleEmtpyStringSpecially() { final Object[] parameters = new Object[] { "" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo(STRING_EMPTY); }
@Test public void testFormatAllReplacesNullTerminatorWithTheirPrintableCounterpart() { final Object[] parameters = new Object[] { "\0" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("\\0"); }
@Test public void testFormatAllReplacesNullTerminatorWithTheirPrintableCounterpartEvenIfWithText() { final Object[] parameters = new Object[] { "test\0test\0" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("test\\0test\\0"); }
@Test public void testFormatAllReplacesCarriageReturnWithTheirPrintableCounterpart() { final Object[] parameters = new Object[] { "\r" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("\\r"); }
@Test public void testFormatAllReplacesCarriageReturnsWithTheirPrintableCounterpartEvenIfWithText() { final Object[] parameters = new Object[] { "test\rtest\r" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("test\\rtest\\r"); }
@Test public void testFormatAllReplacesLineFeedWithTheirPrintableCounterpart() { final Object[] parameters = new Object[] { "\n" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("\\n"); }
@Test public void testFormatAllReplacesLineFeedsWithTheirPrintableCounterpartEvenIfWithText() { final Object[] parameters = new Object[] { "1\n2\n3" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("1\\n2\\n3"); }
@Test public void testFormatAllReplacesNonPrintableCharactersWithPredefinedPrintableCounterpart() { final Object[] parameters = new Object[] { "\u001F" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo(STRING_NON_PRINTABLE); }
@Test public void testFormatAllReplacesNonPrintableCharactersWithPredefinedPrintableCounterpartEvenIfWithText() { final Object[] parameters = new Object[] { "test\btest\uFFFF" }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("test" + STRING_NON_PRINTABLE + "test" + STRING_NON_PRINTABLE); }
@Test public void testFormatAllReplacesCarriageReturnsAndLineFeedsWithTheirPrintableCounterpart() { final Object[] parameters = new Object[] { "A very\r\nlong text\nwith multiple\rdifferent newline\n\rvariations." }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("A very\\r\\nlong text\\nwith multiple\\rdifferent newline\\n\\rvariations."); }
@Test public void testFormatAllHandleObjectArrayCorrectly() { final Object[] parameters = new Object[] { new Object[] { 7.5, "test" } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[7.5, test]"); }
@Test public void testFormatAllHandlePrimitiveBooleanTypeArrayCorrectly() { final Object[] parameters = new Object[] { new boolean[] { true, false } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[true, false]"); }
@Test public void testFormatAllHandlePrimitiveByteTypeArrayCorrectly() { final Object[] parameters = new Object[] { new byte[] { 12, 24 } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[12, 24]"); }
@Test public void testFormatAllHandlePrimitiveCharTypeArrayCorrectly() { final Object[] parameters = new Object[] { new char[] { 'a', '0' } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[a, 0]"); }
@Test public void testFormatAllHandlePrimitiveShortTypeArrayCorrectly() { final Object[] parameters = new Object[] { new short[] { 1024 } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[1024]"); }
@Test public void testFormatAllHandlePrimitiveIntTypeArrayCorrectly() { final Object[] parameters = new Object[] { new int[] { 11, 2 } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[11, 2]"); }
@Test public void testFormatAllHandlePrimitiveLongTypeArrayCorrectly() { final Object[] parameters = new Object[] { new long[] { 111L, 222L, 333L } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[111, 222, 333]"); }
@Test public void testFormatAllHandlePrimitiveFloatTypeArrayCorrectly() { final Object[] parameters = new Object[] { new float[] { 0.3f, 0.9f, 0.81f, 0.6561f } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[0.3, 0.9, 0.81, 0.6561]"); }
@Test public void testFormatAllHandlePrimitiveDoubleTypeArrayCorrectly() { final Object[] parameters = new Object[] { new double[] { .78, 3.15E2 } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[0.78, 315.0]"); }
@Test public void testFormatAllHandleFurtherNestedArraysCorrectly() { final Object[] parameters = new Object[] { new Object[] { 2, new char[] { 'a', 'b' }, new String[] { "a", "b" } } }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[2, [a, b], [a, b]]"); }
@Test public void testFormatAllHandleObjectCorrectly() { final Object[] parameters = new Object[] { new Object() }; String result = underTest.formatAll(parameters); assertThat(result).matches("java.lang.Object@[0-9a-f]+"); }
@Test public void testFormatAllHandleListsCorrectly() { final Object[] parameters = new Object[] { Arrays.<Object> asList("test", 1, 1723940567289346512L), 3 }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("[test, 1, 1723940567289346512], 3"); }
@Test public void testFormatAllHandleEnumsCorrectly() { final Object[] parameters = new Object[] { Thread.State.RUNNABLE }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("RUNNABLE"); }
@Test public void testFormatAllHandleComplexExampleCorrectly() { Date now = new Date(); final Object[] parameters = new Object[] { now, Double.valueOf(3.5), new StringBuilder("1").append("|2").append("|3"), new File("src/main/java/com/tngtech"), }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo(now.toString() + ", 3.5, 1|2|3, src/main/java/com/tngtech"); }
@Test public void testFormatAllShouldHandleSingleValueCorrectly() { final Object[] parameters = new Object[] { 12.45 }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("12.45"); }
@Test public void testFormatAllShouldReturnAllThreeValuesCorrectly() { final Object[] parameters = new Object[] { "test", 1, 2L }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo("test, 1, 2"); }
@Test public void testFormatAllHandleNullSpecially() { final Object[] parameters = new Object[] { null }; String result = underTest.formatAll(parameters); assertThat(result).isEqualTo(STRING_NULL); }