Search in sources :

Example 6 with FlagParseException

use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.

the class FlagTest method positiveIntegerFlag_zero_throws.

@Test
public void positiveIntegerFlag_zero_throws() throws Exception {
    Flag<Integer> flag = Flag.positiveInteger("testFlag");
    ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=0");
    FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
    assertThat(exception).hasMessageThat().contains("has illegal value");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 7 with FlagParseException

use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.

the class FlagTest method positiveIntegerFlag_notANumber_throws.

@Test
public void positiveIntegerFlag_notANumber_throws() throws Exception {
    Flag<Integer> flag = Flag.positiveInteger("testFlag");
    ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=blah");
    FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
    assertThat(exception).hasMessageThat().contains("Error while parsing");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 8 with FlagParseException

use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.

the class FlagTest method nonNegativeIntegerFlag_notANumber_throws.

@Test
public void nonNegativeIntegerFlag_notANumber_throws() throws Exception {
    Flag<Integer> flag = Flag.nonNegativeInteger("testFlag");
    ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=blah");
    FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getValue(parsedFlags));
    assertThat(exception).hasMessageThat().contains("Error while parsing");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 9 with FlagParseException

use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.

the class BuildSdkApksCommandTest method nonPositiveMaxThreads_throws.

@Test
public void nonPositiveMaxThreads_throws() throws Exception {
    FlagParseException zeroException = assertThrows(FlagParseException.class, () -> BuildSdkApksCommand.fromFlags(getDefaultFlagsWithAdditionalFlags("--max-threads=0")));
    assertThat(zeroException).hasMessageThat().contains("flag --max-threads has illegal value");
    FlagParseException negativeException = assertThrows(FlagParseException.class, () -> BuildSdkApksCommand.fromFlags(getDefaultFlagsWithAdditionalFlags("--max-threads=-3")));
    assertThat(negativeException).hasMessageThat().contains("flag --max-threads has illegal value");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 10 with FlagParseException

use of com.android.tools.build.bundletool.flags.FlagParser.FlagParseException in project bundletool by google.

the class FlagTest method keyValueFlag_missingKeyValueDelimiter_throws.

@Test
public void keyValueFlag_missingKeyValueDelimiter_throws() throws Exception {
    Flag<Map.Entry<String, String>> flag = Flag.keyValue("testFlag", String.class, String.class);
    ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=key=value");
    FlagParseException exception = assertThrows(FlagParseException.class, () -> flag.getRequiredValue(parsedFlags));
    assertThat(exception).hasMessageThat().contains("must contain ':'");
}
Also used : Entry(java.util.Map.Entry) FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Aggregations

FlagParseException (com.android.tools.build.bundletool.flags.FlagParser.FlagParseException)15 Test (org.junit.Test)15 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)1 Entry (java.util.Map.Entry)1