Subversion Repositories eFlore/Applications.del

Rev

Rev 1098 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1098 Rev 1152
Line 2... Line 2...
2
 
2
 
Line 3... Line 3...
3
import static org.junit.Assert.assertTrue;
3
import static org.junit.Assert.assertTrue;
4
 
4
 
-
 
5
import java.util.ArrayList;
5
import java.util.ArrayList;
6
import java.util.Date;
Line 6... Line 7...
6
import java.util.Date;
7
import java.util.Iterator;
7
import java.util.List;
8
import java.util.List;
8
 
9
 
Line 17... Line 18...
17
public class CalculVoteDeterminationServiceTest {
18
public class CalculVoteDeterminationServiceTest {
Line 18... Line 19...
18
 
19
 
19
	@Test
20
	@Test
Line -... Line 21...
-
 
21
	public void testCalculerVoteDetermination() {
-
 
22
 
20
	public void testCalculerVoteDetermination() {
23
		Observation obs = new Observation();
21
 
24
		
22
		VoteDetermination voteDetermination = new VoteDetermination();
25
		VoteDetermination voteDetermination = new VoteDetermination();
23
		voteDetermination.setVote(1);
26
		voteDetermination.setVote(1);
Line 24... Line 27...
24
		voteDetermination.setDate(new Date());
27
		voteDetermination.setDate(new Date());
25
		voteDetermination.setContributeur("benjamin");
28
		voteDetermination.setContributeur("benjamin");
26
 
29
 
27
		PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
30
		PropositionDetermination propositionDetermination = new PropositionDetermination(obs);
28
		propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
31
		propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
-
 
32
		propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
Line 29... Line 33...
29
		propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
33
		propositionDetermination.setId("1");
30
		propositionDetermination.setId("1");
34
		propositionDetermination.ajouterVoteDetermination(voteDetermination);
Line 31... Line 35...
31
		propositionDetermination.ajouterVoteDetermination(voteDetermination);
35
		obs.ajouterPropositionDetermination(propositionDetermination);
Line 32... Line 36...
32
 
36
 
Line 33... Line 37...
33
		MoyenneVote moyenneVote = CalculVoteDeterminationService
37
		MoyenneVote moyenneVote = CalculVoteDeterminationService
34
				.calculerVoteDetermination(propositionDetermination);
38
				.calculerVoteDetermination(propositionDetermination);
-
 
39
 
-
 
40
		assertTrue(moyenneVote.getScore() == 100);
Line 35... Line 41...
35
 
41
 
36
		assertTrue(moyenneVote.getScore() == 100);
42
	}
Line 37... Line 43...
37
 
43
	
Line 61... Line 67...
61
		voteDetermination3.setVote(0);
67
		voteDetermination3.setVote(0);
62
		voteDetermination3.setDate(new Date());
68
		voteDetermination3.setDate(new Date());
63
		voteDetermination3.setContributeur(cAnon1.getId());
69
		voteDetermination3.setContributeur(cAnon1.getId());
64
		voteDetermination3.setAuteur(cAnon1);
70
		voteDetermination3.setAuteur(cAnon1);
Line 65... Line 71...
65
 
71
 
66
		PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
72
		PropositionDetermination propositionDetermination = new PropositionDetermination(obs);
67
		propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
73
		propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
68
		propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
74
		propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
69
		propositionDetermination.setId("1");
75
		propositionDetermination.setId("1");
70
		propositionDetermination.ajouterVoteDetermination(voteDetermination2);
76
		propositionDetermination.ajouterVoteDetermination(voteDetermination2);
Line -... Line 77...
-
 
77
		propositionDetermination.ajouterVoteDetermination(voteDetermination3);
-
 
78
		
71
		propositionDetermination.ajouterVoteDetermination(voteDetermination3);
79
		obs.ajouterPropositionDetermination(propositionDetermination);
72
		
80
		
73
		PropositionDetermination propositionDetermination2 = new PropositionDetermination(new Observation());
81
		PropositionDetermination propositionDetermination2 = new PropositionDetermination(obs);
74
		propositionDetermination2.setEspece("Iris urticans");
82
		propositionDetermination2.setEspece("Iris urticans");
75
		propositionDetermination2.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
83
		propositionDetermination2.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
76
		propositionDetermination2.setId("2");
84
		propositionDetermination2.setId("2");
77
		propositionDetermination2.ajouterVoteDetermination(voteDetermination1);
85
		propositionDetermination2.ajouterVoteDetermination(voteDetermination1);
Line -... Line 86...
-
 
86
		propositionDetermination2.ajouterVoteDetermination(voteDetermination2);
-
 
87
		propositionDetermination2.ajouterVoteDetermination(voteDetermination3);
78
		propositionDetermination2.ajouterVoteDetermination(voteDetermination2);
88
		
79
		propositionDetermination2.ajouterVoteDetermination(voteDetermination3);
89
		obs.ajouterPropositionDetermination(propositionDetermination2);
80
		
90
		
Line 81... Line 91...
81
		List<PropositionDetermination> listePropositions = new ArrayList<PropositionDetermination>();
91
		List<PropositionDetermination> listePropositions = new ArrayList<PropositionDetermination>();
82
		listePropositions.add(propositionDetermination2);
92
		listePropositions.add(propositionDetermination2);
-
 
93
		listePropositions.add(propositionDetermination);
-
 
94
 
-
 
95
		List<MoyenneVote> listeMoyenneVote = CalculVoteDeterminationService
-
 
96
				.calculerVoteDeterminationPlusPopulaire(listePropositions);
-
 
97
		
-
 
98
		for (Iterator iterator = listeMoyenneVote.iterator(); iterator
Line 83... Line 99...
83
		listePropositions.add(propositionDetermination);
99
				.hasNext();) {
84
 
100
			MoyenneVote moyenneVote = (MoyenneVote) iterator.next();
85
		List<MoyenneVote> listeMoyenneVote = CalculVoteDeterminationService
101
			System.out.println(moyenneVote.getScore());