Search in sources :

Example 86 with FlagParser

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

the class CheckTransparencyCommandTest method buildingCommandViaFlags_bundleMode_unknownFlagSet.

@Test
public void buildingCommandViaFlags_bundleMode_unknownFlagSet() {
    Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=BUNDLE", "--bundle=" + bundlePath, "--unknownFlag=hello"), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Unrecognized flags");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 87 with FlagParser

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

the class CheckTransparencyCommandTest method buildingCommandViaFlags_apkMode_adbPathSet.

@Test
public void buildingCommandViaFlags_apkMode_adbPathSet() {
    Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=APK", "--apk-zip=" + apkZipPath, "--adb=path/to/adb"), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Unrecognized flags");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 88 with FlagParser

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

the class CheckTransparencyCommandTest method buildingCommandViaFlags_connectedDeviceMode_unknownFlagSet.

@Test
public void buildingCommandViaFlags_connectedDeviceMode_unknownFlagSet() {
    Throwable e = assertThrows(UnknownFlagsException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=CONNECTED_DEVICE", "--connected-device=true", "--adb=" + ADB_PATH, "--package-name=" + PACKAGE_NAME, "--unknownFlag=hello"), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Unrecognized flags");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 89 with FlagParser

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

the class CheckTransparencyCommandTest method buildingCommandViaFlags_bundleMode_bundlePathNotSet.

@Test
public void buildingCommandViaFlags_bundleMode_bundlePathNotSet() {
    Throwable e = assertThrows(RequiredFlagNotSetException.class, () -> CheckTransparencyCommand.fromFlags(new FlagParser().parse("--mode=BUNDLE"), systemEnvironmentProvider, fakeAdbServer));
    assertThat(e).hasMessageThat().contains("Missing the required --bundle flag");
}
Also used : FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Example 90 with FlagParser

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

the class ExtractApksCommandTest method missingApksArchiveFlag_throws.

@Test
public void missingApksArchiveFlag_throws() throws Exception {
    Path deviceSpecFile = createDeviceSpecFile(DeviceSpec.getDefaultInstance(), tmpDir.resolve("device.json"));
    expectMissingRequiredFlagException("apks", () -> ExtractApksCommand.fromFlags(new FlagParser().parse("--device-spec=" + deviceSpecFile)));
}
Also used : Path(java.nio.file.Path) ZipPath(com.android.tools.build.bundletool.model.ZipPath) FlagParser(com.android.tools.build.bundletool.flags.FlagParser) Test(org.junit.Test)

Aggregations

FlagParser (com.android.tools.build.bundletool.flags.FlagParser)138 Test (org.junit.Test)137 Path (java.nio.file.Path)63 ZipPath (com.android.tools.build.bundletool.model.ZipPath)55 ByteArrayOutputStream (java.io.ByteArrayOutputStream)29 PrintStream (java.io.PrintStream)29 BuildApksResult (com.android.bundle.Commands.BuildApksResult)22 InvalidCommandException (com.android.tools.build.bundletool.model.exceptions.InvalidCommandException)20 DeviceSpec (com.android.bundle.Devices.DeviceSpec)13 ParsedFlags (com.android.tools.build.bundletool.flags.ParsedFlags)12 ApksigSigningConfiguration (com.android.tools.build.bundletool.model.ApksigSigningConfiguration)10 SigningConfiguration (com.android.tools.build.bundletool.model.SigningConfiguration)10 FlagParseException (com.android.tools.build.bundletool.flags.FlagParser.FlagParseException)8 CommandExecutionException (com.android.tools.build.bundletool.model.exceptions.CommandExecutionException)8 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)8 TestUtils.expectMissingRequiredBuilderPropertyException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredBuilderPropertyException)8 TestUtils.expectMissingRequiredFlagException (com.android.tools.build.bundletool.testing.TestUtils.expectMissingRequiredFlagException)8 IOException (java.io.IOException)8 JoseException (org.jose4j.lang.JoseException)7 FakeSystemEnvironmentProvider (com.android.tools.build.bundletool.testing.FakeSystemEnvironmentProvider)6