InfoItem implements Parcelable { public InfoType getType() { if (getUrlAndroid() != null) { return InfoType.EXTERNAL_APP; } else if (getHtml() != null) { return InfoType.INTERNAL; } else if (getSubContent() != null) { return InfoType.SUBLIST; } else { return InfoType.EXTERNAL_LINK; } } InfoItem(); protected  InfoItem(Parcel in); String getTitle(); void setTitle(String title); String getImage(); void setImage(String image); String getHtml(); void setHtml(String html); String getUrl(); void setUrl(String url); String getUrlAndroid(); void setUrlAndroid(String urlAndroid); List<InfoItem> getSubContent(); void setSubContent(List<InfoItem> subContent); InfoType getType(); @Override int describeContents(); @Override void writeToParcel(Parcel dest, int flags); @Override boolean equals(Object o); @Override int hashCode(); static final Creator<InfoItem> CREATOR; }
@Test public void getType() { InfoItem infoItem = generate(InfoItem.class, "urlAndroid", "html", "subContent"); assertEquals(InfoType.EXTERNAL_LINK, infoItem.getType()); InfoItem infoItem1 = generate(InfoItem.class, "url", "html", "subContent"); assertEquals(InfoType.EXTERNAL_APP, infoItem1.getType()); InfoItem infoItem2 = generate(InfoItem.class, "url", "urlAndroid", "subContent"); assertEquals(InfoType.INTERNAL, infoItem2.getType()); InfoItem infoItem3 = generate(InfoItem.class, "url", "urlAndroid", "html"); assertEquals(InfoType.SUBLIST, infoItem3.getType()); }