Search in sources :

Example 11 with FlagParseException

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

the class FlagParserTest method listFlag_setMultipleTimesWithSpace_throws.

@Test
public void listFlag_setMultipleTimesWithSpace_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 12 with FlagParseException

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

the class FlagParserTest method duplicateSimpleFlag_throws.

@Test
public void duplicateSimpleFlag_throws() throws Exception {
    FlagParseException e = assertThrows(FlagParseException.class, () -> new FlagParser().parse("command", "--flag=v1", "--flag=v2").getFlagValue("flag"));
    assertThat(e).hasMessageThat().contains("flag");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 13 with FlagParseException

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

the class FlagParserTest method booleanFlag_nonTrueFalse_throws.

@Test
public void booleanFlag_nonTrueFalse_throws() throws Exception {
    ParsedFlags fp = new FlagParser().parse("command", "--boolFlag=no");
    FlagParseException exception = assertThrows(FlagParseException.class, () -> Flag.booleanFlag("boolFlag").getRequiredValue(fp));
    assertThat(exception).hasMessageThat().contains("Error while parsing the boolean flag");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 14 with FlagParseException

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

the class FlagParserTest method listFlag_multipleValuesWithSpaceInValue_throws.

@Test
public void listFlag_multipleValuesWithSpaceInValue_throws() throws Exception {
    FlagParseException e = assertThrows(FlagParseException.class, () -> new FlagParser().parse("command", "--flag1", "v1", "v2", "v3"));
    assertThat(e).hasMessageThat().contains("Syntax error: flags should start with -- (v2)");
}
Also used : FlagParseException(com.android.tools.build.bundletool.flags.FlagParser.FlagParseException) Test(org.junit.Test)

Example 15 with FlagParseException

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

the class FlagTest method positiveIntegerFlag_negative_throws.

@Test
public void positiveIntegerFlag_negative_throws() throws Exception {
    Flag<Integer> flag = Flag.positiveInteger("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