Search in sources :

Example 1 with SubValidator

use of com.android.tools.build.bundletool.validation.SubValidator in project bundletool by google.

the class BuildApksValidationTest method extraValidator_runsValidation.

@Test
public void extraValidator_runsValidation() throws Exception {
    createAppBundle(bundlePath);
    SubValidator extraValidator = new SubValidator() {

        @Override
        public void validateBundle(AppBundle bundle) {
            throw InvalidBundleException.builder().withUserMessage("Custom validator").build();
        }
    };
    BuildApksCommand command = BuildApksCommand.builder().setBundlePath(bundlePath).setOutputFile(outputFilePath).setExtraValidators(ImmutableList.of(extraValidator)).build();
    Exception e = assertThrows(InvalidBundleException.class, command::execute);
    assertThat(e).hasMessageThat().contains("Custom validator");
}
Also used : AppBundle(com.android.tools.build.bundletool.model.AppBundle) SubValidator(com.android.tools.build.bundletool.validation.SubValidator) InvalidBundleException(com.android.tools.build.bundletool.model.exceptions.InvalidBundleException) IOException(java.io.IOException) Test(org.junit.Test)

Aggregations

AppBundle (com.android.tools.build.bundletool.model.AppBundle)1 InvalidBundleException (com.android.tools.build.bundletool.model.exceptions.InvalidBundleException)1 SubValidator (com.android.tools.build.bundletool.validation.SubValidator)1 IOException (java.io.IOException)1 Test (org.junit.Test)1