From: Roland Häder Date: Wed, 16 Nov 2022 13:20:10 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=f6c5cc59734916c05fd7960918f26190419670a9;p=jcountry-core.git Continued: - also test setting fields on right side (country2) - sorted members --- diff --git a/test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java b/test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java index 35d41e2..08c6415 100644 --- a/test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java +++ b/test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java @@ -265,32 +265,6 @@ public class CountryDataObjectTest { Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N } - @Test (description = "Tests Country.countryEntryCreated getter/setter") - public void testCountryEntryCreated () { - // Empty instance - final Country country = new CountryData(); - final Date date = new Date(); - - // Set it - country.setCountryEntryCreated(date); - - // Should be the same! - Assert.assertEquals(country.getCountryEntryCreated(), date); - } - - @Test (description = "Tests Country.countryEntryUpdated getter/setter") - public void testCountryEntryUpdated () { - // Empty instance - final Country country = new CountryData(); - final Date date = new Date(); - - // Set it - country.setCountryEntryUpdated(date); - - // Should be the same! - Assert.assertEquals(country.getCountryEntryUpdated(), date); - } - @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") public void testCountry1EqualsDifferentAbroadDialPrefix (final Country country1, final Country country2) { // First change countryAbroadDialPrefix to something else @@ -366,4 +340,86 @@ public class CountryDataObjectTest { Assert.assertTrue(country.equals(country)); } + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentAbroadDialPrefix (final Country country1, final Country country2) { + // First change countryAbroadDialPrefix to something else + country2.setCountryAbroadDialPrefix("++"); //NOI18N + Assert.assertFalse(country1.equals(country2)); + country2.setCountryAbroadDialPrefix(ABROAD_DIAL_PREFIX); + } + + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentCountryCode (final Country country1, final Country country2) { + // Next is countryCode + country2.setCountryCode("XX"); //NOI18N + Assert.assertFalse(country1.equals(country2)); + country2.setCountryCode(COUNTRY_CODE); + } + + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentCountryId (final Country country1, final Country country2) { + // Next is countryId + country2.setCountryId(1l); //NOI18N + Assert.assertFalse(country1.equals(country2)); + country2.setCountryId(null); + } + + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentExternalDialPrefix (final Country country1, final Country country2) { + // Next is countryExternalDialPrefix + country2.setCountryExternalDialPrefix("00"); //NOI18N + Assert.assertFalse(country1.equals(country2)); + country2.setCountryCode(EXTERNAL_DIAL_PREFIX); + } + + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentI18nKey (final Country country1, final Country country2) { + // Next is countryI18nKey + country2.setCountryI18nKey("COUNTRY_XX"); //NOI18N + Assert.assertFalse(country1.equals(country2)); + country2.setCountryI18nKey(COUNTRY_I18N_KEY); + } + + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentIsLocalDialPrefixRequired (final Country country1, final Country country2) { + // Next is countryId + country2.setCountryIsLocalPrefixRequired(Boolean.FALSE); + Assert.assertFalse(country1.equals(country2)); + country2.setCountryIsLocalPrefixRequired(Boolean.TRUE); + } + + @Test (description = "Tests if Country.equals() returns false when a field has been changed to an other value", dataProvider = "same-country-provider") + public void testCountry2EqualsDifferentPhoneCode (final Country country1, final Country country2) { + // Next is countryId + country2.setCountryPhoneCode(COUNTRY_PHONE_CODE0); + Assert.assertFalse(country1.equals(country2)); + country2.setCountryPhoneCode(COUNTRY_PHONE_CODE1); + } + + @Test (description = "Tests Country.countryEntryCreated getter/setter") + public void testCountryEntryCreated () { + // Empty instance + final Country country = new CountryData(); + final Date date = new Date(); + + // Set it + country.setCountryEntryCreated(date); + + // Should be the same! + Assert.assertEquals(country.getCountryEntryCreated(), date); + } + + @Test (description = "Tests Country.countryEntryUpdated getter/setter") + public void testCountryEntryUpdated () { + // Empty instance + final Country country = new CountryData(); + final Date date = new Date(); + + // Set it + country.setCountryEntryUpdated(date); + + // Should be the same! + Assert.assertEquals(country.getCountryEntryUpdated(), date); + } + }