Search in sources :

Example 11 with DatabaseManager

use of com.microsoft.appcenter.utils.storage.DatabaseManager in project mobile-center-sdk-android by Microsoft.

the class DatabasePersistenceTest method checkSetStorageSizeForwarding.

@Test
public void checkSetStorageSizeForwarding() throws Exception {
    /* The real Android test for checking size is in DatabaseManagerAndroidTest. */
    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);
    /* Just checks calls are forwarded to the low level database layer. */
    DatabasePersistence persistence = new DatabasePersistence(mock(Context.class));
    assertTrue(persistence.setMaxStorageSize(20480));
    assertFalse(persistence.setMaxStorageSize(2));
}
Also used : Context(android.content.Context) DatabaseManager(com.microsoft.appcenter.utils.storage.DatabaseManager) Cursor(android.database.Cursor) SQLiteQueryBuilder(android.database.sqlite.SQLiteQueryBuilder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

DatabaseManager (com.microsoft.appcenter.utils.storage.DatabaseManager)11 Context (android.content.Context)10 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)9 Cursor (android.database.Cursor)8 SQLiteQueryBuilder (android.database.sqlite.SQLiteQueryBuilder)8 Log (com.microsoft.appcenter.ingestion.models.Log)8 AppCenterLog (com.microsoft.appcenter.utils.AppCenterLog)7 ArrayList (java.util.ArrayList)6 LogSerializer (com.microsoft.appcenter.ingestion.models.json.LogSerializer)5 ContentValues (android.content.ContentValues)4 Matchers.anyString (org.mockito.Matchers.anyString)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 ApplicationInfo (android.content.pm.ApplicationInfo)1 SQLiteDiskIOException (android.database.sqlite.SQLiteDiskIOException)1 Handler (android.os.Handler)1 HandlerThread (android.os.HandlerThread)1 Looper (android.os.Looper)1 MediumTest (androidx.test.filters.MediumTest)1 DefaultLogSerializer (com.microsoft.appcenter.ingestion.models.json.DefaultLogSerializer)1