### Question:
KnowsLastCompletedBuildDetails implements Feature<KnowsLastCompletedBuildDetails.LastCompletedBuild> { @Override public KnowsLastCompletedBuildDetails of(JobView jobView) { this.job = jobView; return this; } KnowsLastCompletedBuildDetails(/* config */); @Override KnowsLastCompletedBuildDetails of(JobView jobView); @Override LastCompletedBuild asJson();  }### Answer:
@Test public void should_know_the_url_of_the_last_build() { view = a(jobView().which(new KnowsLastCompletedBuildDetails()).of( a(job().whereTheLast(build().hasNumber(22)))) .with(locatedAt("job/project-name"))); assertThat(lastCompletedBuildOf(view).url(), is("job/project-name/22/")); }
@Test public void should_know_how_long_the_last_build_took_once_its_finished() throws Exception { view = a(jobView().which(new KnowsLastCompletedBuildDetails()).of( a(job().whereTheLast(build().finishedWith(SUCCESS).and().took(3))))); assertThat(lastCompletedBuildOf(view).duration(), is("3m 0s")); }
@Test public void should_know_how_long_since_the_last_build_happened() throws Exception { String tenMinutesInMilliseconds = String.format("%d", 10 * 60 * 1000); view = a(jobView().which(new KnowsLastCompletedBuildDetails()).of( a(job().whereTheLast(build().startedAt("18:05:00").and().took(5)))) .assuming(currentTime().is("18:20:00"))); assertThat(lastCompletedBuildOf(view).timeElapsedSince(), is(tenMinutesInMilliseconds)); }
@Test public void should_know_current_build_number() { view = a(jobView().which(new KnowsLastCompletedBuildDetails()).of( a(job().whereTheLast(build().hasNumber(5))))); assertThat(lastCompletedBuildOf(view).name(), is("#5")); }
@Test public void should_use_build_name_if_its_known() { view = a(jobView().which(new KnowsLastCompletedBuildDetails()).of( a(job().whereTheLast(build().hasName("1.3.4+build.15"))))); assertThat(lastCompletedBuildOf(view).name(), is("1.3.4+build.15")); }