SortFieldConfig implements Config { public void setType(@NonNull FieldType type) { this.type = type; } 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 testSetType() throws InvalidMapBoxStyleException { try { SortFieldConfig config = new SortFieldConfig(); config.setType("invalid_type"); Assert.fail("InvalidMapBoxStyleException didn't get thrown for an invalid type"); } catch (InvalidMapBoxStyleException e) { } try { SortFieldConfig config = new SortFieldConfig(); config.setType(""); Assert.fail("InvalidMapBoxStyleException didn't get thrown for an invalid type"); } catch (InvalidMapBoxStyleException e) { } try { SortFieldConfig config = new SortFieldConfig(); config.setType((String) null); Assert.fail("InvalidMapBoxStyleException didn't get thrown for an invalid type"); } catch (InvalidMapBoxStyleException e) { } SortFieldConfig config1 = new SortFieldConfig(); config1.setType(SortFieldConfig.FieldType.DATE); Assert.assertEquals(SortFieldConfig.FieldType.DATE, config1.getType()); SortFieldConfig config2 = new SortFieldConfig(); config2.setType(SortFieldConfig.FieldType.NUMBER); Assert.assertEquals(SortFieldConfig.FieldType.NUMBER, config2.getType()); SortFieldConfig config3 = new SortFieldConfig(); config3.setType(SortFieldConfig.FieldType.STRING); Assert.assertEquals(SortFieldConfig.FieldType.STRING, config3.getType()); }