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.");
}
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: .*");
}
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.");
}
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.");
}
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.");
}
Aggregations