### Question:
SummaryFilter { public PropertyDescriptor[] getPropertyDescriptors(Object object, boolean exportMode) throws IntrospectionException { BeanInfo info = Introspector.getBeanInfo(object.getClass(), Object.class); final Map<PropertyDescriptor, Integer> indexes = new HashMap<PropertyDescriptor, Integer>(); for (PropertyDescriptor property : info.getPropertyDescriptors()) { boolean add = false; int index = 100; try { Field field = getField(property); if (field.isAnnotationPresent(Summary.class)) { add = true; index = field.getAnnotation(Summary.class).index(); } else if (property.getReadMethod() != null && property.getReadMethod().isAnnotationPresent(Summary.class)) { add = true; index = property.getReadMethod().getAnnotation(Summary.class).index(); } } catch (NoSuchFieldException e) { if (property.getReadMethod() != null && property.getReadMethod().isAnnotationPresent(Summary.class)) { add = true; index = property.getReadMethod().getAnnotation(Summary.class).index(); } } if (add || exportMode) { indexes.put(property, index); } } if (indexes.isEmpty()) { for (PropertyDescriptor property : info.getPropertyDescriptors()) { indexes.put(property, 0); } } PropertyDescriptor[] descriptors; descriptors = indexes.keySet().toArray(new PropertyDescriptor[indexes.size()]); Arrays.sort(descriptors, new Comparator<PropertyDescriptor>() { public int compare(PropertyDescriptor o1, PropertyDescriptor o2) { int i = indexes.get(o1).compareTo(indexes.get(o2)); if (i == 0) { i = o1.getName().compareTo(o2.getName()); } return i; } }); return descriptors; }  PropertyDescriptor[] getPropertyDescriptors(Object object, boolean exportMode);  }### Answer:
@Test public void testFilterAndReturnOrder() throws Exception { SummaryFilter filter = new SummaryFilter(); PropertyDescriptor[] properties = filter.getPropertyDescriptors(new TestEntity(),false); assert (properties.length == 2); assert (properties[0].getName().equals("id")); assert (properties[1].getName().equals("summaryField")); }