Skip to content

Commit 3b665cd

Browse files
committed
test(JdbcCountryDaoTest): add tests for countCountriesOfCollection() method.
Prerequisite for #371
1 parent af601a4 commit 3b665cd

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

src/test/java/ru/mystamps/web/feature/country/JdbcCountryDaoTest.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,44 @@ public class JdbcCountryDaoTest implements WithAssertions {
5050
@Autowired
5151
private CountryDao countryDao;
5252

53+
//
54+
// Tests for countCountriesOfCollection()
55+
//
56+
57+
@Test
58+
public void countCountriesOfCollectionWithEmptyCollection() {
59+
// given
60+
// when
61+
long numberOfCountries = countryDao.countCountriesOfCollection(Random.id());
62+
// then
63+
assertThat(numberOfCountries).isEqualTo(0);
64+
}
65+
66+
@Test
67+
@Sql(
68+
scripts = {
69+
"/db/users-coder.sql",
70+
"/db/collections-coder.sql",
71+
"/db/categories-sport.sql",
72+
"/db/countries-italy.sql",
73+
"/db/countries-france.sql",
74+
"/db/series-4-italy-qty5.sql",
75+
"/db/series-5-france-qty4.sql",
76+
"/db/series-6-france-qty6.sql"
77+
},
78+
statements = {
79+
"INSERT INTO collections_series(collection_id, series_id, number_of_stamps) "
80+
+ "VALUES (1, 4, 5), (1, 5, 4), (1, 6, 6)"
81+
}
82+
)
83+
public void countCountriesOfCollectionWithMultipleSeriesFromEachCountry() {
84+
// given
85+
// when
86+
long numberOfCountries = countryDao.countCountriesOfCollection(1);
87+
// then
88+
assertThat(numberOfCountries).isEqualTo(2);
89+
}
90+
5391
//
5492
// Tests for getStatisticsOf()
5593
//

0 commit comments

Comments
 (0)