]> git.mxchange.org Git - jcountry-core.git/commitdiff
Continued:
authorRoland Häder <roland@mxchange.org>
Fri, 4 Nov 2022 16:00:39 +0000 (17:00 +0100)
committerRoland Häder <roland@mxchange.org>
Sat, 5 Nov 2022 04:36:41 +0000 (05:36 +0100)
- moved test classes to same package as the tested classes are
- also compare flag

src/org/mxchange/jcountry/model/data/CountryData.java
test/org/mxchange/jcountry/CountryCoreTestSuite.xml
test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java [new file with mode: 0644]
test/org/mxchange/jcountry/model/utils/CountryUtilsTest.java [new file with mode: 0644]
test/org/mxchange/jcountry/test/model/data/CountryDataObjectTest.java [deleted file]
test/org/mxchange/jcountry/test/model/utils/CountryUtilsTest.java [deleted file]

index 8dce48e1645e745b76dea6e874ea40db20f63ff1..886c37007adaf5014bed0f0a40bd84c4aae8498b 100644 (file)
@@ -214,7 +214,9 @@ public class CountryData implements Country {
                        // ... abroad dial prefix
                        StringUtils.compare(this.getCountryAbroadDialPrefix(), country.getCountryAbroadDialPrefix()),
                        // ... external dial prefix
-                       StringUtils.compare(this.getCountryExternalDialPrefix(), country.getCountryExternalDialPrefix())
+                       StringUtils.compare(this.getCountryExternalDialPrefix(), country.getCountryExternalDialPrefix()),
+                       // ... "is required" flag
+                       Boolean.compare(this.getCountryIsLocalPrefixRequired(), country.getCountryIsLocalPrefixRequired())
                };
 
                // Check all values
index 17380ed87ca5bb363e34bf63ca3fac597b8c6c72..11f58d31c2215e6ece296b06c0c0298b5d69cf0a 100644 (file)
@@ -18,7 +18,7 @@
        -->
        <test name="org.mxchange.jcountry.test suite">
                <packages>
-                       <package name="org.mxchange.jcountry.test"/>
+                       <package name="org.mxchange.jcountry"/>
                </packages>
        </test>
 </suite>
diff --git a/test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java b/test/org/mxchange/jcountry/model/data/CountryDataObjectTest.java
new file mode 100644 (file)
index 0000000..9ecb754
--- /dev/null
@@ -0,0 +1,369 @@
+/*
+ * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcountry.model.data;
+
+import java.util.Date;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test cases for CountryData class as an object (no entity-related tests)
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class CountryDataObjectTest {
+
+       private static final String ABROAD_DIAL_PREFIX = "+"; //NOI18N
+
+       private static final String COUNTRY_CODE = "DE"; //NOI18N
+
+       private static final String COUNTRY_I18N_KEY = "COUNTRY_GERMANY"; //NOI18N
+
+       private static final Short COUNTRY_PHONE_CODE0 = 0;
+
+       private static final Short COUNTRY_PHONE_CODE1 = 49;
+
+       private static final String EXTERNAL_DIAL_PREFIX = "0"; //NOI18N
+
+       /**
+        * Default constructor
+        */
+       public CountryDataObjectTest () {
+       }
+
+       @DataProvider (name = "same-country-provider")
+       public Object[][] createSameCountryObjectses () {
+               return new Object[][]{
+                       {new CountryData(), new CountryData()},
+                       {new CountryData(
+                               ABROAD_DIAL_PREFIX,
+                               COUNTRY_CODE,
+                               EXTERNAL_DIAL_PREFIX,
+                               COUNTRY_I18N_KEY,
+                               Boolean.TRUE,
+                               COUNTRY_PHONE_CODE1
+                               ), new CountryData(
+                        ABROAD_DIAL_PREFIX,
+                        COUNTRY_CODE,
+                        EXTERNAL_DIAL_PREFIX,
+                        COUNTRY_I18N_KEY,
+                        Boolean.TRUE,
+                        COUNTRY_PHONE_CODE1
+                        )}
+               };
+       }
+
+       @Test (description = "Tests method Country.compareTo() responding to a null reference", expectedExceptions = NullPointerException.class)
+       public void testCompareToNullReference () {
+               // Just a dummy ...
+               final Country country = new CountryData();
+
+               // This should cause a NPE with a non-empty message
+               country.compareTo(null);
+       }
+
+       @Test (description = "Tests method Country.compareTo() responding to same country data", dataProvider = "same-country-provider")
+       public void testCompareToSameCountryData (final Country country1, final Country country2) {
+               // Should always be 0
+               Assert.assertEquals(country1.compareTo(country2), 0);
+       }
+
+       @Test (description = "Tests method Country.compareTo() responding to same instance ")
+       public void testCompareToSameInstance () {
+               final Country country1 = new CountryData();
+               Assert.assertEquals(country1.compareTo(country1), 0);
+       }
+
+       @Test (description = "Tests constructor with abroadDialPrefix being empty", expectedExceptions = IllegalArgumentException.class)
+       public void testConstructorEmptyAbroadDialPrefix () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         "", //NOI18N
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be empty and if so must cause an IAE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryCodde being empty", expectedExceptions = IllegalArgumentException.class)
+       public void testConstructorEmptyCountryCode () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         "", //NOI18N
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be empty and if so must cause an IAE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryI18nKey being empty", expectedExceptions = IllegalArgumentException.class)
+       public void testConstructorEmptyCountryI18nKey () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         "", //NOI18N
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be empty and if so must cause an IAE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryExternalDialPrefix being empty", expectedExceptions = IllegalArgumentException.class)
+       public void testConstructorEmptyExternalDialPrefix () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         "", //NOI18N
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be invalid and if so must cause an IAE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with invalid countryPhoneCode", expectedExceptions = IllegalArgumentException.class)
+       public void testConstructorInvalidCountryPhoneCode () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY, //NOI18N
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE0
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be invalid or else an E being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with abroadDialPrefix being null", expectedExceptions = NullPointerException.class)
+       public void testConstructorNullAbroadDialPrefix () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         null,
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryCodde being null", expectedExceptions = NullPointerException.class)
+       public void testConstructorNullCountryCode () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         null,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryI18nKey being null", expectedExceptions = NullPointerException.class)
+       public void testConstructorNullCountryI18nKey () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         null,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryIsLocalPrefixRequired being null", expectedExceptions = NullPointerException.class)
+       public void testConstructorNullCountryIsLocalPrefixRequired () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY,
+                                         null,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryPhoneCode being null", expectedExceptions = NullPointerException.class)
+       public void testConstructorNullCountryPhoneCode () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         EXTERNAL_DIAL_PREFIX,
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         null
+                         );
+
+               // NEVER REACHED!
+               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
+       }
+
+       @Test (description = "Tests constructor with countryExternalDialPrefix being null", expectedExceptions = NullPointerException.class)
+       public void testConstructorNullExternalDialPrefix () {
+               // Should throw a NPE
+               final Country country = new CountryData(
+                                         ABROAD_DIAL_PREFIX,
+                                         COUNTRY_CODE,
+                                         null,
+                                         COUNTRY_I18N_KEY,
+                                         Boolean.TRUE,
+                                         COUNTRY_PHONE_CODE1
+                         );
+
+               // NEVER REACHED!
+               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 testEqualsDifferentAbroadDialPrefix (final Country country1, final Country country2) {
+               // First change countryAbroadDialPrefix to something else
+               country1.setCountryAbroadDialPrefix("++"); //NOI18N
+               Assert.assertFalse(country1.equals(country2));
+               country1.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 testEqualsDifferentCountryCode (final Country country1, final Country country2) {
+               // Next is countryCode
+               country1.setCountryCode("XX"); //NOI18N
+               Assert.assertFalse(country1.equals(country2));
+               country1.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 testEqualsDifferentCountryId (final Country country1, final Country country2) {
+               // Next is countryId
+               country1.setCountryId(1l); //NOI18N
+               Assert.assertFalse(country1.equals(country2));
+               country1.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 testEqualsDifferentExternalDialPrefix (final Country country1, final Country country2) {
+               // Next is countryExternalDialPrefix
+               country1.setCountryExternalDialPrefix("00"); //NOI18N
+               Assert.assertFalse(country1.equals(country2));
+               country1.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 testEqualsDifferentI18nKey (final Country country1, final Country country2) {
+               // Next is countryI18nKey
+               country1.setCountryI18nKey("COUNTRY_XX"); //NOI18N
+               Assert.assertFalse(country1.equals(country2));
+               country1.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 testEqualsDifferentIsLocalDialPrefixRequired (final Country country1, final Country country2) {
+               // Next is countryId
+               country1.setCountryIsLocalPrefixRequired(Boolean.FALSE);
+               Assert.assertFalse(country1.equals(country2));
+               country1.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 testEqualsDifferentPhoneCode (final Country country1, final Country country2) {
+               // Next is countryId
+               country1.setCountryPhoneCode(COUNTRY_PHONE_CODE0);
+               Assert.assertFalse(country1.equals(country2));
+               country1.setCountryPhoneCode(COUNTRY_PHONE_CODE1);
+       }
+
+       @Test (description = "Tests if Country.equals() returns false when a null reference is provided")
+       @SuppressWarnings ("ObjectEqualsNull")
+       public void testEqualsNullReference () {
+               final Country country = new CountryData();
+               Assert.assertFalse(country.equals(null));
+       }
+
+       @Test (description = "Tests if Country.equals() returns false when an other object is provided")
+       public void testEqualsOtherObject () {
+               final Country country = new CountryData();
+               Assert.assertFalse(country.equals(new Object()));
+       }
+
+       @Test (description = "Tests if Country.equals() returns true when same instance is provided")
+       public void testEqualsSameInstance () {
+               final Country country = new CountryData();
+               Assert.assertTrue(country.equals(country));
+       }
+
+}
diff --git a/test/org/mxchange/jcountry/model/utils/CountryUtilsTest.java b/test/org/mxchange/jcountry/model/utils/CountryUtilsTest.java
new file mode 100644 (file)
index 0000000..8aae34f
--- /dev/null
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jcountry.model.utils;
+
+import org.mxchange.jcountry.model.data.Country;
+import org.mxchange.jcountry.model.data.CountryData;
+import org.testng.Assert;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/**
+ * Test cases for CountryUtils class
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public class CountryUtilsTest {
+
+       private static final String ABROAD_DIAL_PREFIX = "+"; //NOI18N
+
+       private static final String COUNTRY_CODE = "DE"; //NOI18N
+
+       private static final String COUNTRY_I18N_KEY = "COUNTRY_GERMANY"; //NOI18N
+
+       private static final Short COUNTRY_PHONE_CODE1 = 49;
+
+       private static final Short COUNTRY_PHONE_CODE2 = 1;
+
+       private static final String EXTERNAL_DIAL_PREFIX = "0"; //NOI18N
+
+       /**
+        * Default constructor
+        */
+       public CountryUtilsTest () {
+       }
+
+       @DataProvider (name = "different-country-provider")
+       public Object[][] createDifferentCountryObjectses () {
+               return new Object[][]{
+                       {new CountryData(
+                               ABROAD_DIAL_PREFIX,
+                               "US", //NOI18N
+                               EXTERNAL_DIAL_PREFIX,
+                               "COUNTRY_USA", //NOI18N
+                               Boolean.TRUE,
+                               COUNTRY_PHONE_CODE2
+                               ), new CountryData(
+                        ABROAD_DIAL_PREFIX,
+                        COUNTRY_CODE,
+                        EXTERNAL_DIAL_PREFIX,
+                        COUNTRY_I18N_KEY,
+                        Boolean.TRUE,
+                        COUNTRY_PHONE_CODE1
+                        )}
+               };
+       }
+
+       @DataProvider (name = "left-null-country-provider")
+       public Object[][] createLeftNullCountryObjectses () {
+               return new Object[][]{
+                       {null, new CountryData()},
+                       {null, new CountryData(
+                        ABROAD_DIAL_PREFIX,
+                        COUNTRY_CODE,
+                        EXTERNAL_DIAL_PREFIX,
+                        COUNTRY_I18N_KEY,
+                        Boolean.TRUE,
+                        COUNTRY_PHONE_CODE1
+                        )}
+               };
+       }
+
+       @DataProvider (name = "right-null-country-provider")
+       public Object[][] createRightNullCountryObjectses () {
+               return new Object[][]{
+                       {new CountryData(), null},
+                       {new CountryData(
+                               ABROAD_DIAL_PREFIX,
+                               COUNTRY_CODE,
+                               EXTERNAL_DIAL_PREFIX,
+                               COUNTRY_I18N_KEY,
+                               Boolean.TRUE,
+                               COUNTRY_PHONE_CODE1
+                               ), null}
+               };
+       }
+
+       @DataProvider (name = "same-country-provider")
+       public Object[][] createSameCountryObjectses () {
+               return new Object[][]{
+                       {new CountryData(), new CountryData()},
+                       {new CountryData(
+                               ABROAD_DIAL_PREFIX,
+                               COUNTRY_CODE,
+                               EXTERNAL_DIAL_PREFIX,
+                               COUNTRY_I18N_KEY,
+                               Boolean.TRUE,
+                               COUNTRY_PHONE_CODE1
+                               ), new CountryData(
+                        ABROAD_DIAL_PREFIX,
+                        COUNTRY_CODE,
+                        EXTERNAL_DIAL_PREFIX,
+                        COUNTRY_I18N_KEY,
+                        Boolean.TRUE,
+                        COUNTRY_PHONE_CODE1
+                        )}
+               };
+       }
+
+       @Test (description = "Tests the CountryUtils.compare() method with different country data", dataProvider = "different-country-provider")
+       public void testCompareDifferent (final Country country1, final Country country2) {
+               // Expect 1 always, as right side is higher
+               Assert.assertEquals(CountryUtils.compare(country1, country2), 1);
+       }
+
+       @Test (description = "Tests the CountryUtils.compare() method with left-side being null and other country data", dataProvider = "left-null-country-provider")
+       public void testCompareLeftNull (final Country country1, final Country country2) {
+               // Expect -1 always
+               Assert.assertEquals(CountryUtils.compare(country1, country2), -1);
+       }
+
+       @Test (description = "Tests the CountryUtils.compare() method with right-side being null and other country data", dataProvider = "right-null-country-provider")
+       public void testCompareRightNull (final Country country1, final Country country2) {
+               // Expect 1 always
+               Assert.assertEquals(CountryUtils.compare(country1, country2), 1);
+       }
+
+       @Test (description = "Tests the CountryUtils.compare() method with same country data", dataProvider = "same-country-provider")
+       public void testCompareSame (final Country country1, final Country country2) {
+               // Expect 0 always
+               Assert.assertEquals(CountryUtils.compare(country1, country2), 0);
+       }
+
+       @Test (description = "Tests the CountryUtils.copyCountryData() method with different instances", dataProvider = "different-country-provider")
+       public void testCopyCountryDifferentInstances (final Country country1, final Country country2) {
+               CountryUtils.copyCountryData(country1, country2);
+       }
+
+       @Test (description = "Tests the CountryUtils.copyCountryData() method with same instances", dataProvider = "same-country-provider", expectedExceptions = IllegalArgumentException.class)
+       public void testCopyCountrySameInstances (final Country country1, final Country country2) {
+               CountryUtils.copyCountryData(country1, country2);
+       }
+
+       @Test (description = "Tests the CountryUtils.copyCountryData() method with source null reference", dataProvider = "left-null-country-provider", expectedExceptions = NullPointerException.class)
+       public void testCopyCountrySourceNull (final Country country1, final Country country2) {
+               CountryUtils.copyCountryData(country1, country2);
+       }
+
+       @Test (description = "Tests the CountryUtils.copyCountryData() method with target null reference", dataProvider = "right-null-country-provider", expectedExceptions = NullPointerException.class)
+       public void testCopyCountryTargetNull (final Country country1, final Country country2) {
+               CountryUtils.copyCountryData(country1, country2);
+       }
+
+}
diff --git a/test/org/mxchange/jcountry/test/model/data/CountryDataObjectTest.java b/test/org/mxchange/jcountry/test/model/data/CountryDataObjectTest.java
deleted file mode 100644 (file)
index 1c5c526..0000000
+++ /dev/null
@@ -1,371 +0,0 @@
-/*
- * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcountry.test.model.data;
-
-import java.util.Date;
-import org.mxchange.jcountry.model.data.Country;
-import org.mxchange.jcountry.model.data.CountryData;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * Test cases for CountryData class as an object (no entity-related tests)
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class CountryDataObjectTest {
-
-       private static final String ABROAD_DIAL_PREFIX = "+"; //NOI18N
-
-       private static final String COUNTRY_CODE = "DE"; //NOI18N
-
-       private static final String COUNTRY_I18N_KEY = "COUNTRY_GERMANY"; //NOI18N
-
-       private static final Short COUNTRY_PHONE_CODE0 = 0;
-
-       private static final Short COUNTRY_PHONE_CODE1 = 49;
-
-       private static final String EXTERNAL_DIAL_PREFIX = "0"; //NOI18N
-
-       /**
-        * Default constructor
-        */
-       public CountryDataObjectTest () {
-       }
-
-       @DataProvider (name = "same-country-provider")
-       public Object[][] createSameCountryObjectses () {
-               return new Object[][]{
-                       {new CountryData(), new CountryData()},
-                       {new CountryData(
-                               ABROAD_DIAL_PREFIX,
-                               COUNTRY_CODE,
-                               EXTERNAL_DIAL_PREFIX,
-                               COUNTRY_I18N_KEY,
-                               Boolean.TRUE,
-                               COUNTRY_PHONE_CODE1
-                               ), new CountryData(
-                        ABROAD_DIAL_PREFIX,
-                        COUNTRY_CODE,
-                        EXTERNAL_DIAL_PREFIX,
-                        COUNTRY_I18N_KEY,
-                        Boolean.TRUE,
-                        COUNTRY_PHONE_CODE1
-                        )}
-               };
-       }
-
-       @Test (description = "Tests method Country.compareTo() responding to a null reference", expectedExceptions = NullPointerException.class)
-       public void testCompareToNullReference () {
-               // Just a dummy ...
-               final Country country = new CountryData();
-
-               // This should cause a NPE with a non-empty message
-               country.compareTo(null);
-       }
-
-       @Test (description = "Tests method Country.compareTo() responding to same country data", dataProvider = "same-country-provider")
-       public void testCompareToSameCountryData (final Country country1, final Country country2) {
-               // Should always be 0
-               Assert.assertEquals(country1.compareTo(country2), 0);
-       }
-
-       @Test (description = "Tests method Country.compareTo() responding to same instance ")
-       public void testCompareToSameInstance () {
-               final Country country1 = new CountryData();
-               Assert.assertEquals(country1.compareTo(country1), 0);
-       }
-
-       @Test (description = "Tests constructor with abroadDialPrefix being empty", expectedExceptions = IllegalArgumentException.class)
-       public void testConstructorEmptyAbroadDialPrefix () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         "", //NOI18N
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be empty and if so must cause an IAE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryCodde being empty", expectedExceptions = IllegalArgumentException.class)
-       public void testConstructorEmptyCountryCode () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         "", //NOI18N
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be empty and if so must cause an IAE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryI18nKey being empty", expectedExceptions = IllegalArgumentException.class)
-       public void testConstructorEmptyCountryI18nKey () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         "", //NOI18N
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be empty and if so must cause an IAE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryExternalDialPrefix being empty", expectedExceptions = IllegalArgumentException.class)
-       public void testConstructorEmptyExternalDialPrefix () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         "", //NOI18N
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be invalid and if so must cause an IAE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with invalid countryPhoneCode", expectedExceptions = IllegalArgumentException.class)
-       public void testConstructorInvalidCountryPhoneCode () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY, //NOI18N
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE0
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be invalid or else an E being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with abroadDialPrefix being null", expectedExceptions = NullPointerException.class)
-       public void testConstructorNullAbroadDialPrefix () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         null,
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryCodde being null", expectedExceptions = NullPointerException.class)
-       public void testConstructorNullCountryCode () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         null,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryI18nKey being null", expectedExceptions = NullPointerException.class)
-       public void testConstructorNullCountryI18nKey () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         null,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryIsLocalPrefixRequired being null", expectedExceptions = NullPointerException.class)
-       public void testConstructorNullCountryIsLocalPrefixRequired () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY,
-                                         null,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryPhoneCode being null", expectedExceptions = NullPointerException.class)
-       public void testConstructorNullCountryPhoneCode () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         EXTERNAL_DIAL_PREFIX,
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         null
-                         );
-
-               // NEVER REACHED!
-               Assert.fail("The required parameter must never be null and if so must cause a NPE being thrown: country=" + country); //NOI18N
-       }
-
-       @Test (description = "Tests constructor with countryExternalDialPrefix being null", expectedExceptions = NullPointerException.class)
-       public void testConstructorNullExternalDialPrefix () {
-               // Should throw a NPE
-               final Country country = new CountryData(
-                                         ABROAD_DIAL_PREFIX,
-                                         COUNTRY_CODE,
-                                         null,
-                                         COUNTRY_I18N_KEY,
-                                         Boolean.TRUE,
-                                         COUNTRY_PHONE_CODE1
-                         );
-
-               // NEVER REACHED!
-               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 testEqualsDifferentAbroadDialPrefix (final Country country1, final Country country2) {
-               // First change countryAbroadDialPrefix to something else
-               country1.setCountryAbroadDialPrefix("++"); //NOI18N
-               Assert.assertFalse(country1.equals(country2));
-               country1.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 testEqualsDifferentCountryCode (final Country country1, final Country country2) {
-               // Next is countryCode
-               country1.setCountryCode("XX"); //NOI18N
-               Assert.assertFalse(country1.equals(country2));
-               country1.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 testEqualsDifferentCountryId (final Country country1, final Country country2) {
-               // Next is countryId
-               country1.setCountryId(1l); //NOI18N
-               Assert.assertFalse(country1.equals(country2));
-               country1.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 testEqualsDifferentExternalDialPrefix (final Country country1, final Country country2) {
-               // Next is countryExternalDialPrefix
-               country1.setCountryExternalDialPrefix("00"); //NOI18N
-               Assert.assertFalse(country1.equals(country2));
-               country1.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 testEqualsDifferentI18nKey (final Country country1, final Country country2) {
-               // Next is countryI18nKey
-               country1.setCountryI18nKey("COUNTRY_XX"); //NOI18N
-               Assert.assertFalse(country1.equals(country2));
-               country1.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 testEqualsDifferentIsLocalDialPrefixRequired (final Country country1, final Country country2) {
-               // Next is countryId
-               country1.setCountryIsLocalPrefixRequired(Boolean.FALSE);
-               Assert.assertFalse(country1.equals(country2));
-               country1.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 testEqualsDifferentPhoneCode (final Country country1, final Country country2) {
-               // Next is countryId
-               country1.setCountryPhoneCode(COUNTRY_PHONE_CODE0);
-               Assert.assertFalse(country1.equals(country2));
-               country1.setCountryPhoneCode(COUNTRY_PHONE_CODE1);
-       }
-
-       @Test (description = "Tests if Country.equals() returns false when a null reference is provided")
-       @SuppressWarnings ("ObjectEqualsNull")
-       public void testEqualsNullReference () {
-               final Country country = new CountryData();
-               Assert.assertFalse(country.equals(null));
-       }
-
-       @Test (description = "Tests if Country.equals() returns false when an other object is provided")
-       public void testEqualsOtherObject () {
-               final Country country = new CountryData();
-               Assert.assertFalse(country.equals(new Object()));
-       }
-
-       @Test (description = "Tests if Country.equals() returns true when same instance is provided")
-       public void testEqualsSameInstance () {
-               final Country country = new CountryData();
-               Assert.assertTrue(country.equals(country));
-       }
-
-}
diff --git a/test/org/mxchange/jcountry/test/model/utils/CountryUtilsTest.java b/test/org/mxchange/jcountry/test/model/utils/CountryUtilsTest.java
deleted file mode 100644 (file)
index 6cf6fa2..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2022 Roland Häder<roland@mxchange.org>
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-package org.mxchange.jcountry.test.model.utils;
-
-import org.mxchange.jcountry.model.data.Country;
-import org.mxchange.jcountry.model.data.CountryData;
-import org.mxchange.jcountry.model.utils.CountryUtils;
-import org.testng.Assert;
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-/**
- * Test cases for CountryUtils class
- * <p>
- * @author Roland Häder<roland@mxchange.org>
- */
-public class CountryUtilsTest {
-
-       private static final String ABROAD_DIAL_PREFIX = "+"; //NOI18N
-
-       private static final String COUNTRY_CODE = "DE"; //NOI18N
-
-       private static final String COUNTRY_I18N_KEY = "COUNTRY_GERMANY"; //NOI18N
-
-       private static final Short COUNTRY_PHONE_CODE1 = 49;
-
-       private static final Short COUNTRY_PHONE_CODE2 = 1;
-
-       private static final String EXTERNAL_DIAL_PREFIX = "0"; //NOI18N
-
-       /**
-        * Default constructor
-        */
-       public CountryUtilsTest () {
-       }
-
-       @DataProvider (name = "different-country-provider")
-       public Object[][] createDifferentCountryObjectses () {
-               return new Object[][]{
-                       {new CountryData(
-                               ABROAD_DIAL_PREFIX,
-                               "US", //NOI18N
-                               EXTERNAL_DIAL_PREFIX,
-                               "COUNTRY_USA", //NOI18N
-                               Boolean.TRUE,
-                               COUNTRY_PHONE_CODE2
-                               ), new CountryData(
-                        ABROAD_DIAL_PREFIX,
-                        COUNTRY_CODE,
-                        EXTERNAL_DIAL_PREFIX,
-                        COUNTRY_I18N_KEY,
-                        Boolean.TRUE,
-                        COUNTRY_PHONE_CODE1
-                        )}
-               };
-       }
-
-       @DataProvider (name = "left-null-country-provider")
-       public Object[][] createLeftNullCountryObjectses () {
-               return new Object[][]{
-                       {null, new CountryData()},
-                       {null, new CountryData(
-                        ABROAD_DIAL_PREFIX,
-                        COUNTRY_CODE,
-                        EXTERNAL_DIAL_PREFIX,
-                        COUNTRY_I18N_KEY,
-                        Boolean.TRUE,
-                        COUNTRY_PHONE_CODE1
-                        )}
-               };
-       }
-
-       @DataProvider (name = "right-null-country-provider")
-       public Object[][] createRightNullCountryObjectses () {
-               return new Object[][]{
-                       {new CountryData(), null},
-                       {new CountryData(
-                               ABROAD_DIAL_PREFIX,
-                               COUNTRY_CODE,
-                               EXTERNAL_DIAL_PREFIX,
-                               COUNTRY_I18N_KEY,
-                               Boolean.TRUE,
-                               COUNTRY_PHONE_CODE1
-                               ), null}
-               };
-       }
-
-       @DataProvider (name = "same-country-provider")
-       public Object[][] createSameCountryObjectses () {
-               return new Object[][]{
-                       {new CountryData(), new CountryData()},
-                       {new CountryData(
-                               ABROAD_DIAL_PREFIX,
-                               COUNTRY_CODE,
-                               EXTERNAL_DIAL_PREFIX,
-                               COUNTRY_I18N_KEY,
-                               Boolean.TRUE,
-                               COUNTRY_PHONE_CODE1
-                               ), new CountryData(
-                        ABROAD_DIAL_PREFIX,
-                        COUNTRY_CODE,
-                        EXTERNAL_DIAL_PREFIX,
-                        COUNTRY_I18N_KEY,
-                        Boolean.TRUE,
-                        COUNTRY_PHONE_CODE1
-                        )}
-               };
-       }
-
-       @Test (description = "Tests the CountryUtils.compare() method with different country data", dataProvider = "different-country-provider")
-       public void testCompareDifferent (final Country country1, final Country country2) {
-               // Expect 1 always, as right side is higher
-               Assert.assertEquals(CountryUtils.compare(country1, country2), 1);
-       }
-
-       @Test (description = "Tests the CountryUtils.compare() method with left-side being null and other country data", dataProvider = "left-null-country-provider")
-       public void testCompareLeftNull (final Country country1, final Country country2) {
-               // Expect -1 always
-               Assert.assertEquals(CountryUtils.compare(country1, country2), -1);
-       }
-
-       @Test (description = "Tests the CountryUtils.compare() method with right-side being null and other country data", dataProvider = "right-null-country-provider")
-       public void testCompareRightNull (final Country country1, final Country country2) {
-               // Expect 1 always
-               Assert.assertEquals(CountryUtils.compare(country1, country2), 1);
-       }
-
-       @Test (description = "Tests the CountryUtils.compare() method with same country data", dataProvider = "same-country-provider")
-       public void testCompareSame (final Country country1, final Country country2) {
-               // Expect 0 always
-               Assert.assertEquals(CountryUtils.compare(country1, country2), 0);
-       }
-
-       @Test (description = "Tests the CountryUtils.copyCountryData() method with different instances", dataProvider = "different-country-provider")
-       public void testCopyCountryDifferentInstances (final Country country1, final Country country2) {
-               CountryUtils.copyCountryData(country1, country2);
-       }
-
-       @Test (description = "Tests the CountryUtils.copyCountryData() method with same instances", dataProvider = "same-country-provider", expectedExceptions = IllegalArgumentException.class)
-       public void testCopyCountrySameInstances (final Country country1, final Country country2) {
-               CountryUtils.copyCountryData(country1, country2);
-       }
-
-       @Test (description = "Tests the CountryUtils.copyCountryData() method with source null reference", dataProvider = "left-null-country-provider", expectedExceptions = NullPointerException.class)
-       public void testCopyCountrySourceNull (final Country country1, final Country country2) {
-               CountryUtils.copyCountryData(country1, country2);
-       }
-
-       @Test (description = "Tests the CountryUtils.copyCountryData() method with target null reference", dataProvider = "right-null-country-provider", expectedExceptions = NullPointerException.class)
-       public void testCopyCountryTargetNull (final Country country1, final Country country2) {
-               CountryUtils.copyCountryData(country1, country2);
-       }
-
-}