1919import static org .testng .Assert .assertEquals ;
2020
2121/**
22- * @author Nicole Torres
22+ * @author Nicole Torres / emilia
2323 */
2424public class AE_PersonNameParserCommandTest extends AbstractTest {
2525
2626 private final CommandExecutor executor = NameApiRemoteExecutors .get ();
2727
28+
29+
2830 @ Test (dataProvider = "test_AE_1" )
2931 public void test_AE_1 (NaturalInputPerson inputPerson ) throws Exception {
32+ PersonNameParserCommand command = new PersonNameParserCommand ();
33+ Mode mode = FunctionalTestsNameApiModeFactory .functionalTest ();
34+ PersonNameParserResult result = executor .execute (command , mode , inputPerson ).get ();
35+ ParsedPerson parsedPerson = result .getBestMatch ().getParsedPerson ();
36+ OutputPersonName personName = parsedPerson .getOutputPersonName ();
37+ assertEquals ("حسّان" , personName .getFirst (TermType .GIVENNAME ).get ().getString ());
38+ assertEquals ("عبد العزيز" , personName .getSecond (TermType .GIVENNAME ).get ().getString ());
39+ assertEquals ("المصري" , personName .getFirst (TermType .SURNAME ).get ().getString ());
40+ assertEquals (parsedPerson .getGender ().getGender (), ComputedPersonGender .MALE );
41+ }
42+
43+
44+ @ DataProvider
45+ protected Object [][] test_AE_1 () {
46+ return new Object [][]{
47+ {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().fullname ("حسّان عبد العزيز المصري" ).build ()).build ()},
48+ {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().givenName ("حسّان عبد العزيز" ).surname ("المصري" ).build ()).build ()}
49+ };
50+ }
51+
52+ @ Test (dataProvider = "test_AE_2" )
53+ public void test_AE_2 (NaturalInputPerson inputPerson ) throws Exception {
3054 PersonNameParserCommand command = new PersonNameParserCommand ();
3155 Mode mode = FunctionalTestsNameApiModeFactory .functionalTest ();
3256 PersonNameParserResult result = executor .execute (command , mode , inputPerson ).get ();
@@ -37,12 +61,55 @@ public void test_AE_1(NaturalInputPerson inputPerson) throws Exception {
3761 assertEquals ("Al-Masri" , personName .getFirst (TermType .SURNAME ).get ().getString ());
3862 assertEquals (parsedPerson .getGender ().getGender (), ComputedPersonGender .MALE );
3963 }
64+
65+
4066 @ DataProvider
41- protected Object [][] test_AE_1 () {
67+ protected Object [][] test_AE_2 () {
4268 return new Object [][]{
4369 {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().fullname ("Hassan Abdul-Aziz Al-Masri" ).build ()).build ()},
4470 {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().givenName ("Hassan Abdul-Aziz" ).surname ("Al-Masri" ).build ()).build ()}
4571 };
4672 }
4773
74+ @ Test (dataProvider = "test_AE_3" )
75+ public void test_AE_3 (NaturalInputPerson inputPerson ) throws Exception {
76+ PersonNameParserCommand command = new PersonNameParserCommand ();
77+ Mode mode = FunctionalTestsNameApiModeFactory .functionalTest ();
78+ PersonNameParserResult result = executor .execute (command , mode , inputPerson ).get ();
79+ ParsedPerson parsedPerson = result .getBestMatch ().getParsedPerson ();
80+ OutputPersonName personName = parsedPerson .getOutputPersonName ();
81+ assertEquals ("Hiba" , personName .getFirst (TermType .GIVENNAME ).get ().getString ());
82+ assertEquals ("Al-Baghdadi" , personName .getFirst (TermType .SURNAME ).get ().getString ());
83+ assertEquals (parsedPerson .getGender ().getGender (), ComputedPersonGender .FEMALE );
84+ }
85+
86+
87+ @ DataProvider
88+ protected Object [][] test_AE_3 () {
89+ return new Object [][]{
90+ {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().fullname ("Hiba Al-Baghdadi" ).build ()).build ()},
91+ {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().givenName ("Hiba" ).surname ("Al-Baghdadi" ).build ()).build ()}
92+ };
93+ }
94+
95+ @ Test (dataProvider = "test_AE_4" )
96+ public void test_AE_4 (NaturalInputPerson inputPerson ) throws Exception {
97+ PersonNameParserCommand command = new PersonNameParserCommand ();
98+ Mode mode = FunctionalTestsNameApiModeFactory .functionalTest ();
99+ PersonNameParserResult result = executor .execute (command , mode , inputPerson ).get ();
100+ ParsedPerson parsedPerson = result .getBestMatch ().getParsedPerson ();
101+ OutputPersonName personName = parsedPerson .getOutputPersonName ();
102+ assertEquals ("هبة" , personName .getFirst (TermType .GIVENNAME ).get ().getString ());
103+ assertEquals ("لبغدادي" , personName .getFirst (TermType .SURNAME ).get ().getString ());
104+ assertEquals (parsedPerson .getGender ().getGender (), ComputedPersonGender .FEMALE );
105+ }
106+
107+
108+ @ DataProvider
109+ protected Object [][] test_AE_4 () {
110+ return new Object [][]{
111+ {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().fullname ("هبة لبغدادي" ).build ()).build ()},
112+ {new NaturalInputPersonBuilder ().name (new WesternInputPersonNameBuilder ().givenName ("هبة" ).surname ("لبغدادي" ).build ()).build ()}
113+ };
114+ }
48115}
0 commit comments