### Question:
ArrayParameters { static String updateQueryWithArrayParameters(String parsedQuery, List<ArrayParameter> arrayParametersSortedAsc) { if(arrayParametersSortedAsc.isEmpty()) { return parsedQuery; } StringBuilder sb = new StringBuilder(); Iterator<ArrayParameter> parameterToReplaceIt = arrayParametersSortedAsc.iterator(); ArrayParameter nextParameterToReplace = parameterToReplaceIt.next(); int currentIndex = 1; for(char c : parsedQuery.toCharArray()) { if(nextParameterToReplace != null && c == '?') { if(currentIndex == nextParameterToReplace.parameterIndex) { sb.append("?"); for(int i = 1; i < nextParameterToReplace.parameterCount; i++) { sb.append(",?"); } if(parameterToReplaceIt.hasNext()) { nextParameterToReplace = parameterToReplaceIt.next(); } else { nextParameterToReplace = null; } } else { sb.append(c); } currentIndex++; } else { sb.append(c); } } return sb.toString(); }    }### Answer:
@Test public void testUpdateQueryWithArrayParameters() { assertEquals( "SELECT * FROM user WHERE id IN(?,?,?,?,?)", ArrayParameters.updateQueryWithArrayParameters( "SELECT * FROM user WHERE id IN(?)", ImmutableList.of(new ArrayParameters.ArrayParameter(1, 5)) ) ); assertEquals( "SELECT * FROM user WHERE id IN(?)", ArrayParameters.updateQueryWithArrayParameters( "SELECT * FROM user WHERE id IN(?)", new ArrayList<ArrayParameters.ArrayParameter>() ) ); assertEquals( "SELECT * FROM user WHERE id IN(?)", ArrayParameters.updateQueryWithArrayParameters( "SELECT * FROM user WHERE id IN(?)", ImmutableList.of(new ArrayParameters.ArrayParameter(1, 0)) ) ); assertEquals( "SELECT * FROM user WHERE id IN(?)", ArrayParameters.updateQueryWithArrayParameters( "SELECT * FROM user WHERE id IN(?)", ImmutableList.of(new ArrayParameters.ArrayParameter(1, 1)) ) ); assertEquals( "SELECT * FROM user WHERE login = ? AND id IN(?,?)", ArrayParameters.updateQueryWithArrayParameters( "SELECT * FROM user WHERE login = ? AND id IN(?)", ImmutableList.of(new ArrayParameters.ArrayParameter(2, 2)) ) ); assertEquals( "SELECT * FROM user WHERE login = ? AND id IN(?,?) AND name = ?", ArrayParameters.updateQueryWithArrayParameters( "SELECT * FROM user WHERE login = ? AND id IN(?) AND name = ?", ImmutableList.of(new ArrayParameters.ArrayParameter(2, 2)) ) ); assertEquals( "SELECT ... WHERE other_id IN (?,?,?) login = ? AND id IN(?,?,?) AND name = ?", ArrayParameters.updateQueryWithArrayParameters( "SELECT ... WHERE other_id IN (?) login = ? AND id IN(?) AND name = ?", ImmutableList.of( new ArrayParameters.ArrayParameter(1, 3), new ArrayParameters.ArrayParameter(3, 3) ) ) ); assertEquals( "SELECT ... WHERE other_id IN (?,?,?,?,?) login = ? AND id IN(?,?,?) AND name = ?", ArrayParameters.updateQueryWithArrayParameters( "SELECT ... WHERE other_id IN (?) login = ? AND id IN(?) AND name = ?", ImmutableList.of( new ArrayParameters.ArrayParameter(1, 5), new ArrayParameters.ArrayParameter(3, 3) ) ) ); }