Search in sources :

Example 11 with InvalidCommandException

use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.

the class BuildSdkApksCommandTest method keyAliasSet_keystoreNotSet_throws.

@Test
public void keyAliasSet_keystoreNotSet_throws() {
    InvalidCommandException e = assertThrows(InvalidCommandException.class, () -> BuildSdkApksCommand.fromFlags(getDefaultFlagsWithAdditionalFlags("--ks-key-alias=" + KEY_ALIAS)));
    assertThat(e).hasMessageThat().isEqualTo("Flag --ks is required when --ks-key-alias is set.");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) Test(org.junit.Test)

Example 12 with InvalidCommandException

use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.

the class DumpCommandTest method dumpInvalidTarget.

@Test
public void dumpInvalidTarget() {
    InvalidCommandException exception = assertThrows(InvalidCommandException.class, () -> DumpCommand.fromFlags(new FlagParser().parse("dump", "blah", "--bundle=" + bundlePath)));
    assertThat(exception).hasMessageThat().matches("Unrecognized dump target: 'blah'. Accepted values are: .*");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 13 with InvalidCommandException

use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.

the class DumpCommandTest method dumpManifest_printValues_throws.

@Test
public void dumpManifest_printValues_throws() throws Exception {
    createBundle(bundlePath);
    DumpCommand dumpCommand = DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.MANIFEST).setPrintValues(true).build();
    InvalidCommandException exception = assertThrows(InvalidCommandException.class, dumpCommand::execute);
    assertThat(exception).hasMessageThat().contains("Printing resource values can only be requested when dumping resources.");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) Test(org.junit.Test)

Example 14 with InvalidCommandException

use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.

the class DumpCommandTest method dumpManifest_resourceIdSet_throws.

@Test
public void dumpManifest_resourceIdSet_throws() throws Exception {
    createBundle(bundlePath);
    DumpCommand dumpCommand = DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.MANIFEST).setResourceId(0x12345678).build();
    InvalidCommandException exception = assertThrows(InvalidCommandException.class, dumpCommand::execute);
    assertThat(exception).hasMessageThat().contains("The resource name/id can only be passed when dumping resources.");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) Test(org.junit.Test)

Example 15 with InvalidCommandException

use of com.android.tools.build.bundletool.model.exceptions.InvalidCommandException in project bundletool by google.

the class DumpCommandTest method dumpResources_resourceIdAndResourceNameSet_throws.

@Test
public void dumpResources_resourceIdAndResourceNameSet_throws() throws Exception {
    createBundle(bundlePath);
    DumpCommand dumpCommand = DumpCommand.builder().setBundlePath(bundlePath).setDumpTarget(DumpTarget.RESOURCES).setResourceId(0x12345678).setResourceName("drawable/icon").build();
    InvalidCommandException exception = assertThrows(InvalidCommandException.class, dumpCommand::execute);
    assertThat(exception).hasMessageThat().contains("Cannot pass both resource ID and resource name.");
}
Also used : InvalidCommandException(com.android.tools.build.bundletool.model.exceptions.InvalidCommandException) Test(org.junit.Test)

Aggregations

InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)26 Test (org.junit.Test)26 FlagParser (com.android.tools.build.bundletool.flags.FlagParser)12 ZipPath (com.android.tools.build.bundletool.model.ZipPath)6 BuildApksResult (com.android.bundle.Commands.BuildApksResult)4 DeviceSpec (com.android.bundle.Devices.DeviceSpec)3 ImmutableSet (com.google.common.collect.ImmutableSet)3 Path (java.nio.file.Path)3 SystemEnvironmentProvider (com.android.tools.build.bundletool.model.utils.SystemEnvironmentProvider)1 FakeSystemEnvironmentProvider (com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 PrintStream (java.io.PrintStream)1