@Test @SmallTest public void fromBundle_invalidBundle_throwsIllegalArgumentException() { Bundle bundle = new Bundle(); bundle.putString(APP_STATE_KEY, KEY); bundle.putString(APP_STATE_MESSAGE, MESSAGE); bundle.putString(APP_STATE_DATA, DATA); try { ReceivedKeyedAppState.fromBundle(bundle, PACKAGE_NAME, TIMESTAMP); fail(); } catch (IllegalArgumentException expected) { } }
static ReceivedKeyedAppState fromBundle(Bundle bundle, String packageName, long timestamp) { if (!KeyedAppState.isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return builder() .setPackageName(packageName) .setTimestamp(timestamp) .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); }
ReceivedKeyedAppState { static ReceivedKeyedAppState fromBundle(Bundle bundle, String packageName, long timestamp) { if (!KeyedAppState.isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return builder() .setPackageName(packageName) .setTimestamp(timestamp) .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } }
ReceivedKeyedAppState { static ReceivedKeyedAppState fromBundle(Bundle bundle, String packageName, long timestamp) { if (!KeyedAppState.isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return builder() .setPackageName(packageName) .setTimestamp(timestamp) .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } ReceivedKeyedAppState(); }
ReceivedKeyedAppState { static ReceivedKeyedAppState fromBundle(Bundle bundle, String packageName, long timestamp) { if (!KeyedAppState.isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return builder() .setPackageName(packageName) .setTimestamp(timestamp) .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } ReceivedKeyedAppState(); @NonNull static ReceivedKeyedAppStateBuilder builder(); @NonNull abstract String getPackageName(); abstract long getTimestamp(); @NonNull abstract String getKey(); abstract int getSeverity(); @Nullable abstract String getMessage(); @Nullable abstract String getData(); }
ReceivedKeyedAppState { static ReceivedKeyedAppState fromBundle(Bundle bundle, String packageName, long timestamp) { if (!KeyedAppState.isValid(bundle)) { throw new IllegalArgumentException("Bundle is not valid"); } return builder() .setPackageName(packageName) .setTimestamp(timestamp) .setKey(bundle.getString(APP_STATE_KEY)) .setSeverity(bundle.getInt(APP_STATE_SEVERITY)) .setMessage(bundle.getString(APP_STATE_MESSAGE)) .setData(bundle.getString(APP_STATE_DATA)) .build(); } ReceivedKeyedAppState(); @NonNull static ReceivedKeyedAppStateBuilder builder(); @NonNull abstract String getPackageName(); abstract long getTimestamp(); @NonNull abstract String getKey(); abstract int getSeverity(); @Nullable abstract String getMessage(); @Nullable abstract String getData();  }