Skip to content

Commit 41075fb

Browse files
Merge pull request #32 from leonard1thecoder/create-unit-tests-for-get-all-country-entity-method
add nit test to test get country by continent method and get country…
2 parents ab860c0 + 5cca1db commit 41075fb

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/test/java/org/airpenthouse/GoTel/entities/countries/TestCountriesEntity.java

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void TestPrivateMethod_GetCountryByNameEmptyCountryName() throws NoSuchMe
6666
Test when server is down throw NullPointer
6767
*/
6868

69-
@Test
69+
// @Test
7070
public void TestPrivateMethod_GetCountryByNameWhenServerIsDown() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
7171
setProperties("countryName", "");
7272
assertThrows(NullPointerException.class, () -> reflectPrivateMethod("getCountryByName"));
@@ -93,7 +93,7 @@ public void TestPrivateMethod_GetAllCountries() throws NoSuchMethodException, In
9393
assertEquals(239, list.size());
9494
}
9595

96-
@Test
96+
// @Test
9797
public void TestPrivateMethod_GetAllCountriesThrowsNullPointerException() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
9898
assertThrows(NullPointerException.class, () -> reflectPrivateMethod("getAllCountries"));
9999
}
@@ -118,4 +118,34 @@ private List<CountriesEntity> reflectPrivateMethod(String methodName) throws Inv
118118
return set.stream().toList();
119119
}
120120

121+
@Test
122+
public void TestPrivateMethod_GetCountryByRegionEmptyCountryName() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
123+
setProperties("regionName", "");
124+
var list = reflectPrivateMethod("getCountryByRegion");
125+
assertTrue(list.isEmpty());
126+
}
127+
128+
@Test
129+
public void TestPrivateMethod_GetCountryByRegion() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, SQLException {
130+
setProperties("regionName", "Caribbean");
131+
var list = reflectPrivateMethod("getCountryByRegion");
132+
133+
assertEquals(getPropertiesValue("regionName"), list.get(0).getCountryRegion());
134+
}
135+
136+
@Test
137+
public void TestPrivateMethod_GetCountryByContinentEmptyCountryName() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
138+
setProperties("continentName", "");
139+
var list = reflectPrivateMethod("getCountryByContinent");
140+
assertTrue(list.isEmpty());
141+
}
142+
143+
@Test
144+
public void TestPrivateMethod_GetCountryByContinent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, SQLException {
145+
setProperties("continentName", "Africa");
146+
var list = reflectPrivateMethod("getCountryByContinent");
147+
148+
assertEquals(getPropertiesValue("continentName"), list.get(0).getContinent());
149+
}
150+
121151
}

0 commit comments

Comments
 (0)