OrpheusApi { @NonNull public static Bundleable materializeBundle(Bundle b) throws Exception { Class cls = Class.forName(b.getString("clz")); return materializeBundle(cls, b); }  @NonNull static Bundleable materializeBundle(Bundle b); @NonNull @SuppressWarnings("unchecked") static T materializeBundle(Class<T> cls, Bundle b); static final String ACTION_LIBRARY_SERVICE; static final String PERMISSION_BIND_LIBRARY_SERVICE; static final String EXTRA_LIBRARY_ID; static final String EXTRA_LIBRARY_INFO; static final String EXTRA_WANT_LIGHT_THEME; static final int API_VERSION; static final int API_010; static final int API_020; }
@Test public void testMaterilizeBundleWorks() throws Exception { Folder f = Folder.builder().setIdentity("1").setName("Folder1").build(); Bundle b = f.toBundle(); Parcel p = Parcel.obtain(); b.writeToParcel(p, 0); p.setDataPosition(0); Bundle b1 = p.readBundle(); Bundleable b2 = OrpheusApi.materializeBundle(b1); Assert.assertTrue((b2 instanceof Folder)); assertThat((Folder) b2).isEqualTo(f); Folder f2 = OrpheusApi.materializeBundle(Folder.class, b); assertThat(f).isEqualTo(f2); }
@Test(expected = IllegalArgumentException.class) public void ensureMalformedBundleThrows() throws Exception { Bundle b = Folder.builder().setIdentity("1").setName("Folder1").build().toBundle(); b.putString("clz", null); Folder f = OrpheusApi.materializeBundle(Folder.class, b); }