Line 1... |
Line 1... |
1 |
package org.tela_botanica.del.test.composants.votes;
|
1 |
package org.tela_botanica.del.test.composants.votes;
|
Line 2... |
Line 2... |
2 |
|
2 |
|
3 |
import static org.junit.Assert.*;
|
3 |
import static org.junit.Assert.assertEquals;
|
Line 4... |
Line 4... |
4 |
import static org.mockito.Mockito.mock;
|
4 |
import static org.mockito.Mockito.mock;
|
Line 5... |
Line 5... |
5 |
|
5 |
|
6 |
import java.util.Date;
|
6 |
import java.util.Date;
|
7 |
|
- |
|
8 |
import org.junit.Before;
|
7 |
|
9 |
import org.junit.Test;
|
8 |
import org.junit.Before;
|
10 |
import org.mockito.Mock;
|
9 |
import org.junit.Test;
|
11 |
import org.mockito.Mockito;
|
10 |
import org.mockito.Mockito;
|
12 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur;
|
11 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur;
|
13 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur.Vue;
|
12 |
import org.tela_botanica.del.client.composants.votes.barrerepartition.BarreRepartitionVotePresenteur.Vue;
|
14 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
13 |
import org.tela_botanica.del.client.modeles.Contributeur;
|
15 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
14 |
import org.tela_botanica.del.client.modeles.MoyenneVote;
|
16 |
import org.tela_botanica.del.client.modeles.Observation;
|
15 |
import org.tela_botanica.del.client.modeles.Observation;
|
17 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
- |
|
18 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
- |
|
19 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
- |
|
20 |
|
- |
|
21 |
import com.google.gwt.event.dom.client.ClickHandler;
|
16 |
import org.tela_botanica.del.client.modeles.PropositionDetermination;
|
22 |
import com.google.gwt.event.dom.client.HasClickHandlers;
|
- |
|
23 |
import com.google.gwt.event.shared.GwtEvent;
|
- |
|
Line 24... |
Line 17... |
24 |
import com.google.gwt.event.shared.HandlerRegistration;
|
17 |
import org.tela_botanica.del.client.modeles.VoteDetermination;
|
Line 25... |
Line 18... |
25 |
import com.google.gwt.user.client.ui.IsWidget;
|
18 |
import org.tela_botanica.del.client.services.CalculVoteDeterminationService;
|
26 |
import com.google.gwt.user.client.ui.Widget;
|
19 |
import org.tela_botanica.del.client.services.rest.VoteDeterminationService;
|
27 |
|
20 |
|
28 |
public class BarreRepartitionVotePresenteurTest {
|
21 |
public class BarreRepartitionVotePresenteurTest {
|
29 |
|
22 |
|
30 |
private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
|
23 |
private BarreRepartitionVotePresenteur barreRepartitionVotePresenteur;
|
31 |
private BarreRepartitionVotePresenteur.Vue vue;
|
24 |
private BarreRepartitionVotePresenteur.Vue vue;
|
- |
|
25 |
|
32 |
|
26 |
@Before
|
33 |
@Before
|
27 |
public void setUp() {
|
34 |
public void setUp() {
|
28 |
|
35 |
|
29 |
vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
|
36 |
vue = mock(Vue.class, Mockito.RETURNS_DEEP_STUBS);
|
30 |
VoteDeterminationService voteDeterminationService = Mockito.mock(VoteDeterminationService.class);
|
37 |
barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue);
|
31 |
barreRepartitionVotePresenteur = new BarreRepartitionVotePresenteur(vue, voteDeterminationService);
|
Line 38... |
Line 32... |
38 |
|
32 |
|
39 |
VoteDetermination voteDetermination = new VoteDetermination();
|
33 |
VoteDetermination voteDetermination = new VoteDetermination();
|
40 |
voteDetermination.setVote(1);
|
34 |
voteDetermination.setVote(1);
|
41 |
voteDetermination.setDate(new Date());
|
35 |
voteDetermination.setDate(new Date());
|
42 |
voteDetermination.setContributeur("benjamin");
|
36 |
voteDetermination.setContributeur("benjamin");
|
43 |
|
37 |
|
44 |
PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
|
38 |
PropositionDetermination propositionDetermination = new PropositionDetermination(new Observation());
|
45 |
propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
|
39 |
propositionDetermination.setEspece("Iris lutescens subsp. lutescens");
|
46 |
propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
|
40 |
propositionDetermination.setContributeur(new Contributeur("1", "contrib", "test", "contrib@test.com"));
|
47 |
propositionDetermination.setId("1");
|
41 |
propositionDetermination.setId("1");
|
48 |
propositionDetermination.ajouterVoteDetermination(voteDetermination);
|
42 |
propositionDetermination.ajouterVoteDetermination(voteDetermination);
|
49 |
|
43 |
|
50 |
MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
44 |
MoyenneVote moyenneVote = CalculVoteDeterminationService.calculerVoteDetermination(propositionDetermination);
|
51 |
barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
|
45 |
barreRepartitionVotePresenteur.afficherVotes(moyenneVote);
|
52 |
}
|
46 |
}
|
53 |
|
47 |
|
54 |
@Test
|
48 |
@Test
|
Line 55... |
Line 49... |
55 |
public void testVoter() {
|
49 |
public void testVoter() {
|