Deduplicate types in tests

This commit is contained in:
Daniel Martí 2015-11-13 18:45:59 +01:00
parent 14a79b5577
commit 52ada0131a
4 changed files with 11 additions and 11 deletions

View File

@ -10,7 +10,7 @@ public class MockEmptyPackageManager extends MockPackageManager {
@Override
public List<PackageInfo> getInstalledPackages(int flags) {
return new ArrayList<PackageInfo>();
return new ArrayList<>();
}
}

View File

@ -51,7 +51,7 @@ public class ApkProviderHelperTest extends BaseApkProviderTest {
new MockApk("info.example", 2),
};
List<Apk> apksToCheck = new ArrayList<Apk>(known.length + unknown.length);
List<Apk> apksToCheck = new ArrayList<>(known.length + unknown.length);
Collections.addAll(apksToCheck, known);
Collections.addAll(apksToCheck, unknown);

View File

@ -33,7 +33,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertInvalidUri(ApkProvider.getAuthority());
assertInvalidUri(RepoProvider.getContentUri());
List<Apk> apks = new ArrayList<Apk>(3);
List<Apk> apks = new ArrayList<>(3);
for (int i = 0; i < 10; i++) {
apks.add(new MockApk("com.example." + i, i));
}
@ -46,7 +46,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertValidUri(ApkProvider.getContentUri("org.fdroid.fdroid", 100));
assertValidUri(ApkProvider.getRepoUri(1000));
List<Apk> manyApks = new ArrayList<Apk>(PublicApkProvider.MAX_APKS_TO_QUERY - 5);
List<Apk> manyApks = new ArrayList<>(PublicApkProvider.MAX_APKS_TO_QUERY - 5);
for (int i = 0; i < PublicApkProvider.MAX_APKS_TO_QUERY - 1; i++) {
manyApks.add(new MockApk("com.example." + i, i));
}
@ -100,7 +100,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
public void testInvalidUpdateUris() {
Apk apk = new MockApk("org.fdroid.fdroid", 10);
List<Apk> apks = new ArrayList<Apk>();
List<Apk> apks = new ArrayList<>();
apks.add(apk);
assertCantUpdate(ApkProvider.getContentUri());
@ -137,14 +137,14 @@ public class ApkProviderTest extends BaseApkProviderTest {
};
List<Apk> all = ApkProvider.Helper.findByRepo(getSwappableContext(), new MockRepo(10), ApkProvider.DataColumns.ALL);
List<String> actualIds = new ArrayList<String>();
List<String> actualIds = new ArrayList<>();
for (Apk apk : all) {
actualIds.add(apk.id);
}
TestUtils.assertContainsOnly(actualIds, expectedIds);
List<Apk> toDelete = new ArrayList<Apk>(3);
List<Apk> toDelete = new ArrayList<>(3);
toDelete.add(two);
toDelete.add(three);
toDelete.add(four);
@ -153,7 +153,7 @@ public class ApkProviderTest extends BaseApkProviderTest {
assertTotalApkCount(2);
List<Apk> allRemaining = ApkProvider.Helper.findByRepo(getSwappableContext(), new MockRepo(10), ApkProvider.DataColumns.ALL);
List<String> actualRemainingIds = new ArrayList<String>();
List<String> actualRemainingIds = new ArrayList<>();
for (Apk apk : allRemaining) {
actualRemainingIds.add(apk.id);
}

View File

@ -35,19 +35,19 @@ public class TestUtils {
private static final String TAG = "TestUtils";
public static <T extends Comparable> void assertContainsOnly(List<T> actualList, T[] expectedArray) {
List<T> expectedList = new ArrayList<T>(expectedArray.length);
List<T> expectedList = new ArrayList<>(expectedArray.length);
Collections.addAll(expectedList, expectedArray);
assertContainsOnly(actualList, expectedList);
}
public static <T extends Comparable> void assertContainsOnly(T[] actualArray, List<T> expectedList) {
List<T> actualList = new ArrayList<T>(actualArray.length);
List<T> actualList = new ArrayList<>(actualArray.length);
Collections.addAll(actualList, actualArray);
assertContainsOnly(actualList, expectedList);
}
public static <T extends Comparable> void assertContainsOnly(T[] actualArray, T[] expectedArray) {
List<T> expectedList = new ArrayList<T>(expectedArray.length);
List<T> expectedList = new ArrayList<>(expectedArray.length);
Collections.addAll(expectedList, expectedArray);
assertContainsOnly(actualArray, expectedList);
}