DatabasePersistence extends Persistence { @Override public boolean setMaxStorageSize(long maxStorageSizeInBytes) { return mDatabaseManager.setMaxSize(maxStorageSizeInBytes); } DatabasePersistence(Context context);   DatabasePersistence(Context context, int version, @SuppressWarnings("SameParameterValue") final ContentValues schema); @Override boolean setMaxStorageSize(long maxStorageSizeInBytes); @Override long putLog(@NonNull Log log, @NonNull String group, @IntRange(from = Flags.NORMAL, to = Flags.CRITICAL) int flags); @Override void deleteLogs(@NonNull String group, @NonNull String id); @Override void deleteLogs(String group); @Override int countLogs(@NonNull String group); @Override @Nullable String getLogs(@NonNull String group, @NonNull Collection<String> pausedTargetKeys, @IntRange(from = 0) int limit, @NonNull List<Log> outLogs); @Override void clearPendingLogState(); @Override void close();  }
@Test public void checkSetStorageSizeForwarding() throws Exception { DatabaseManager databaseManager = mock(DatabaseManager.class); whenNew(DatabaseManager.class).withAnyArguments().thenReturn(databaseManager); when(databaseManager.getCursor(any(SQLiteQueryBuilder.class), any(String[].class), any(String[].class), anyString())) .thenReturn(mock(Cursor.class)); when(databaseManager.setMaxSize(anyLong())).thenReturn(true).thenReturn(false); DatabasePersistence persistence = new DatabasePersistence(mock(Context.class)); assertTrue(persistence.setMaxStorageSize(20480)); assertFalse(persistence.setMaxStorageSize(2)); }