@Theory public void when_new_column_contains_illegal_character_ISA_is_thrown ( @FromDataPoints("database") DatabaseAndResult database, @FromDataPoints("columnDef") ColumnDef columnDef, @FromDataPoints("illegalColumnName") String illegalColumnName) { String tableName = "table_" + randomAlphabetic(6).toLowerCase(); expectedException.expect(IllegalArgumentException.class); new RenameColumnsBuilder(database.getDialect(), tableName) .renameColumn(illegalColumnName, columnDef) .build(); }
@Override protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) { Collection<Field> fields = super.getSingleDataPointFields(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<Field> fieldsWithMatchingNames = new ArrayList<Field>(); for (Field field : fields) { String[] fieldNames = field.getAnnotation(DataPoint.class).value(); if (Arrays.asList(fieldNames).contains(requestedName)) { fieldsWithMatchingNames.add(field); } } return fieldsWithMatchingNames; }
@Theory public void checkSQL_results( @FromDataPoints("database") DatabaseAndResult database, @FromDataPoints("columnDef") ColumnDef columnDef) { String oldColumnName = "old_" + randomAlphabetic(6).toLowerCase(); String tableName = "table_" + randomAlphabetic(6).toLowerCase(); List<String> result = new RenameColumnsBuilder(database.getDialect(), tableName) .renameColumn(oldColumnName, columnDef) .build(); Map<String, String> parameters = new HashMap<>(); parameters.put("table_name", tableName); parameters.put("old_column_name", oldColumnName); parameters.put("new_column_name", NEW_COLUMN_NAME); parameters.put("column_def", columnDef.generateSqlType(database.getDialect())); String expectedResult = StrSubstitutor.replace(database.getTemplateSql(), parameters); assertThat(result).containsExactlyInAnyOrder(expectedResult); }
@Override protected Collection<Field> getDataPointsFields(ParameterSignature sig) { Collection<Field> fields = super.getDataPointsFields(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<Field> fieldsWithMatchingNames = new ArrayList<Field>(); for (Field field : fields) { String[] fieldNames = field.getAnnotation(DataPoints.class).value(); if (Arrays.asList(fieldNames).contains(requestedName)) { fieldsWithMatchingNames.add(field); } } return fieldsWithMatchingNames; }
@Theory public void when_old_column_is_same_as_new_column_ISA_is_thrown ( @FromDataPoints("database") DatabaseAndResult database, @FromDataPoints("columnDef") ColumnDef columnDef) { String tableName = "table_" + randomAlphabetic(6).toLowerCase(); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Column names must be different"); new RenameColumnsBuilder(database.getDialect(), tableName) .renameColumn(NEW_COLUMN_NAME, columnDef) .build(); }
@Override protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) { Collection<FrameworkMethod> methods = super.getSingleDataPointMethods(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>(); for (FrameworkMethod method : methods) { String[] methodNames = method.getAnnotation(DataPoint.class).value(); if (Arrays.asList(methodNames).contains(requestedName)) { methodsWithMatchingNames.add(method); } } return methodsWithMatchingNames; }
@Test @Theory public void apexModule_getsBestPossibleApk( @FromDataPoints("apksInDirectory") boolean apksInDirectory) throws Exception { ZipPath x64Apk = ZipPath.create("standalones/standalone-x86_64.apk"); ZipPath x64X86Apk = ZipPath.create("standalones/standalone-x86_64.x86.apk");
@Override protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) { Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>(); for (FrameworkMethod method : methods) { String[] methodNames = method.getAnnotation(DataPoints.class).value(); if (Arrays.asList(methodNames).contains(requestedName)) { methodsWithMatchingNames.add(method); } } return methodsWithMatchingNames; }
@Test @Theory public void singleModule_withNativeLibsAndDensity_64bitNativeLibsDisabled( @FromDataPoints("standaloneSplitTypes") SplitType standaloneSplitType) throws Exception {
@Override protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) { Collection<Field> fields = super.getSingleDataPointFields(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<Field> fieldsWithMatchingNames = new ArrayList<Field>(); for (Field field : fields) { String[] fieldNames = field.getAnnotation(DataPoint.class).value(); if (Arrays.asList(fieldNames).contains(requestedName)) { fieldsWithMatchingNames.add(field); } } return fieldsWithMatchingNames; }
@Test @Theory public void simpleMultipleModules( @FromDataPoints("standaloneSplitTypes") SplitType standaloneSplitType) throws Exception { ImmutableList<BundleModule> bundleModule = ImmutableList.of( new BundleModuleBuilder("base") .addFile("assets/leftover.txt") .setManifest(androidManifest("com.test.app")) .build(), new BundleModuleBuilder("test") .addFile("assets/test.txt") .setManifest(androidManifest("com.test.app")) .build()); ImmutableList<ModuleSplit> moduleSplits = generateModuleSplits(bundleModule, standaloneSplitType, /* generate64BitShards= */ true); assertThat(moduleSplits).hasSize(1); ModuleSplit moduleSplit = moduleSplits.get(0); assertThat(moduleSplit.getSplitType()).isEqualTo(standaloneSplitType); assertThat(getEntriesPaths(moduleSplit)) .containsExactly("assets/test.txt", "assets/leftover.txt"); assertThat(moduleSplit.getVariantTargeting()).isEqualTo(variantMinSdkTargeting(1)); }
@Override protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) { Collection<Field> fields = super.getSingleDataPointFields(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<Field> fieldsWithMatchingNames = new ArrayList<Field>(); for (Field field : fields) { String[] fieldNames = field.getAnnotation(DataPoint.class).value(); if (Arrays.asList(fieldNames).contains(requestedName)) { fieldsWithMatchingNames.add(field); } } return fieldsWithMatchingNames; }
@Test @Theory public void shardByAbiAndDensity_havingNoAbiAndNoResources_producesOneApk( @FromDataPoints("deviceSpecs") Optional<DeviceSpec> deviceSpec) throws Exception { bundleSharder = new BundleSharder( tmpDir, BundleToolVersion.getCurrentVersion(), /* generate64BitShards= */ true, deviceSpec); BundleModule bundleModule = new BundleModuleBuilder("base") .addFile("assets/file.txt") .addFile("dex/classes.dex") .addFile("root/license.dat") .setManifest(androidManifest("com.test.app")) .build(); ImmutableList<ModuleSplit> shards = bundleSharder.shardBundle( ImmutableList.of(bundleModule), ImmutableSet.of(OptimizationDimension.ABI, OptimizationDimension.SCREEN_DENSITY), DEFAULT_METADATA); assertThat(shards).hasSize(1); ModuleSplit fatShard = shards.get(0); assertThat(fatShard.getApkTargeting()).isEqualToDefaultInstance(); assertThat(fatShard.getVariantTargeting()).isEqualToDefaultInstance(); assertThat(fatShard.getSplitType()).isEqualTo(SplitType.STANDALONE); assertThat(extractPaths(fatShard.getEntries())) .containsExactly("assets/file.txt", "dex/classes.dex", "root/license.dat"); }
@Override protected Collection<Field> getDataPointsFields(ParameterSignature sig) { Collection<Field> fields = super.getDataPointsFields(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<Field> fieldsWithMatchingNames = new ArrayList<Field>(); for (Field field : fields) { String[] fieldNames = field.getAnnotation(DataPoints.class).value(); if (Arrays.asList(fieldNames).contains(requestedName)) { fieldsWithMatchingNames.add(field); } } return fieldsWithMatchingNames; }
@Test @Theory public void singleModule_withNativeLibsAndDensity( @FromDataPoints("standaloneSplitTypes") SplitType standaloneSplitType) throws Exception {
@Override protected Collection<Field> getDataPointsFields(ParameterSignature sig) { Collection<Field> fields = super.getDataPointsFields(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<Field> fieldsWithMatchingNames = new ArrayList<Field>(); for (Field field : fields) { String[] fieldNames = field.getAnnotation(DataPoints.class).value(); if (Arrays.asList(fieldNames).contains(requestedName)) { fieldsWithMatchingNames.add(field); } } return fieldsWithMatchingNames; }
@Test @Theory public void moduleDependencies_installDependency( @FromDataPoints("apksInDirectory") boolean apksInDirectory) throws Exception { BuildApksResult tableOfContent = BuildApksResult.newBuilder()
@Override protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) { Collection<FrameworkMethod> methods = super.getSingleDataPointMethods(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>(); for (FrameworkMethod method : methods) { String[] methodNames = method.getAnnotation(DataPoint.class).value(); if (Arrays.asList(methodNames).contains(requestedName)) { methodsWithMatchingNames.add(method); } } return methodsWithMatchingNames; }
@Test @Theory public void installsOnlySpecifiedModules( @FromDataPoints("apksInDirectory") boolean apksInDirectory) throws Exception { BuildApksResult tableOfContent = BuildApksResult.newBuilder()
@Override protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) { Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig); String requestedName = sig.getAnnotation(FromDataPoints.class).value(); List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>(); for (FrameworkMethod method : methods) { String[] methodNames = method.getAnnotation(DataPoints.class).value(); if (Arrays.asList(methodNames).contains(requestedName)) { methodsWithMatchingNames.add(method); } } return methodsWithMatchingNames; }