Goal { public Goal(JSONObject goalData) { try { mId = goalData.getInt(ID); mIdentifier = goalData.getString(IDENTIFIER); mGoalType = GoalEnum.getEnumFromGoal(goalData.getString(TYPE)); } catch (JSONException e) { e.printStackTrace(); } try { mIsGoalTriggered = goalData.getBoolean(GOAL_TRIGGERED); } catch (JSONException e) { mIsGoalTriggered = false; } } Goal(JSONObject goalData); boolean isGoalTriggered(); void setIsGoalTriggered(boolean isGoalTriggered); GoalEnum getGoalType(); String getIdentifier(); int getId(); JSONObject getGoalAsJsonObject(); final static String TYPE; final static String IDENTIFIER; final static String ID; final static String GOAL_TRIGGERED; }
@Test public void testGoal() throws JSONException, IOException { String data = TestUtils.readJsonFile(getClass(), "com/vwo/mobile/models/goal.json"); Goal goal = new Goal(new JSONObject(data)); Assert.assertEquals(goal.getId(), 349); }