644 |
aurelien |
1 |
package org.tela_botanica.del.test.composants.votes;
|
275 |
aurelien |
2 |
|
959 |
benjamin |
3 |
import static org.junit.Assert.assertEquals;
|
307 |
aurelien |
4 |
import static org.mockito.Mockito.mock;
|
275 |
aurelien |
5 |
|
|
|
6 |
import java.util.Date;
|
|
|
7 |
|
|
|
8 |
import org.junit.Before;
|
|
|
9 |
import org.junit.Test;
|
534 |
benjamin |
10 |
import org.mockito.Mockito;
|
637 |
aurelien |
11 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur;
|
|
|
12 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur.Vue;
|
690 |
gduche |
13 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
275 |
aurelien |
14 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
838 |
aurelien |
15 |
import org.tela_botanica.del.client.modeles.Observation;
|
275 |
aurelien |
16 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
|
|
17 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
|
|
18 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
959 |
benjamin |
19 |
import org.tela_botanica.del.client.services.rest.VoteDeterminationService;
|
275 |
aurelien |
20 |
|
|
|
21 |
public class BarreRepartitionVotePresenteurTest {
|
|
|
22 |
|
|
|
23 |
private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
|
307 |
aurelien |
24 |
private BarreRepartitionVotePresenteur.Vue vue;
|
959 |
benjamin |
25 |
|
275 |
aurelien |
26 |
@Before
|
|
|
27 |
public void setUp() {
|
959 |
benjamin |
28 |
|
534 |
benjamin |
29 |
vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
|
959 |
benjamin |
30 |
VoteDeterminationService voteDeterminationService = Mockito.mock(VoteDeterminationService.class);
|
|
|
31 |
barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue, voteDeterminationService);
|
|
|
32 |
|
275 |
aurelien |
33 |
VoteDetermination voteDetermination = new VoteDetermination();
|
|
|
34 |
voteDetermination.setVote(1);
|
|
|
35 |
voteDetermination.setDate(new Date());
|
|
|
36 |
voteDetermination.setContributeur("benjamin");
|
|
|
37 |
|
838 |
aurelien |
38 |
PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
|
275 |
aurelien |
39 |
propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
|
882 |
aurelien |
40 |
propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
|
275 |
aurelien |
41 |
propositionDetermination.setId("1");
|
|
|
42 |
propositionDetermination.ajouterVoteDetermination(voteDetermination);
|
959 |
benjamin |
43 |
|
275 |
aurelien |
44 |
MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
|
|
45 |
barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
|
|
|
46 |
}
|
959 |
benjamin |
47 |
|
275 |
aurelien |
48 |
@Test
|
|
|
49 |
public void testVoter() {
|
|
|
50 |
assertEquals("Iris lutescens subsp. lutescens", barreRepartitionVotePresenteur.getMoyenneVote().getIntituleAssocie());
|
|
|
51 |
assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
|
|
52 |
barreRepartitionVotePresenteur.voter(false);
|
959 |
benjamin |
53 |
assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
275 |
aurelien |
54 |
}
|
|
|
55 |
|
|
|
56 |
}
|