// 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/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;
//     }
// 
// }


import com.optimaize.anythingworks.common.fault.exceptions.AccessDeniedServiceException;
import com.optimaize.anythingworks.common.fault.exceptions.BadRequestServiceException;
import com.optimaize.anythingworks.common.fault.exceptions.InternalServerErrorServiceException;
import com.optimaize.anythingworks.common.fault.faultinfo.Blame;
import com.optimaize.anythingworks.common.fault.faultinfo.RetryType;
import com.optimaize.command4j.CommandExecutor;
import com.optimaize.command4j.Mode;
import org.nameapi.client.services.FunctionalTestsNameApiModeFactory;
import org.nameapi.client.lib.NameApiRemoteExecutors;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;
        } catch (InternalServerErrorServiceException e) {
            assertEquals(e.getFaultInfo().getBlame(), Blame.SERVER);
            assertFalse(e.getFaultInfo().getRetrySameLocation().isPresent());
        }
    }


    @Test
    public void testCall3() throws Exception {
        try {
            execute(ExceptionType.AccessDeniedNoSuchAccount);
            fail("Expected exception!");
        } catch (AccessDeniedServiceException e) {
            assertEquals(e.getFaultInfo().getBlame(), Blame.CLIENT);
            assertEquals(e.getFaultInfo().getRetrySameLocation().get().getRetryType(), RetryType.NO);
        }
    }

//    @Test(expectedExceptions = AccessDeniedServiceException.class)
//    public void testCall4() throws Exception {
//        execute(ExceptionType.AccessDeniedRequestLimitExceeded);
//    }
//
//    @Test(expectedExceptions = AccessDeniedServiceException.class)
//    public void testCall5() throws Exception {
//        execute(ExceptionType.AccessDeniedTooManyConcurrentRequests);
//    }

    private void execute(ExceptionType type) throws Exception {
        ExceptionThrowerCommand command = new ExceptionThrowerCommand();
// 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/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/development/exceptionthrower/ExceptionThrowerCommandTest.java
import com.optimaize.anythingworks.common.fault.exceptions.AccessDeniedServiceException;
import com.optimaize.anythingworks.common.fault.exceptions.BadRequestServiceException;
import com.optimaize.anythingworks.common.fault.exceptions.InternalServerErrorServiceException;
import com.optimaize.anythingworks.common.fault.faultinfo.Blame;
import com.optimaize.anythingworks.common.fault.faultinfo.RetryType;
import com.optimaize.command4j.CommandExecutor;
import com.optimaize.command4j.Mode;
import org.nameapi.client.services.FunctionalTestsNameApiModeFactory;
import org.nameapi.client.lib.NameApiRemoteExecutors;
import org.testng.annotations.Test;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.fail;

        } catch (InternalServerErrorServiceException e) {
            assertEquals(e.getFaultInfo().getBlame(), Blame.SERVER);
            assertFalse(e.getFaultInfo().getRetrySameLocation().isPresent());
        }
    }


    @Test
    public void testCall3() throws Exception {
        try {
            execute(ExceptionType.AccessDeniedNoSuchAccount);
            fail("Expected exception!");
        } catch (AccessDeniedServiceException e) {
            assertEquals(e.getFaultInfo().getBlame(), Blame.CLIENT);
            assertEquals(e.getFaultInfo().getRetrySameLocation().get().getRetryType(), RetryType.NO);
        }
    }

//    @Test(expectedExceptions = AccessDeniedServiceException.class)
//    public void testCall4() throws Exception {
//        execute(ExceptionType.AccessDeniedRequestLimitExceeded);
//    }
//
//    @Test(expectedExceptions = AccessDeniedServiceException.class)
//    public void testCall5() throws Exception {
//        execute(ExceptionType.AccessDeniedTooManyConcurrentRequests);
//    }

    private void execute(ExceptionType type) throws Exception {
        ExceptionThrowerCommand command = new ExceptionThrowerCommand();
        Mode mode = FunctionalTestsNameApiModeFactory.functionalTest();