Search in sources :

Example 6 with Account

use of it.niedermann.owncloud.notes.persistence.entity.Account in project nextcloud-notes by stefan-niedermann.

the class NotesDaoTest method getFavoritesCount.

@Test
public void getFavoritesCount() throws InterruptedException {
    final Account secondAccount = setupSecondAccountAndTestNotes();
    assertEquals(Integer.valueOf(1), db.getNoteDao().countFavorites(account.getId()));
    assertEquals(Integer.valueOf(1), db.getNoteDao().countFavorites(secondAccount.getId()));
    assertEquals(Integer.valueOf(1), NotesTestingUtil.getOrAwaitValue(db.getNoteDao().countFavorites$(account.getId())));
    assertEquals(Integer.valueOf(1), NotesTestingUtil.getOrAwaitValue(db.getNoteDao().countFavorites$(secondAccount.getId())));
}
Also used : Account(it.niedermann.owncloud.notes.persistence.entity.Account) Test(org.junit.Test)

Example 7 with Account

use of it.niedermann.owncloud.notes.persistence.entity.Account in project nextcloud-notes by stefan-niedermann.

the class NotesRepositoryTest method updateDisplayName.

@Test
public void updateDisplayName() {
    final var account = db.getAccountDao().getAccountById(db.getAccountDao().insert(new Account("https://äöüß.example.com", "彼得", "彼得@äöüß.example.com", null, new Capabilities())));
    assertEquals("Should read userName in favor of displayName if displayName is NULL", "彼得", account.getDisplayName());
    repo.updateDisplayName(account.getId(), "");
    assertEquals("Should properly update the displayName, even if it is blank", "", db.getAccountDao().getAccountById(account.getId()).getDisplayName());
    repo.updateDisplayName(account.getId(), "Foo Bar");
    assertEquals("Foo Bar", db.getAccountDao().getAccountById(account.getId()).getDisplayName());
    repo.updateDisplayName(account.getId(), null);
    assertEquals("Should read userName in favor of displayName if displayName is NULL", "彼得", db.getAccountDao().getAccountById(account.getId()).getDisplayName());
}
Also used : SingleSignOnAccount(com.nextcloud.android.sso.model.SingleSignOnAccount) Account(it.niedermann.owncloud.notes.persistence.entity.Account) Capabilities(it.niedermann.owncloud.notes.shared.model.Capabilities) Test(org.junit.Test)

Example 8 with Account

use of it.niedermann.owncloud.notes.persistence.entity.Account in project nextcloud-notes by stefan-niedermann.

the class NotesRepositoryTest method testAddAccount.

@Test
public void testAddAccount() throws IOException {
    NotesTestingUtil.mockSingleSignOn(new SingleSignOnAccount("彼得@äöüß.example.com", "彼得", "1337", "https://äöüß.example.com", ""));
    repo.addAccount("https://äöüß.example.com", "彼得", "彼得@äöüß.example.com", new Capabilities(), "", new IResponseCallback<>() {

        @Override
        public void onSuccess(Account createdAccount) {
            assertEquals("https://äöüß.example.com", createdAccount.getUrl());
            assertEquals("彼得", createdAccount.getUserName());
            assertEquals("彼得@äöüß.example.com", createdAccount.getAccountName());
        }

        @Override
        public void onError(@NonNull Throwable t) {
            fail(t.getMessage());
        }
    });
}
Also used : SingleSignOnAccount(com.nextcloud.android.sso.model.SingleSignOnAccount) SingleSignOnAccount(com.nextcloud.android.sso.model.SingleSignOnAccount) Account(it.niedermann.owncloud.notes.persistence.entity.Account) Capabilities(it.niedermann.owncloud.notes.shared.model.Capabilities) Test(org.junit.Test)

Example 9 with Account

use of it.niedermann.owncloud.notes.persistence.entity.Account in project nextcloud-notes by stefan-niedermann.

the class AccountDaoTest method insertAccount.

@Test
public void insertAccount() {
    final long createdId = db.getAccountDao().insert(new Account("https://äöüß.example.com", "彼得", "彼得@äöüß.example.com", null, new Capabilities()));
    final var createdAccount = db.getAccountDao().getAccountById(createdId);
    assertEquals("https://äöüß.example.com", createdAccount.getUrl());
    assertEquals("彼得", createdAccount.getUserName());
    assertEquals("彼得@äöüß.example.com", createdAccount.getAccountName());
}
Also used : Account(it.niedermann.owncloud.notes.persistence.entity.Account) Capabilities(it.niedermann.owncloud.notes.shared.model.Capabilities) Test(org.junit.Test)

Example 10 with Account

use of it.niedermann.owncloud.notes.persistence.entity.Account in project nextcloud-notes by stefan-niedermann.

the class AccountDaoTest method updateApiVersionFromNull.

@Test
public void updateApiVersionFromNull() {
    final var account = db.getAccountDao().getAccountById(db.getAccountDao().insert(new Account("https://äöüß.example.com", "彼得", "彼得@äöüß.example.com", null, new Capabilities())));
    assertNull(account.getApiVersion());
    assertEquals(0, db.getAccountDao().updateApiVersion(account.getId(), null));
    assertEquals(1, db.getAccountDao().updateApiVersion(account.getId(), "[0.2]"));
    assertEquals(0, db.getAccountDao().updateApiVersion(account.getId(), "[0.2]"));
}
Also used : Account(it.niedermann.owncloud.notes.persistence.entity.Account) Capabilities(it.niedermann.owncloud.notes.shared.model.Capabilities) Test(org.junit.Test)

Aggregations

Account (it.niedermann.owncloud.notes.persistence.entity.Account)16 Capabilities (it.niedermann.owncloud.notes.shared.model.Capabilities)7 Bundle (android.os.Bundle)6 Test (org.junit.Test)6 NetworkErrorException (android.accounts.NetworkErrorException)5 NonNull (androidx.annotation.NonNull)5 AlertDialog (androidx.appcompat.app.AlertDialog)5 NextcloudFilesAppAccountNotFoundException (com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException)5 R (it.niedermann.owncloud.notes.R)5 Intent (android.content.Intent)4 SDK_INT (android.os.Build.VERSION.SDK_INT)4 Nullable (androidx.annotation.Nullable)4 ViewModelProvider (androidx.lifecycle.ViewModelProvider)4 AccountImporter (com.nextcloud.android.sso.AccountImporter)4 LockedActivity (it.niedermann.owncloud.notes.LockedActivity)4 ExceptionDialogFragment (it.niedermann.owncloud.notes.exception.ExceptionDialogFragment)4 Note (it.niedermann.owncloud.notes.persistence.entity.Note)4 IResponseCallback (it.niedermann.owncloud.notes.shared.model.IResponseCallback)4 Uri (android.net.Uri)3 SingleSignOnAccount (com.nextcloud.android.sso.model.SingleSignOnAccount)3