// Path: src/main/java/org/nameapi/client/lib/NameApiRemoteExecutors.java
// public final class NameApiRemoteExecutors {
// 
//     private static final CommandExecutor SAME = create();
// 
//     public static CommandExecutor create() {
//         return new CommandExecutorBuilder()
//                 .withExtension(new TimeoutExtension())
//                 .withExtension(new StdoutLoggingExtension())
//                 .withExtension(new ExceptionTranslationExtension())
//                 .withExtension(new AutoRetryExtension())
//                 .build();
//         //could add name-api specific extensions here ...
//     }
// 
//     /**
//      * @return Always the same, immutable executor.
//      */
//     public static CommandExecutor get() {
//         return SAME;
//     }
// 
// }
// 
// Path: src/test/functional/java/org/nameapi/client/services/AbstractTest.java
// public class AbstractTest {
// 
//     @NotNull
//     protected InputPersonName makeName(@NotNull String gn, @NotNull String sn) {
//         return new WesternInputPersonNameBuilder().givenName(gn).surname(sn).build();
//     }
// 
//     @NotNull
//     protected InputPersonName makeName(@NotNull String fullname) {
//         return NameBuilders.western().fullname(fullname).build();
//     }
// 
// }
// 
// Path: src/test/functional/java/org/nameapi/client/services/FunctionalTestsNameApiModeFactory.java
// public class FunctionalTestsNameApiModeFactory extends NameApiModeFactory {
// 
//     //Developer: set your api key here. It looks something like this:
//     //private static final String API_KEY = "32d21gc5071d7463ef6064c07ea98cb2-user1";
//     private static final String API_KEY = null;
// 
//     private static final Mode unitTestMode = withContext(API_KEY, makeContext(),
//             //the default and live server is "api.nameapi.org"
//             //we're using the latest release candidate with latest features here:
//             new Host("rc50-api.nameapi.org", 80), NameApiPortUrlFactory.versionLatestStable())
// 
//             //.with(TimeoutExtension.TIMEOUT, Duration.millis(5000))
//             .with(StdoutLoggingExtension.enabled())
//     ;
// 
//     private static Context makeContext() {
//         if (API_KEY==null) {
//             throw new RuntimeException("Set the api key variable to run the functional tests (get it from nameapi.org)!");
//         }
//         return new ContextBuilder()
//                 .priority(Priority.REALTIME)
//         .build();
//     }
// 
//     @NotNull
//     public static Mode functionalTest() {
//         return unitTestMode;
//     }
// 
// }


import com.optimaize.command4j.CommandExecutor;
import com.optimaize.command4j.Mode;
import org.nameapi.client.lib.NameApiRemoteExecutors;
import org.nameapi.client.services.AbstractTest;
import org.nameapi.client.services.FunctionalTestsNameApiModeFactory;
import org.nameapi.ontology5.input.entities.address.StructuredAddressBuilder;
import org.nameapi.ontology5.input.entities.address.StructuredPlaceInfoBuilder;
import org.nameapi.ontology5.input.entities.address.StructuredStreetInfoBuilder;
import org.nameapi.ontology5.input.entities.contact.EmailAddressFactory;
import org.nameapi.ontology5.input.entities.contact.TelNumberFactory;
import org.nameapi.ontology5.input.entities.person.InputPerson;
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;
import org.nameapi.ontology5.input.entities.person.age.AgeInfo;
import org.nameapi.ontology5.input.entities.person.age.AgeInfoFactory;
import org.nameapi.ontology5.services.riskdetector.*;
import org.testng.AssertJUnit;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertTrue;
                .name(makeName("Peter Meyer"))
                .age(birthDate)
                .build();

        RiskDetectorResult result = run(person);
        AssertJUnit.assertFalse(result.hasRisk());
    }
    @DataProvider
    protected Object[][] birthDates_ok() {
        return new Object[][] {
                {AgeInfoFactory.forDate(1961, 1, 2)},
                {AgeInfoFactory.forDate(1981, 1, 2)},
                {AgeInfoFactory.forDate(1995, 12, 31)},
        };
    }

    @Test
    public void multipleResults() throws Exception {
        InputPerson person = new NaturalInputPersonBuilder()
                .name(makeName("John Doe"))
                .addEmail(EmailAddressFactory.forAddress("dqwdqw@dsds.sddsa"))
                .age(AgeInfoFactory.forDate(1861, 3, 3))
                .build();

        RiskDetectorResult result = run(person);
        assertTrue(result.getRisks().size() >= 3);
    }

    private RiskDetectorResult run(InputPerson person) throws Exception {
        PersonRiskDetectorCommand command = new PersonRiskDetectorCommand();
// Path: src/main/java/org/nameapi/client/lib/NameApiRemoteExecutors.java
// public final class NameApiRemoteExecutors {
// 
//     private static final CommandExecutor SAME = create();
// 
//     public static CommandExecutor create() {
//         return new CommandExecutorBuilder()
//                 .withExtension(new TimeoutExtension())
//                 .withExtension(new StdoutLoggingExtension())
//                 .withExtension(new ExceptionTranslationExtension())
//                 .withExtension(new AutoRetryExtension())
//                 .build();
//         //could add name-api specific extensions here ...
//     }
// 
//     /**
//      * @return Always the same, immutable executor.
//      */
//     public static CommandExecutor get() {
//         return SAME;
//     }
// 
// }
// 
// Path: src/test/functional/java/org/nameapi/client/services/AbstractTest.java
// public class AbstractTest {
// 
//     @NotNull
//     protected InputPersonName makeName(@NotNull String gn, @NotNull String sn) {
//         return new WesternInputPersonNameBuilder().givenName(gn).surname(sn).build();
//     }
// 
//     @NotNull
//     protected InputPersonName makeName(@NotNull String fullname) {
//         return NameBuilders.western().fullname(fullname).build();
//     }
// 
// }
// 
// Path: src/test/functional/java/org/nameapi/client/services/FunctionalTestsNameApiModeFactory.java
// public class FunctionalTestsNameApiModeFactory extends NameApiModeFactory {
// 
//     //Developer: set your api key here. It looks something like this:
//     //private static final String API_KEY = "32d21gc5071d7463ef6064c07ea98cb2-user1";
//     private static final String API_KEY = null;
// 
//     private static final Mode unitTestMode = withContext(API_KEY, makeContext(),
//             //the default and live server is "api.nameapi.org"
//             //we're using the latest release candidate with latest features here:
//             new Host("rc50-api.nameapi.org", 80), NameApiPortUrlFactory.versionLatestStable())
// 
//             //.with(TimeoutExtension.TIMEOUT, Duration.millis(5000))
//             .with(StdoutLoggingExtension.enabled())
//     ;
// 
//     private static Context makeContext() {
//         if (API_KEY==null) {
//             throw new RuntimeException("Set the api key variable to run the functional tests (get it from nameapi.org)!");
//         }
//         return new ContextBuilder()
//                 .priority(Priority.REALTIME)
//         .build();
//     }
// 
//     @NotNull
//     public static Mode functionalTest() {
//         return unitTestMode;
//     }
// 
// }


// Path: src/test/functional/java/org/nameapi/client/services/riskdetector/person/PersonRiskDetectorCommandTest.java
import com.optimaize.command4j.CommandExecutor;
import com.optimaize.command4j.Mode;
import org.nameapi.client.lib.NameApiRemoteExecutors;
import org.nameapi.client.services.AbstractTest;
import org.nameapi.client.services.FunctionalTestsNameApiModeFactory;
import org.nameapi.ontology5.input.entities.address.StructuredAddressBuilder;
import org.nameapi.ontology5.input.entities.address.StructuredPlaceInfoBuilder;
import org.nameapi.ontology5.input.entities.address.StructuredStreetInfoBuilder;
import org.nameapi.ontology5.input.entities.contact.EmailAddressFactory;
import org.nameapi.ontology5.input.entities.contact.TelNumberFactory;
import org.nameapi.ontology5.input.entities.person.InputPerson;
import org.nameapi.ontology5.input.entities.person.NaturalInputPersonBuilder;
import org.nameapi.ontology5.input.entities.person.age.AgeInfo;
import org.nameapi.ontology5.input.entities.person.age.AgeInfoFactory;
import org.nameapi.ontology5.services.riskdetector.*;
import org.testng.AssertJUnit;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertTrue;

                .name(makeName("Peter Meyer"))
                .age(birthDate)
                .build();

        RiskDetectorResult result = run(person);
        AssertJUnit.assertFalse(result.hasRisk());
    }
    @DataProvider
    protected Object[][] birthDates_ok() {
        return new Object[][] {
                {AgeInfoFactory.forDate(1961, 1, 2)},
                {AgeInfoFactory.forDate(1981, 1, 2)},
                {AgeInfoFactory.forDate(1995, 12, 31)},
        };
    }

    @Test
    public void multipleResults() throws Exception {
        InputPerson person = new NaturalInputPersonBuilder()
                .name(makeName("John Doe"))
                .addEmail(EmailAddressFactory.forAddress("dqwdqw@dsds.sddsa"))
                .age(AgeInfoFactory.forDate(1861, 3, 3))
                .build();

        RiskDetectorResult result = run(person);
        assertTrue(result.getRisks().size() >= 3);
    }

    private RiskDetectorResult run(InputPerson person) throws Exception {
        PersonRiskDetectorCommand command = new PersonRiskDetectorCommand();
        Mode mode = FunctionalTestsNameApiModeFactory.functionalTest();