FormSection implements Comparable<FormSection> { public List<FormField> getOrderedHighLightedFields() { SortedMap<Integer, FormField> sortedFormFields = new TreeMap<Integer, FormField>(); for (FormField formField : fields) { if (formField.getHighlightInfo() != null && formField.getHighlightInfo().getHighlighted()) { Integer order = Integer.parseInt(formField.getHighlightInfo().getOrder()); sortedFormFields.put(order, formField); } } return Arrays.asList(sortedFormFields.values().toArray(new FormField[]{})); }  String getLocalizedName(); String getLocalizedHelpText(); @Override int compareTo(FormSection other); String toString(); List<FormField> getOrderedHighLightedFields(); List<FormField> getOrderedTitleFields();  }
@Test public void shouldReturnSortedHighlightedFields() { assertEquals(10, formSections.size()); assertEquals("Basic Identity", formSections.get(0).getName().get("en")); List<FormField> formFields = formSections.get(0).getOrderedHighLightedFields(); assertEquals(4, formFields.size()); assertEquals(NAME_FIELD_ID, formFields.get(0).getId()); assertEquals(RC_ID_NO_FIELD_ID, formFields.get(1).getId()); assertEquals(PROTECTION_STATUS_FIELD_ID, formFields.get(2).getId()); assertEquals(FTR_STATUS_FIELD_ID, formFields.get(3).getId()); }