### Question:
CanBeClaimed implements Feature { @Override public CanBeClaimed of(JobView jobView) { this.job = jobView; return this; }  @Override CanBeClaimed of(JobView jobView); @Override Claim asJson();  }### Answer:
@Test public void should_know_if_a_failing_build_has_been_claimed() throws Exception { String ourPotentialHero = "Adam", theReason = "I broke it, sorry, fixing now"; job = a(jobView().which(new CanBeClaimed()).of( a(job().whereTheLast(build().finishedWith(FAILURE).and().wasClaimedBy(ourPotentialHero, theReason))))); assertThat(serialisedClaimOf(job).author(), is(ourPotentialHero)); assertThat(serialisedClaimOf(job).reason(), is(theReason)); }
@Test public void should_know_if_a_failing_build_has_not_been_claimed() throws Exception { job = a(jobView().which(new CanBeClaimed()).of( a(job().whereTheLast(build().finishedWith(FAILURE))))); assertThat(serialisedClaimOf(job), is(nullValue())); }
@Test public void should_complain_if_the_build_was_not_claimable() throws Exception { job = a(jobView().of( a(job().withName("my-project").whereTheLast(build().finishedWith(FAILURE))))); thrown.expectMessage("CanBeClaimed is not a feature of this project: 'my-project'"); job.which(CanBeClaimed.class); }