RouteService implements IRouteService { public List<Object> buildParameters(Map<Integer, ParameterCommand> commonds){ if (commonds == null || commonds.size() == 0){ return null; } SortedSet<Map.Entry<Integer, ParameterCommand>> set = new TreeSet<Map.Entry<Integer, ParameterCommand>>(new Comparator<Map.Entry<Integer, ParameterCommand>>() { @Override public int compare(Map.Entry<Integer, ParameterCommand> e1, Map.Entry<Integer, ParameterCommand> e2) { return e1.getKey().compareTo(e2.getKey()); } }); for (Map.Entry entry : commonds.entrySet()){ set.add(entry); } List<Object> result = new ArrayList<Object>(commonds.size()); for (Map.Entry<Integer, ParameterCommand> entry : set){ result.add(entry.getValue().getParttionArg()); } return result; }  ExecutePlan doRoute(String sql, Map<Integer, ParameterCommand> parameterCommand); ExecutePlan route(List<String> tables, List<CalculateUnit> units, String sql, SqlType sqlType); List<Object> buildParameters(Map<Integer, ParameterCommand> commonds);  }
@Test public void testBuildParameters() throws Exception { Map<Integer, ParameterCommand> commonds = new HashMap<Integer, ParameterCommand>(); commonds.put(3, new ParameterCommand(ParameterMethod.setInt, new Object[]{3}, 3)); commonds.put(1, new ParameterCommand(ParameterMethod.setInt, new Object[]{1}, 1)); commonds.put(2, new ParameterCommand(ParameterMethod.setInt, new Object[]{2}, 2)); List<Object> result = routeService.buildParameters(commonds); System.out.println(result); Assert.assertEquals(3, result.size()); Assert.assertEquals(1, result.get(0)); Assert.assertEquals(2, result.get(1)); Assert.assertEquals(3, result.get(2)); }