Search in sources :

Example 1 with FlagParseException

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

the class BuildApksCommandTest method nonPositiveMaxThreads_throws.

@Test
public void nonPositiveMaxThreads_throws() throws Exception {
    FlagParseException zeroException = assertThrows(FlagParseException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--max-threads=0"), fakeAdbServer));
    assertThat(zeroException).hasMessageThat().contains("flag --max-threads has illegal value");
    FlagParseException negativeException = assertThrows(FlagParseException.class, () -> BuildApksCommand.fromFlags(new FlagParser().parse("--bundle=" + bundlePath, "--output=" + outputFilePath, "--max-threads=-1"), fakeAdbServer));
    assertThat(negativeException).hasMessageThat().contains("flag --max-threads has illegal value");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 2 with FlagParseException

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

the class FlagParserTest method incorrectCommandLineFlags_throws.

@Test
public void incorrectCommandLineFlags_throws() throws Exception {
    FlagParseException e = assertThrows(FlagParseException.class, () -> new FlagParser().parse("command", "--flag1=value1", "-flag2=value2"));
    assertThat(e).hasMessageThat().contains("-flag2=value2");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 3 with FlagParseException

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

the class FlagParserTest method listFlag_setMultipleTimes_throws.

@Test
public void listFlag_setMultipleTimes_throws() throws Exception {
    ParsedFlags fp = new FlagParser().parse("command", "--flag1=v1", "--flag1=v2");
    FlagParseException e = assertThrows(FlagParseException.class, () -> Flag.stringList("flag1").getRequiredValue(fp));
    assertThat(e).hasMessageThat().contains("Flag --flag1 has been set more than once");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 4 with FlagParseException

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

the class FlagParserTest method listFlag_setMultipleTimesMixedSeparators_throws.

@Test
public void listFlag_setMultipleTimesMixedSeparators_throws() throws Exception {
    ParsedFlags fp = new FlagParser().parse("command", "--flag1", "v1", "--flag1=v2");
    FlagParseException e = assertThrows(FlagParseException.class, () -> Flag.stringList("flag1").getRequiredValue(fp));
    assertThat(e).hasMessageThat().contains("Flag --flag1 has been set more than once");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 5 with FlagParseException

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

the class FlagTest method nonNegativeIntegerFlag_negative_throws.

@Test
public void nonNegativeIntegerFlag_negative_throws() throws Exception {
    Flag<Integer> flag = Flag.nonNegativeInteger("testFlag");
    ParsedFlags parsedFlags = new FlagParser().parse("--testFlag=-1");
    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)

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