From 5cca1db3d9d00435ac63c61b315d08e9ce43ae5e Mon Sep 17 00:00:00 2001 From: Sizolwakhe Leonard Mthimunye Date: Fri, 12 Sep 2025 02:59:53 +0200 Subject: [PATCH] add nit test to test get country by continent method and get country by region method --- .../countries/TestCountriesEntity.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/airpenthouse/GoTel/entities/countries/TestCountriesEntity.java b/src/test/java/org/airpenthouse/GoTel/entities/countries/TestCountriesEntity.java index 011d520..4e27cf1 100644 --- a/src/test/java/org/airpenthouse/GoTel/entities/countries/TestCountriesEntity.java +++ b/src/test/java/org/airpenthouse/GoTel/entities/countries/TestCountriesEntity.java @@ -66,7 +66,7 @@ public void TestPrivateMethod_GetCountryByNameEmptyCountryName() throws NoSuchMe Test when server is down throw NullPointer */ - @Test + // @Test public void TestPrivateMethod_GetCountryByNameWhenServerIsDown() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { setProperties("countryName", ""); assertThrows(NullPointerException.class, () -> reflectPrivateMethod("getCountryByName")); @@ -93,7 +93,7 @@ public void TestPrivateMethod_GetAllCountries() throws NoSuchMethodException, In assertEquals(239, list.size()); } - @Test + // @Test public void TestPrivateMethod_GetAllCountriesThrowsNullPointerException() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { assertThrows(NullPointerException.class, () -> reflectPrivateMethod("getAllCountries")); } @@ -118,4 +118,34 @@ private List reflectPrivateMethod(String methodName) throws Inv return set.stream().toList(); } + @Test + public void TestPrivateMethod_GetCountryByRegionEmptyCountryName() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + setProperties("regionName", ""); + var list = reflectPrivateMethod("getCountryByRegion"); + assertTrue(list.isEmpty()); + } + + @Test + public void TestPrivateMethod_GetCountryByRegion() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, SQLException { + setProperties("regionName", "Caribbean"); + var list = reflectPrivateMethod("getCountryByRegion"); + + assertEquals(getPropertiesValue("regionName"), list.get(0).getCountryRegion()); + } + + @Test + public void TestPrivateMethod_GetCountryByContinentEmptyCountryName() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException { + setProperties("continentName", ""); + var list = reflectPrivateMethod("getCountryByContinent"); + assertTrue(list.isEmpty()); + } + + @Test + public void TestPrivateMethod_GetCountryByContinent() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, SQLException { + setProperties("continentName", "Africa"); + var list = reflectPrivateMethod("getCountryByContinent"); + + assertEquals(getPropertiesValue("continentName"), list.get(0).getContinent()); + } + }