@Test(expected = JsonParseException.class) public void testNoEventKey() { mData.remove("event_key"); mNotification = new CompLevelStartingNotification(mData.toString()); mNotification.parseMessageData(); }
@Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name'"); } eventName = jsonData.get("event_name").getAsString(); if (!jsonData.has("event_key")) { throw new JsonParseException("Notification data does not contain 'event_key'"); } eventKey = jsonData.get("event_key").getAsString(); if (!jsonData.has("comp_level")) { throw new JsonParseException("Notification data does not contain 'comp_level'"); } compLevelAbbrev = jsonData.get("comp_level").getAsString(); scheduledTime = jsonData.get("scheduled_time"); }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name'"); } eventName = jsonData.get("event_name").getAsString(); if (!jsonData.has("event_key")) { throw new JsonParseException("Notification data does not contain 'event_key'"); } eventKey = jsonData.get("event_key").getAsString(); if (!jsonData.has("comp_level")) { throw new JsonParseException("Notification data does not contain 'comp_level'"); } compLevelAbbrev = jsonData.get("comp_level").getAsString(); scheduledTime = jsonData.get("scheduled_time"); } }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name'"); } eventName = jsonData.get("event_name").getAsString(); if (!jsonData.has("event_key")) { throw new JsonParseException("Notification data does not contain 'event_key'"); } eventKey = jsonData.get("event_key").getAsString(); if (!jsonData.has("comp_level")) { throw new JsonParseException("Notification data does not contain 'comp_level'"); } compLevelAbbrev = jsonData.get("comp_level").getAsString(); scheduledTime = jsonData.get("scheduled_time"); } CompLevelStartingNotification(String messageData); }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name'"); } eventName = jsonData.get("event_name").getAsString(); if (!jsonData.has("event_key")) { throw new JsonParseException("Notification data does not contain 'event_key'"); } eventKey = jsonData.get("event_key").getAsString(); if (!jsonData.has("comp_level")) { throw new JsonParseException("Notification data does not contain 'comp_level'"); } compLevelAbbrev = jsonData.get("comp_level").getAsString(); scheduledTime = jsonData.get("scheduled_time"); } CompLevelStartingNotification(String messageData); @Nullable JsonElement getScheduledTime(); String getEventName(); String getEventKey(); String getCompLevelAbbrev(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override Intent getIntent(Context c); @Override void updateDataLocally(); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override CompLevelStartingNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid); }
CompLevelStartingNotification extends BaseNotification<CompLevelStartingNotificationViewModel> { @Override public void parseMessageData() throws JsonParseException { JsonObject jsonData = JSONHelper.getasJsonObject(messageData); if (!jsonData.has("event_name")) { throw new JsonParseException("Notification data does not contain 'event_name'"); } eventName = jsonData.get("event_name").getAsString(); if (!jsonData.has("event_key")) { throw new JsonParseException("Notification data does not contain 'event_key'"); } eventKey = jsonData.get("event_key").getAsString(); if (!jsonData.has("comp_level")) { throw new JsonParseException("Notification data does not contain 'comp_level'"); } compLevelAbbrev = jsonData.get("comp_level").getAsString(); scheduledTime = jsonData.get("scheduled_time"); } CompLevelStartingNotification(String messageData); @Nullable JsonElement getScheduledTime(); String getEventName(); String getEventKey(); String getCompLevelAbbrev(); @Override void parseMessageData(); @Override Notification buildNotification(Context context, FollowsChecker followsChecker); @Override Intent getIntent(Context c); @Override void updateDataLocally(); @Override int getNotificationId(); @Override View getView(Context c, LayoutInflater inflater, View convertView); @Nullable @Override CompLevelStartingNotificationViewModel renderToViewModel(Context context, @Nullable Void aVoid);  }