### Question:
HasBadgesBadgePlugin implements Feature<HasBadgesBadgePlugin.Badges> { @Override public HasBadgesBadgePlugin of(JobView jobView) { this.job = jobView; return this; }  @Override HasBadgesBadgePlugin of(JobView jobView); @Override Badges asJson();  }### Answer:
@Test public void should_support_job_without_badges() throws Exception { job = a(jobView().which(new HasBadgesBadgePlugin()).of( a(job()))); assertThat(serialisedBadgesDetailsOf(job), is(nullValue())); }
@Test public void should_convert_badges_to_json() throws Exception { job = a(jobView().which(new HasBadgesBadgePlugin()).of( a(job().whereTheLast(build().hasBadgesBadgePlugin(badgePluginBadge().withText("badge1"), badgePluginBadge().withText("badge2")))))); assertThat(serialisedBadgesDetailsOf(job).value(), hasSize(2)); }
@Test public void should_ignore_badges_with_icon() throws Exception { job = a(jobView().which(new HasBadgesBadgePlugin()).of( a(job().whereTheLast(build().hasBadgesBadgePlugin(badgePluginBadge().withIcon("icon.gif", "badge1"), badgePluginBadge().withText("badge2")))))); assertThat(serialisedBadgesDetailsOf(job).value(), hasSize(1)); }
@Test public void should_report_badges_from_latest_build() throws Exception { job = a(jobView().which(new HasBadgesBadgePlugin()).of( a(job().whereTheLast(build().isStillBuilding().hasBadgesBadgePlugin(badgePluginBadge().withText("badge1"))) .andThePrevious(build().hasBadgesBadgePlugin(badgePluginBadge().withText("badge1"), badgePluginBadge().withText("badge2")))))); assertThat(serialisedBadgesDetailsOf(job).value(), hasSize(1)); }