CompareController extends AbstractController implements IController { protected List<String> sortAndAdjustSampleNameList(List<String> inputList) { Collections.sort(inputList, String.CASE_INSENSITIVE_ORDER); final List<String> resultList = new ArrayList<String>(); String previousListItem = null; int counter = 2; for (String listItem : inputList) { String newListItem = listItem; if (newListItem.equals(previousListItem)) { newListItem += "_" + counter; counter++; } else { counter = 2; } previousListItem = listItem; resultList.add(newListItem); } return resultList; }  @Override ModelAndView doGet(ModelMap model); @RequestMapping(method = RequestMethod.POST) ModelAndView doPostComparisonToolForm(@Valid @ModelAttribute("comparisonForm") final ComparisonForm comparisonForm,
                                                 BindingResult result,
                                                 ModelMap model); @RequestMapping(value = "/samples") ModelAndView getRunsByStudyId(@RequestParam(value = "studyId", required = true)
                                         final long studyId,
                                         @ModelAttribute(value = "comparisonForm")
                                         final ComparisonForm comparisonForm); @RequestMapping(value = "/studies") ModelAndView getStudyDescription(
            @RequestParam(value = "studyId", required = true) final String studyId
    ); static final String VIEW_NAME; }
@Test public void testRunIdHack() throws Exception { List<String> sampleIds = new ArrayList<String>(); sampleIds.add("ERS000005"); sampleIds.add("ERS000006"); sampleIds.add("ERS000003"); sampleIds.add("ERS000004"); sampleIds.add("ERS000010"); sampleIds.add("ERS000002"); sampleIds.add("ERS000001"); sampleIds.add("ERS000002"); sampleIds.add("ERS000003"); sampleIds.add("ERS000003"); sampleIds.add("ERS000003"); assertTrue(sampleIds.size() == 11); List<String> sortedList = controller.sortAndAdjustSampleNameList(sampleIds); assertTrue(sortedList.size() == 11); assertEquals("ERS000001", sortedList.get(0)); assertEquals("ERS000002", sortedList.get(1)); assertEquals("ERS000002_2", sortedList.get(2)); assertEquals("ERS000003", sortedList.get(3)); assertEquals("ERS000003_2", sortedList.get(4)); assertEquals("ERS000003_3", sortedList.get(5)); assertEquals("ERS000003_4", sortedList.get(6)); assertEquals("ERS000004", sortedList.get(7)); assertEquals("ERS000005", sortedList.get(8)); assertEquals("ERS000006", sortedList.get(9)); assertEquals("ERS000010", sortedList.get(10)); }