@Test(expected = JsonParseException.class) public void testParseNoMatch() { mData.remove("match"); mNotification = new ScoreNotification(mData.toString(), mWriter, mRenderer); mNotification.parseMessageData(); }
@Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("match")) { throw new JsonParseException("Notification data does not contain 'match"); } JsonObject match = jsonData.get("match").getAsJsonObject(); this.match = gson.fromJson(match, Match.class); this.matchKey = this.match.getKey(); this.eventKey = MatchHelper.getEventKeyFromMatchKey(matchKey); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name"); } eventName = jsonData.get("event_name").getAsString(); }
ScoreNotification extends BaseNotification<ScoreNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("match")) { throw new JsonParseException("Notification data does not contain 'match"); } JsonObject match = jsonData.get("match").getAsJsonObject(); this.match = gson.fromJson(match, Match.class); this.matchKey = this.match.getKey(); this.eventKey = MatchHelper.getEventKeyFromMatchKey(matchKey); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name"); } eventName = jsonData.get("event_name").getAsString(); } }
ScoreNotification extends BaseNotification<ScoreNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("match")) { throw new JsonParseException("Notification data does not contain 'match"); } JsonObject match = jsonData.get("match").getAsJsonObject(); this.match = gson.fromJson(match, Match.class); this.matchKey = this.match.getKey(); this.eventKey = MatchHelper.getEventKeyFromMatchKey(matchKey); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name"); } eventName = jsonData.get("event_name").getAsString(); } ScoreNotification(String messageData, MatchWriter writer, MatchRenderer matchRenderer); }
ScoreNotification extends BaseNotification<ScoreNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("match")) { throw new JsonParseException("Notification data does not contain 'match"); } JsonObject match = jsonData.get("match").getAsJsonObject(); this.match = gson.fromJson(match, Match.class); this.matchKey = this.match.getKey(); this.eventKey = MatchHelper.getEventKeyFromMatchKey(matchKey); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name"); } eventName = jsonData.get("event_name").getAsString(); } ScoreNotification(String messageData, MatchWriter writer, MatchRenderer matchRenderer); String getEventName(); String getEventKey(); String getMatchKey(); Match getMatch(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override void updateDataLocally(); @Override Intent getIntent(Context c); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override ScoreNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid); }
ScoreNotification extends BaseNotification<ScoreNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("match")) { throw new JsonParseException("Notification data does not contain 'match"); } JsonObject match = jsonData.get("match").getAsJsonObject(); this.match = gson.fromJson(match, Match.class); this.matchKey = this.match.getKey(); this.eventKey = MatchHelper.getEventKeyFromMatchKey(matchKey); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name"); } eventName = jsonData.get("event_name").getAsString(); } ScoreNotification(String messageData, MatchWriter writer, MatchRenderer matchRenderer); String getEventName(); String getEventKey(); String getMatchKey(); Match getMatch(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override void updateDataLocally(); @Override Intent getIntent(Context c); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override ScoreNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid);  }