// Path: src/main/java/com/github/jankroken/commandline/ParseResult.java
// public class ParseResult<T> {
//     public enum ErrorType {
//         OK,
//         INTERNAL_ERROR,
//         INVALID_COMMAND_LINE,
//         INVALID_OPTION_CONFIGURATION,
//         UNRECOGNIZED_SWITCH,
//         INVALID_CONFIGURATION
//     }
// 
//     private final ErrorType errorType;
//     private final boolean success;
//     private final T value;
//     private final Exception rootCause;
//     private final String errorMessage;
// 
//     protected ParseResult(Exception e, boolean success, T value) {
//         errorType = success ? OK : toErrorType(e);
//         rootCause = e;
//         errorMessage = e == null ? null : e.getMessage();
//         this.success = success;
//         this.value = value;
//     }
// 
//     protected ParseResult(Exception t) {
//         this(t, false, null);
//     }
// 
//     protected ParseResult(T value) {
//         this(null, true, value);
//     }
// 
//     public Optional<T> toOptional() {
//         if (success) return Optional.of(value);
//         else return Optional.empty();
//     }
// 
//     public T get() throws CommandLineWrappedException {
//         if (success) return value;
//         throw new CommandLineWrappedException(rootCause);
//     }
// 
//     public <R> ParseResult<R> map(Function<T, R> f) {
//         if (success) {
//             return new ParseResult(f.apply(value));
//         } else {
//             return new ParseResult(rootCause);
//         }
//     }
// 
//     private static ErrorType toErrorType(Exception e) {
//         if (e instanceof InternalErrorException) return INTERNAL_ERROR;
//         if (e instanceof InvalidCommandLineException) return INVALID_COMMAND_LINE;
//         if (e instanceof InvalidOptionConfigurationException) return INVALID_OPTION_CONFIGURATION;
//         if (e instanceof UnrecognizedSwitchException) return UNRECOGNIZED_SWITCH;
//         if (e instanceof InvocationTargetException) return INVALID_CONFIGURATION;
//         if (e instanceof IllegalAccessException) return INVALID_CONFIGURATION;
//         if (e instanceof InstantiationException) return INVALID_CONFIGURATION;
//         throw new RuntimeException("Implementation error: unhandled exception", e);
//     }
// 
//     public ErrorType getErrorType() {
//         return errorType;
//     }
// 
//     public boolean isSuccess() {
//         return success;
//     }
// 
//     public Exception getRootCause() {
//         return rootCause;
//     }
// 
//     public String getErrorMessage() {
//         return errorMessage;
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/domain/CommandLineWrappedException.java
// public class CommandLineWrappedException extends CommandLineException {
//     public CommandLineWrappedException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/domain/InvalidCommandLineException.java
// public class InvalidCommandLineException extends CommandLineException {
//     private static final long serialVersionUID = 2L;
// 
//     public InvalidCommandLineException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/domain/UnrecognizedSwitchException.java
// public class UnrecognizedSwitchException extends CommandLineException {
//     private static final long serialVersionUID = 2L;
//     private String _switch;
// 
//     public UnrecognizedSwitchException(Class<?> configurationClass, String _switch) {
//         super(configurationClass + ": " + _switch);
//         this._switch = _switch;
//     }
// 
//     public String getSwitch() {
//         return _switch;
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/CommandLineParser.java
// public static <T> T parse(Class<T> optionClass, String[] args, OptionStyle style)
//         throws IllegalAccessException, InstantiationException, InvocationTargetException {
//     T spec;
//     try {
//         spec = optionClass.getConstructor().newInstance();
//     } catch (NoSuchMethodException noSuchMethodException) {
//         throw new RuntimeException(noSuchMethodException);
//     }
//     var optionSet = new OptionSet(spec, MAIN_OPTIONS);
//     Tokenizer tokenizer;
//     if (style == SIMPLE) {
//         tokenizer = new SimpleTokenizer(new PeekIterator<>(new ArrayIterator<>(args)));
//     } else {
//         tokenizer = new LongOrCompactTokenizer(new PeekIterator<>(new ArrayIterator<>(args)));
//     }
//     optionSet.consumeOptions(tokenizer);
//     return spec;
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/CommandLineParser.java
// public static <T> ParseResult<T> tryParse(Class<T> optionClass, String[] args, OptionStyle style) {
//     try {
//         return new ParseResult(parse(optionClass, args, style));
//     } catch(CommandLineException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
//         return new ParseResult(e);
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/util/Constants.java
// public static final String[] EMPTY_STRING_ARRAY = new String[]{};


import com.github.jankroken.commandline.ParseResult;
import com.github.jankroken.commandline.domain.CommandLineWrappedException;
import com.github.jankroken.commandline.domain.InvalidCommandLineException;
import com.github.jankroken.commandline.domain.UnrecognizedSwitchException;
import org.junit.jupiter.api.Test;
import static com.github.jankroken.commandline.CommandLineParser.parse;
import static com.github.jankroken.commandline.CommandLineParser.tryParse;
import static com.github.jankroken.commandline.OptionStyle.SIMPLE;
import static com.github.jankroken.commandline.util.Constants.EMPTY_STRING_ARRAY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
package com.github.jankroken.commandline.error;




public class InvalidArgumentsTests {

    @Test
    public void testMissingSwitches() {
        var args = EMPTY_STRING_ARRAY;
        assertThatThrownBy(() -> parse(RequiredConfiguration.class, args, SIMPLE))
// Path: src/main/java/com/github/jankroken/commandline/ParseResult.java
// public class ParseResult<T> {
//     public enum ErrorType {
//         OK,
//         INTERNAL_ERROR,
//         INVALID_COMMAND_LINE,
//         INVALID_OPTION_CONFIGURATION,
//         UNRECOGNIZED_SWITCH,
//         INVALID_CONFIGURATION
//     }
// 
//     private final ErrorType errorType;
//     private final boolean success;
//     private final T value;
//     private final Exception rootCause;
//     private final String errorMessage;
// 
//     protected ParseResult(Exception e, boolean success, T value) {
//         errorType = success ? OK : toErrorType(e);
//         rootCause = e;
//         errorMessage = e == null ? null : e.getMessage();
//         this.success = success;
//         this.value = value;
//     }
// 
//     protected ParseResult(Exception t) {
//         this(t, false, null);
//     }
// 
//     protected ParseResult(T value) {
//         this(null, true, value);
//     }
// 
//     public Optional<T> toOptional() {
//         if (success) return Optional.of(value);
//         else return Optional.empty();
//     }
// 
//     public T get() throws CommandLineWrappedException {
//         if (success) return value;
//         throw new CommandLineWrappedException(rootCause);
//     }
// 
//     public <R> ParseResult<R> map(Function<T, R> f) {
//         if (success) {
//             return new ParseResult(f.apply(value));
//         } else {
//             return new ParseResult(rootCause);
//         }
//     }
// 
//     private static ErrorType toErrorType(Exception e) {
//         if (e instanceof InternalErrorException) return INTERNAL_ERROR;
//         if (e instanceof InvalidCommandLineException) return INVALID_COMMAND_LINE;
//         if (e instanceof InvalidOptionConfigurationException) return INVALID_OPTION_CONFIGURATION;
//         if (e instanceof UnrecognizedSwitchException) return UNRECOGNIZED_SWITCH;
//         if (e instanceof InvocationTargetException) return INVALID_CONFIGURATION;
//         if (e instanceof IllegalAccessException) return INVALID_CONFIGURATION;
//         if (e instanceof InstantiationException) return INVALID_CONFIGURATION;
//         throw new RuntimeException("Implementation error: unhandled exception", e);
//     }
// 
//     public ErrorType getErrorType() {
//         return errorType;
//     }
// 
//     public boolean isSuccess() {
//         return success;
//     }
// 
//     public Exception getRootCause() {
//         return rootCause;
//     }
// 
//     public String getErrorMessage() {
//         return errorMessage;
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/domain/CommandLineWrappedException.java
// public class CommandLineWrappedException extends CommandLineException {
//     public CommandLineWrappedException(Throwable cause) {
//         super(cause);
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/domain/InvalidCommandLineException.java
// public class InvalidCommandLineException extends CommandLineException {
//     private static final long serialVersionUID = 2L;
// 
//     public InvalidCommandLineException(String message) {
//         super(message);
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/domain/UnrecognizedSwitchException.java
// public class UnrecognizedSwitchException extends CommandLineException {
//     private static final long serialVersionUID = 2L;
//     private String _switch;
// 
//     public UnrecognizedSwitchException(Class<?> configurationClass, String _switch) {
//         super(configurationClass + ": " + _switch);
//         this._switch = _switch;
//     }
// 
//     public String getSwitch() {
//         return _switch;
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/CommandLineParser.java
// public static <T> T parse(Class<T> optionClass, String[] args, OptionStyle style)
//         throws IllegalAccessException, InstantiationException, InvocationTargetException {
//     T spec;
//     try {
//         spec = optionClass.getConstructor().newInstance();
//     } catch (NoSuchMethodException noSuchMethodException) {
//         throw new RuntimeException(noSuchMethodException);
//     }
//     var optionSet = new OptionSet(spec, MAIN_OPTIONS);
//     Tokenizer tokenizer;
//     if (style == SIMPLE) {
//         tokenizer = new SimpleTokenizer(new PeekIterator<>(new ArrayIterator<>(args)));
//     } else {
//         tokenizer = new LongOrCompactTokenizer(new PeekIterator<>(new ArrayIterator<>(args)));
//     }
//     optionSet.consumeOptions(tokenizer);
//     return spec;
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/CommandLineParser.java
// public static <T> ParseResult<T> tryParse(Class<T> optionClass, String[] args, OptionStyle style) {
//     try {
//         return new ParseResult(parse(optionClass, args, style));
//     } catch(CommandLineException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
//         return new ParseResult(e);
//     }
// }
// 
// Path: src/main/java/com/github/jankroken/commandline/util/Constants.java
// public static final String[] EMPTY_STRING_ARRAY = new String[]{};


// Path: src/test/java/com/github/jankroken/commandline/error/InvalidArgumentsTests.java
import com.github.jankroken.commandline.ParseResult;
import com.github.jankroken.commandline.domain.CommandLineWrappedException;
import com.github.jankroken.commandline.domain.InvalidCommandLineException;
import com.github.jankroken.commandline.domain.UnrecognizedSwitchException;
import org.junit.jupiter.api.Test;
import static com.github.jankroken.commandline.CommandLineParser.parse;
import static com.github.jankroken.commandline.CommandLineParser.tryParse;
import static com.github.jankroken.commandline.OptionStyle.SIMPLE;
import static com.github.jankroken.commandline.util.Constants.EMPTY_STRING_ARRAY;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

package com.github.jankroken.commandline.error;




public class InvalidArgumentsTests {

    @Test
    public void testMissingSwitches() {
        var args = EMPTY_STRING_ARRAY;
        assertThatThrownBy(() -> parse(RequiredConfiguration.class, args, SIMPLE))
                .isInstanceOf(InvalidCommandLineException.class);