Author: nrannou Date: 2009-08-21 15:46:11 +0200 (Fri, 21 Aug 2009) New Revision: 2739 Modified: trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java Log: modification des tests Modified: trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java =================================================================== --- trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java 2009-08-20 15:12:21 UTC (rev 2738) +++ trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreator.java 2009-08-21 13:46:11 UTC (rev 2739) @@ -24,5 +24,18 @@ * @version $Id$ */ public interface PollDTOCreator { + + /** + * Création d'un sondage aléatoire. + * + * @return le sondage + */ public PollDTO createPoll(); + + /** + * Création d'un sondage de test. + * + * @return le sondage + */ + public PollDTO createTestPoll(); } \ No newline at end of file Modified: trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java =================================================================== --- trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java 2009-08-20 15:12:21 UTC (rev 2738) +++ trunk/pollen-votecounting/src/test/java/org/chorem/pollen/votecounting/business/services/PollDTOCreatorVoteCounting.java 2009-08-21 13:46:11 UTC (rev 2739) @@ -61,7 +61,7 @@ + "typeVoteCounting=" + this.typeCount); } - PollDTO poll = new PollDTO("poll1"); + PollDTO poll = new PollDTO("RandomPoll"); poll.setMaxChoiceNb(this.maxChoiceNb); poll.setPollType(PollType.FREE); poll.setVoteCounting(this.typeCount); @@ -72,7 +72,7 @@ private List<PollChoiceDTO> createChoices() { if (log.isDebugEnabled()) { - log.debug("Création des choix : " + this.maxChoice); + log.debug("Création des choix : "); } List<PollChoiceDTO> choices = new ArrayList<PollChoiceDTO>(); for (int i = 1; i <= this.maxChoice; i++) { @@ -180,4 +180,64 @@ return 1; } } + + @Override + public PollDTO createTestPoll() { + if (log.isDebugEnabled()) { + log.debug("Création du sondage : typeVoteCounting=" + typeCount); + } + + PollDTO poll = new PollDTO("TestPoll"); + poll.setMaxChoiceNb(3); + poll.setPollType(PollType.FREE); + poll.setVoteCounting(typeCount); + poll.setChoices(createTestChoices()); + poll.setVotingGroups(createTestGroups()); + return poll; + } + + private List<PollChoiceDTO> createTestChoices() { + int nbChoices = 3; + if (log.isDebugEnabled()) { + log.debug("Création des choix : " + nbChoices); + } + List<PollChoiceDTO> choices = new ArrayList<PollChoiceDTO>(); + for (int i = 1; i <= nbChoices; i++) { + choices.add(new PollChoiceDTO(String.valueOf(i))); + if (log.isDebugEnabled()) { + log.debug("Choice : id=" + i); + } + } + return choices; + } + + private List<VotingGroupDTO> createTestGroups() { + List<VotingGroupDTO> groups = new ArrayList<VotingGroupDTO>(); + if (log.isDebugEnabled()) { + log.debug("Création des groupes : "); + } + + //// groupe 1 : poids 1 + VotingGroupDTO group = new VotingGroupDTO("group1", 1.0); + List<VotingPersonDTO> persons = new ArrayList<VotingPersonDTO>(); + + // person 1 : poids 1 + VotingPersonDTO person1 = new VotingPersonDTO("person1", 1.0); + List<VoteToChoiceDTO> choices1 = new ArrayList<VoteToChoiceDTO>(); + choices1.add(new VoteToChoiceDTO("1", 1.0)); + person1.setChoices(choices1); + persons.add(person1); + + // person 2 : poids 2 + VotingPersonDTO person2 = new VotingPersonDTO("person2", 2.0); + List<VoteToChoiceDTO> choices2 = new ArrayList<VoteToChoiceDTO>(); + choices2.add(new VoteToChoiceDTO("2", 1.0)); + person2.setChoices(choices2); + persons.add(person2); + + group.setVotingPersons(persons); + groups.add(group); + + return groups; + } } \ No newline at end of file