Skip to content

Instantly share code, notes, and snippets.

@beyondxscratch
Created August 10, 2020 00:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beyondxscratch/d6d844e819c5b99d8590069b7cbb2d96 to your computer and use it in GitHub Desktop.
Save beyondxscratch/d6d844e819c5b99d8590069b7cbb2d96 to your computer and use it in GitHub Desktop.
@Test
fun `should retrieve talks`() {
val mockedTalk = mock(Talk::class.java)
given(mockedTalk.format).willReturn(IGNITE)
given(mockedTalk.duration).willReturn(Duration.ofHours(1))
// this resulted Talk Object is invalid, the source of truth is the duration
// but here with mockito we overload the format computation logic
given(searchTalks.forTopics(anySet())).willReturn(setOf(mockedTalk))
val recommendTalks = TalksAdvisor(searchTalks, recommendations, profiles)
val recommendation = recommendTalks.satisfying(GuestCriteria(setOf(), setOf(IGNITE)))
assertThat(recommendation.talks).containsExactly(mockedTalk) //it should have been filtered
assertThat(recommendation.talks.first().format).isEqualTo(IGNITE)
assertThat(recommendation.talks.first().duration).isEqualTo(Duration.ofHours(1))
//the test is incorrect but will still pass
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment