Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@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
You can’t perform that action at this time.