HaloEvent implements Parcelable { public static String serialize(@NonNull HaloEvent haloEvent, @NonNull Parser.Factory parser) throws HaloParsingException { AssertionUtils.notNull(haloEvent, "haloEvent"); AssertionUtils.notNull(parser, "parser"); try { return ((Parser<HaloEvent, String>) parser.serialize(HaloEvent.class)).convert(haloEvent); } catch (IOException e) { throw new HaloParsingException("Error while serializing the haloEvent", e); } } protected  HaloEvent(); private  HaloEvent(@NonNull Builder builder); protected  HaloEvent(Parcel in); @NonNull @Api(2.33) String getType(); @NonNull @Api(2.33) String getCoord(); @NonNull @Api(2.33) JSONObject getExtra(); @NonNull @Api(2.33) String getIp(); @NonNull @Api(2.33) String getCategory(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @NonNull @Api(2.33) static Builder builder(); static String serialize(@NonNull HaloEvent haloEvent, @NonNull Parser.Factory parser); static final String OPEN_APPLICATION; static final String REGISTER_DEVICE; static final String UPDATE_DEVICE; static final String REGISTER_LOCATION; static final Creator<HaloEvent> CREATOR; }
@Test public void thatCanSerializeObject() throws JSONException, HaloParsingException { HaloEvent event = givenAHaloEvent(); String objectSerialized = HaloEvent.serialize(event, mHalo.framework().parser()); JSONObject jsonObject = new JSONObject(objectSerialized); assertThat(jsonObject.get("coord")).isEqualTo("3,3"); }