InsertValue { @Override public final String toString() { StringBuilder result = new StringBuilder(); result.append("("); for (int i = 0; i < values.size(); i++) { result.append(getValue(i)).append(", "); } result.delete(result.length() - 2, result.length()).append(")"); return result.toString(); }  @Override final String toString();  }
@Test public void assertToString() { List<ExpressionSegment> expressionSegmentList = new ArrayList<>(3); ParameterMarkerExpressionSegment parameterMarkerExpressionSegment = new ParameterMarkerExpressionSegment(1, 1, 1); LiteralExpressionSegment literalExpressionSegment = new LiteralExpressionSegment(2, 2, "literals"); ComplexExpressionSegment complexExpressionSegment = new ComplexExpressionSegment() { @Override public String getText() { return "complexExpressionSegment"; } @Override public int getStartIndex() { return 3; } @Override public int getStopIndex() { return 3; } }; expressionSegmentList.add(parameterMarkerExpressionSegment); expressionSegmentList.add(literalExpressionSegment); expressionSegmentList.add(complexExpressionSegment); InsertValue insertValue = new InsertValue(expressionSegmentList); String actualToString = insertValue.toString(); String expectedToString = "(?, 'literals', complexExpressionSegment)"; assertThat(actualToString, is(expectedToString)); }