SortFieldConfig implements Config { public static SortFieldConfig[] extractSortFieldConfigs(@NonNull MapBoxStyleHelper styleHelper) throws JSONException, InvalidMapBoxStyleException { ArrayList<SortFieldConfig> sortFieldConfigs = styleHelper.getKujakuConfig() .getSortFieldConfigs(); SortFieldConfig[] sortFields = sortFieldConfigs.toArray(new SortFieldConfig[]{}); return sortFields; } SortFieldConfig(@NonNull FieldType fieldType, @NonNull String dataField);  SortFieldConfig(@NonNull String type, @NonNull String dataField);  SortFieldConfig(@NonNull JSONObject jsonObject);  SortFieldConfig(); FieldType getType(); void setType(@NonNull FieldType type); void setType(@NonNull String type); static boolean isValidType(String type); String getDataField(); void setDataField(@NonNull String dataField); static SortFieldConfig[] extractSortFieldConfigs(@NonNull MapBoxStyleHelper styleHelper); @Override boolean isValid(); @Override JSONObject toJsonObject(); static final String KEY_DATA_FIELD; static final String KEY_TYPE; }
@Test public void testExtractSortFieldConfigs() throws InvalidMapBoxStyleException, JSONException { int count = 5; MapBoxStyleHelper helper1 = new MapBoxStyleHelper(new JSONObject()); for (int i = 0; i < count; i++) { SortFieldConfig config1 = new SortFieldConfig(SortFieldConfig.FieldType.DATE, "test" + String.valueOf(i)); helper1.getKujakuConfig().addSortFieldConfig(config1); } helper1.getKujakuConfig().addDataSourceConfig("test"); helper1.getKujakuConfig().getInfoWindowConfig().addVisibleProperty("test", "test"); SortFieldConfig[] configs1 = SortFieldConfig .extractSortFieldConfigs(new MapBoxStyleHelper(helper1.build())); Assert.assertEquals(configs1.length, count); for (int i = 0; i < count; i++) { Assert.assertEquals(configs1[i].getDataField(), "test" + String.valueOf(i)); } }