### Question:
ParseAnalytics { static String getPushHashFromIntent(Intent intent) { String pushData = null; if (intent != null && intent.getExtras() != null) { pushData = intent.getExtras().getString(ParsePushBroadcastReceiver.KEY_PUSH_DATA); } if (pushData == null) { return null; } String pushHash = null; try { JSONObject payload = new JSONObject(pushData); pushHash = payload.optString("push_hash"); } catch (JSONException e) { PLog.e(TAG, "Failed to parse push data: " + e.getMessage()); } return pushHash; }  static Task<Void> trackAppOpenedInBackground(Intent intent); @Deprecated static void trackAppOpened(Intent intent); static void trackAppOpenedInBackground(Intent intent, SaveCallback callback); @Deprecated static void trackEvent(String name); static void trackEventInBackground(String name, SaveCallback callback); @Deprecated static void trackEvent(String name, Map<String, String> dimensions); static void trackEventInBackground(String name, Map<String, String> dimensions, SaveCallback callback); static Task<Void> trackEventInBackground(String name); static Task<Void> trackEventInBackground(final String name,
      Map<String, String> dimensions);  }### Answer:
@Test public void testGetPushHashFromIntentNullIntent() throws Exception { String pushHash = ParseAnalytics.getPushHashFromIntent(null); assertEquals(null, pushHash); }
@Test public void testGetPushHashFromIntentEmptyIntent() throws Exception { Intent intent = new Intent(); Bundle bundle = new Bundle(); JSONObject json = new JSONObject(); json.put("push_hash_wrong_key", "test"); bundle.putString("data_wrong_key", json.toString()); intent.putExtras(bundle); String pushHash = ParseAnalytics.getPushHashFromIntent(intent); assertEquals(null, pushHash); }
@Test public void testGetPushHashFromIntentEmptyPushHashIntent() throws Exception { Intent intent = new Intent(); Bundle bundle = new Bundle(); JSONObject json = new JSONObject(); json.put("push_hash_wrong_key", "test"); bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, json.toString()); intent.putExtras(bundle); String pushHash = ParseAnalytics.getPushHashFromIntent(intent); assertEquals("", pushHash); }
@Test public void testGetPushHashFromIntentWrongPushHashIntent() throws Exception { Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putString(ParsePushBroadcastReceiver.KEY_PUSH_DATA, "error_data"); intent.putExtras(bundle); String pushHash = ParseAnalytics.getPushHashFromIntent(intent); assertEquals(null, pushHash); }
@Test public void testGetPushHashFromIntentNormalIntent() throws Exception { Intent intent = makeIntentWithParseData("test"); String pushHash = ParseAnalytics.getPushHashFromIntent(intent); assertEquals("test", pushHash); }