ListCountriesViewTest.java
1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.legrog.web.xyz;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.platform.runner.JUnitPlatform;
import org.junit.runner.RunWith;
import org.legrog.entities.Country;
import org.legrog.test.MockitoExtension;
import org.mockito.*;
import java.util.ArrayList;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Mockito.when;
/**
* Classe testant ListCountriesView
*/
@RunWith(JUnitPlatform.class)
@ExtendWith(MockitoExtension.class)
@DisplayName("Shows the country list")
public class ListCountriesViewTest {
private ListCountriesView listCountriesView;
private List<Country> countryList;
@BeforeEach
public void setup(@Mock SharedService sharedService) throws Exception {
countryList = new ArrayList<Country>();
listCountriesView = new ListCountriesView(sharedService);
when(sharedService.getAllCountries()).thenReturn(countryList);
}
@Nested
@DisplayName("init method")
class initTests{
@Test
@DisplayName("should get all countries")
public void getAllCountriesTest() {
listCountriesView.init();
assertThat(listCountriesView.getCountries()).isEqualTo(countryList);
}
}
}