Entry implements Serializable { public String getUrl() { return url; } Entry(@NonNull String url); String getUrl(); void setUrl(String url); int getRetryCount(); void incrementRetryCount(); abstract String getKey(); @Override boolean equals(Object obj); @Override String toString(); static final String TYPE_GOAL; static final String TYPE_CAMPAIGN; }
@Test public void parcelTest() throws IOException, ClassNotFoundException { String campaignUrl = "www.wingify.com/campaign"; String goalUrl = "www.wingify.com/goal"; int campaignId = 100; int variationId = 150; int goalId = 200; CampaignEntry campaignEntry = new CampaignEntry(campaignUrl, campaignId, variationId); GoalEntry goalEntry = new GoalEntry(goalUrl, campaignId, variationId, goalId); byte[] campaignParcel = Serializer.marshall(campaignEntry); byte[] goalParcel = Serializer.marshall(goalEntry); CampaignEntry entryCampaign = (CampaignEntry) Serializer.unmarshall(campaignParcel, Entry.class); GoalEntry entryGoal = (GoalEntry) Serializer.unmarshall(goalParcel, Entry.class); Assert.assertEquals(campaignId, entryCampaign.getCampaignId()); Assert.assertEquals(variationId, entryCampaign.getVariationId()); Assert.assertEquals(campaignUrl, entryCampaign.getUrl()); Assert.assertEquals(campaignId, entryGoal.getCampaignId()); Assert.assertEquals(variationId, entryGoal.getVariationId()); Assert.assertEquals(goalId, entryGoal.getGoalId()); Assert.assertEquals(goalUrl, entryGoal.getUrl()); }