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 |
|
1408 |
aurelien |
38 |
Observation obs = new Observation();
|
|
|
39 |
PropositionDetermination propositionDetermination = new PropositionDetermination(obs);
|
275 |
aurelien |
40 |
propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
|
882 |
aurelien |
41 |
propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
|
275 |
aurelien |
42 |
propositionDetermination.setId("1");
|
|
|
43 |
propositionDetermination.ajouterVoteDetermination(voteDetermination);
|
1408 |
aurelien |
44 |
propositionDetermination.setObservation(obs);
|
|
|
45 |
obs.ajouterPropositionDetermination(propositionDetermination);
|
959 |
benjamin |
46 |
|
275 |
aurelien |
47 |
MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
|
|
48 |
barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
|
|
|
49 |
}
|
959 |
benjamin |
50 |
|
275 |
aurelien |
51 |
@Test
|
|
|
52 |
public void testVoter() {
|
|
|
53 |
assertEquals("Iris lutescens subsp. lutescens", barreRepartitionVotePresenteur.getMoyenneVote().getIntituleAssocie());
|
|
|
54 |
assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
|
|
55 |
barreRepartitionVotePresenteur.voter(false);
|
959 |
benjamin |
56 |
assertEquals(100, barreRepartitionVotePresenteur.getMoyenneVote().getScore());
|
275 |
aurelien |
57 |
}
|
|
|
58 |
|
|
|
59 |
}
|