void (final String string, final String truncated, MyWidthCalculator calculator) { int width = calculator.stringWidth(truncated); final boolean equals = string.equals(truncated); if (equals) { width += calculator.stringWidth(SwingHelper.ERROR_STR); } else { width += calculator.stringWidth(SwingHelper.ELLIPSIS) + calculator.stringWidth(SwingHelper.ERROR_STR); } final String result = SwingHelper.truncateStringWithEllipsis(string, width, calculator); if (equals) Assert.assertEquals(truncated, result); else Assert.assertEquals(truncated + SwingHelper.ELLIPSIS, result); }