private DetailsQuestion laRechercheRetourne() { DetailsQuestion test = new DetailsQuestion(); UUID uuid = UUID.randomUUID(); test.setId(uuid.toString()); when(this.recherche.detailsDe(uuid)).thenReturn(test); return test; }
@Test public void peutAjouterUneRéponse() { DetailsQuestion detailsQuestion = laRechercheRetourne(); initialiseRessource(detailsQuestion); Form formulaire = new Form(); formulaire.add("libelle", "Une réponse"); formulaire.add("correcte", "checked"); questionRessource.ajouteRéponse(formulaire); ArgumentCaptor<AjoutReponseMessage> captor = ArgumentCaptor.forClass(AjoutReponseMessage.class); verify(busCommande).envoie(captor.capture()); AjoutReponseMessage message = captor.getValue(); assertThat(message.idQuestion).isEqualTo(UUID.fromString(detailsQuestion.getId())); assertThat(message.correcte).isTrue(); assertThat(message.libellé).isEqualTo("Une réponse"); }
private void initialiseRessource(DetailsQuestion detailsQuestion) { RessourceHelper.initialise(questionRessource).avec("id", detailsQuestion.getId()); }