DataSourceConfig implements Config { public String getName() { return name; } DataSourceConfig();  DataSourceConfig(@NonNull String name);  DataSourceConfig(JSONObject jsonObject); @Override boolean isValid(); String getName(); void setName(@NonNull String name); @Override JSONObject toJsonObject(); static String[] extractDataSourceNames(@NonNull ArrayList<DataSourceConfig> dataSourceConfigs); static final String KEY_NAME; }
@Test public void testConstructor() throws JSONException, InvalidMapBoxStyleException { try { String name1 = null; new DataSourceConfig(name1); Assert.fail("InvalidMapBoxStyleException not thrown when initialized using null name"); } catch (InvalidMapBoxStyleException e) { } try { new DataSourceConfig(""); Assert.fail("InvalidMapBoxStyleException not thrown when initialized using empty name"); } catch (InvalidMapBoxStyleException e) { } try { JSONObject object1 = new JSONObject(); object1.put(DataSourceConfig.KEY_NAME, ""); new DataSourceConfig(object1); Assert.fail("InvalidMapBoxStyleException not thrown when initialized using JSONObject with an empty name"); } catch (InvalidMapBoxStyleException e) { } try { new DataSourceConfig(new JSONObject()); Assert.fail("InvalidMapBoxStyleException not thrown when initialized using JSONObject with no name key"); } catch (InvalidMapBoxStyleException e) { } catch (JSONException e) { } String name2 = "test"; DataSourceConfig config1 = new DataSourceConfig(name2); Assert.assertEquals(name2, config1.getName()); JSONObject object2 = new JSONObject(); object2.put(DataSourceConfig.KEY_NAME, name2); DataSourceConfig config2 = new DataSourceConfig(object2); Assert.assertEquals(name2, config2.getName()); }