Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 46552853 authored by Stefan Niedermann's avatar Stefan Niedermann
Browse files

Reactive a few tests

parent a4b8f8be
Loading
Loading
Loading
Loading
+153 −143
Original line number Diff line number Diff line
@@ -4,6 +4,8 @@ import android.content.Context;
import android.util.Log;

import androidx.annotation.NonNull;
import androidx.arch.core.executor.testing.InstantTaskExecutorRule;
import androidx.room.Room;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;

@@ -12,19 +14,28 @@ import com.nextcloud.android.sso.exceptions.NextcloudHttpRequestFailedException;
import org.junit.Before;
import org.junit.FixMethodOrder;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.TimeZone;

import it.niedermann.owncloud.notes.main.navigation.NavigationItem;
import it.niedermann.owncloud.notes.persistence.entity.Account;
import it.niedermann.owncloud.notes.persistence.entity.Note;
import it.niedermann.owncloud.notes.shared.model.Capabilities;

import static it.niedermann.owncloud.notes.persistence.NotesDatabaseTestUtil.getOrAwaitValue;
import static it.niedermann.owncloud.notes.shared.util.DisplayUtils.convertToCategoryNavigationItem;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;


/**
@@ -36,24 +47,26 @@ import static org.junit.Assert.assertNotNull;
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class NotesNotesDatabaseTest {

    @Rule
    public InstantTaskExecutorRule instantTaskExecutorRule = new InstantTaskExecutorRule();

    @NonNull
    private Context context;
    private NotesDatabase db = null;

    private String accountURL = "HelloHowAreYou";
    private String accountUserName = "John Doe";
    private String accountName = accountUserName + "@" + accountURL;
    private Account account = null;

    @Before
    public void setupDB() throws NextcloudHttpRequestFailedException {
        context = ApplicationProvider.getApplicationContext();
        db = NotesDatabase.getInstance(context);
        db = Room.inMemoryDatabaseBuilder(ApplicationProvider.getApplicationContext(), NotesDatabase.class).build();
        // Create a new account if not exist
        String accountURL = "HelloHowAreYou";
        String accountUserName = "John Doe";
        final String accountName = accountUserName + "@" + accountURL;
        account = db.getAccountDao().getAccountByName(accountName);
        if (account == null) {
            final String response = "{\"ocs\":{\"meta\":{\"status\":\"ok\",\"statuscode\":200,\"message\":\"OK\"},\"data\":{\"version\":{\"major\":18,\"minor\":0,\"micro\":4,\"string\":\"18.0.4\",\"edition\":\"\",\"extendedSupport\":false},\"capabilities\":{\"core\":{\"pollinterval\":60,\"webdav-root\":\"remote.php\\/webdav\"},\"bruteforce\":{\"delay\":0},\"files\":{\"bigfilechunking\":true,\"blacklisted_files\":[\".htaccess\"],\"directEditing\":{\"url\":\"https:\\/\\/efss.qloud.my\\/ocs\\/v2.php\\/apps\\/files\\/api\\/v1\\/directEditing\",\"etag\":\"ed2b141af2a39b0e42666952ba60988d\"},\"versioning\":true,\"undelete\":true},\"activity\":{\"apiv2\":[\"filters\",\"filters-api\",\"previews\",\"rich-strings\"]},\"ocm\":{\"enabled\":true,\"apiVersion\":\"1.0-proposal1\",\"endPoint\":\"https:\\/\\/efss.qloud.my\\/index.php\\/ocm\",\"resourceTypes\":[{\"name\":\"file\",\"shareTypes\":[\"user\",\"group\"],\"protocols\":{\"webdav\":\"\\/public.php\\/webdav\\/\"}}]},\"deck\":{\"version\":\"0.8.2\"},\"richdocuments\":{\"mimetypes\":[\"application\\/vnd.oasis.opendocument.text\",\"application\\/vnd.oasis.opendocument.spreadsheet\",\"application\\/vnd.oasis.opendocument.graphics\",\"application\\/vnd.oasis.opendocument.presentation\",\"application\\/vnd.lotus-wordpro\",\"application\\/vnd.visio\",\"application\\/vnd.wordperfect\",\"application\\/msonenote\",\"application\\/msword\",\"application\\/rtf\",\"text\\/rtf\",\"application\\/vnd.openxmlformats-officedocument.wordprocessingml.document\",\"application\\/vnd.openxmlformats-officedocument.wordprocessingml.template\",\"application\\/vnd.ms-word.document.macroEnabled.12\",\"application\\/vnd.ms-word.template.macroEnabled.12\",\"application\\/vnd.ms-excel\",\"application\\/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\"application\\/vnd.openxmlformats-officedocument.spreadsheetml.template\",\"application\\/vnd.ms-excel.sheet.macroEnabled.12\",\"application\\/vnd.ms-excel.template.macroEnabled.12\",\"application\\/vnd.ms-excel.addin.macroEnabled.12\",\"application\\/vnd.ms-excel.sheet.binary.macroEnabled.12\",\"application\\/vnd.ms-powerpoint\",\"application\\/vnd.openxmlformats-officedocument.presentationml.presentation\",\"application\\/vnd.openxmlformats-officedocument.presentationml.template\",\"application\\/vnd.openxmlformats-officedocument.presentationml.slideshow\",\"application\\/vnd.ms-powerpoint.addin.macroEnabled.12\",\"application\\/vnd.ms-powerpoint.presentation.macroEnabled.12\",\"application\\/vnd.ms-powerpoint.template.macroEnabled.12\",\"application\\/vnd.ms-powerpoint.slideshow.macroEnabled.12\",\"text\\/csv\"],\"mimetypesNoDefaultOpen\":[\"image\\/svg+xml\",\"application\\/pdf\",\"text\\/plain\",\"text\\/spreadsheet\"],\"collabora\":[],\"direct_editing\":false,\"templates\":false,\"productName\":\"\\u5728\\u7ebf\\u534f\\u4f5c\"},\"dav\":{\"chunking\":\"1.0\"},\"files_sharing\":{\"api_enabled\":true,\"public\":{\"enabled\":true,\"password\":{\"enforced\":true,\"askForOptionalPassword\":false},\"expire_date\":{\"enabled\":true,\"days\":\"7\",\"enforced\":false},\"multiple_links\":true,\"expire_date_internal\":{\"enabled\":false},\"send_mail\":false,\"upload\":true,\"upload_files_drop\":true},\"resharing\":true,\"user\":{\"send_mail\":false,\"expire_date\":{\"enabled\":true}},\"group_sharing\":true,\"group\":{\"enabled\":true,\"expire_date\":{\"enabled\":true}},\"default_permissions\":31,\"federation\":{\"outgoing\":false,\"incoming\":false,\"expire_date\":{\"enabled\":true}},\"sharee\":{\"query_lookup_default\":false},\"sharebymail\":{\"enabled\":true,\"upload_files_drop\":{\"enabled\":true},\"password\":{\"enabled\":true},\"expire_date\":{\"enabled\":true}}},\"external\":{\"v1\":[\"sites\",\"device\",\"groups\",\"redirect\"]},\"notifications\":{\"ocs-endpoints\":[\"list\",\"get\",\"delete\",\"delete-all\",\"icons\",\"rich-strings\",\"action-web\"],\"push\":[\"devices\",\"object-data\",\"delete\"],\"admin-notifications\":[\"ocs\",\"cli\"]},\"password_policy\":{\"minLength\":8,\"enforceNonCommonPassword\":true,\"enforceNumericCharacters\":false,\"enforceSpecialCharacters\":false,\"enforceUpperLowerCase\":false,\"api\":{\"generate\":\"https:\\/\\/efss.qloud.my\\/ocs\\/v2.php\\/apps\\/password_policy\\/api\\/v1\\/generate\",\"validate\":\"https:\\/\\/efss.qloud.my\\/ocs\\/v2.php\\/apps\\/password_policy\\/api\\/v1\\/validate\"}},\"theming\":{\"name\":\"QloudData\",\"url\":\"https:\\/\\/www.qloud.my\\/qloud-data\\/\",\"slogan\":\"Powered by NextCloud\",\"color\":\"#1E4164\",\"color-text\":\"#ffffff\",\"color-element\":\"#1E4164\",\"logo\":\"https:\\/\\/efss.qloud.my\\/index.php\\/apps\\/theming\\/image\\/logo?useSvg=1&v=47\",\"background\":\"https:\\/\\/efss.qloud.my\\/core\\/img\\/background.png?v=47\",\"background-plain\":false,\"background-default\":true,\"logoheader\":\"https:\\/\\/efss.qloud.my\\/index.php\\/apps\\/theming\\/image\\/logo?useSvg=1&v=47\",\"favicon\":\"https:\\/\\/efss.qloud.my\\/index.php\\/apps\\/theming\\/image\\/logo?useSvg=1&v=47\"},\"registration\":{\"enabled\":true,\"apiRoot\":\"\\/ocs\\/v2.php\\/apps\\/registration\\/api\\/v1\\/\",\"apiLevel\":\"v1\"}}}}}";
            Capabilities capabilities = new Capabilities(response, null);
            final Capabilities capabilities = new Capabilities(response, null);
            assertNotNull(capabilities);
            db.addAccount(accountURL, accountUserName, accountName, capabilities);
            account = db.getAccountDao().getAccountByName(accountName);
@@ -70,55 +83,53 @@ public class NotesNotesDatabaseTest {
    }

    @Test
    @Ignore
    public void test_01_addNote_CloudNote() {
        // TODO LiveData
//        long accountID = account.getId();   // retrieve account id
//        // Create a cloud note for argument passing
//        NoteWithCategory cloudNote = new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "A Great Day", getCurDate() + " This is a really great day bro.",
//                true, null), "Diary");
//
//        // Pre-check
//        List<Note> notes = db.getNoteDao().getNotes(accountID);
//        int pre_size = notes.size();
//        Log.i("Test_01_addNote_All_Notes_Before_Addition", "Size: " + pre_size);
//
//        // Add a new note
//        long noteID = db.addNote(accountID, cloudNote);
//        // Check if this note is added successfully
//        NoteWithCategory note = db.getNoteDao().getNoteWithCategory(accountID, noteID);
//        Log.i("Test_01_addNote_Cur_Note", note.toString());
//        Log.i("Test_01_addNote_Cur_Note", "Title: " + note.getTitle());
//        Log.i("Test_01_addNote_Cur_Note", "Content: " + note.getContent());
//        Log.i("Test_01_addNote_Cur_Note", "Category: " + note.getCategory());
//
//        assertEquals("A Great Day", note.getTitle());
//        assertEquals(cloudNote.getContent(), note.getContent());
//        assertEquals("Diary", note.getCategory());
//        assertEquals(accountID, note.getAccountId().longValue());
//
//        // Check if this note is in all notes
//        notes = db.getNoteDao().getNotes(accountID);
//        int added_size = notes.size();
//        assertEquals(1, added_size - pre_size);
//
//        Log.i("Test_01_addNote_All_Notes_Added", "Size: " + added_size);
//        for (Note cnote : notes) {
//            Log.i("Test_01_addNote_All_Notes_Added", cnote.toString());
//            Log.i("Test_01_addNote_All_Notes_Added", cnote.getTitle());
//        }
//
//        NoteWithCategory cloudNote_re0 = new NoteWithCategory(new Note(0L, Calendar.getInstance(),
//                "A Bad Day", getCurDate() + " You're faking a smile with just a coffee to go (Daniel Powter).",
//                true, null), "A Nice Song");
//        noteID = db.addNote(accountID, cloudNote_re0);
//        note = db.getNoteDao().getNoteWithCategory(accountID, noteID);
//        // Check
//        assertEquals("A Bad Day", note.getTitle());
//        assertEquals(cloudNote_re0.getContent(), note.getContent());
//        assertEquals("A Nice Song", note.getCategory());
//        assertEquals(accountID, note.getAccountId().longValue());
        long accountID = account.getId();   // retrieve account id
        // Create a cloud note for argument passing
        Note cloudNote = new Note(1L, Calendar.getInstance(),
                "A Great Day", getCurDate() + " This is a really great day bro.", "Diary",
                true, null);

        // Pre-check
        List<Note> notes = db.getNoteDao().getRecentNotes(accountID);
        int pre_size = notes.size();
        Log.i("Test_01_addNote_All_Notes_Before_Addition", "Size: " + pre_size);

        // Add a new note
        Note noteID = db.addNote(accountID, cloudNote);
        // Check if this note is added successfully
        Note note = db.getNoteDao().getNoteById(noteID.getId());
        Log.i("Test_01_addNote_Cur_Note", note.toString());
        Log.i("Test_01_addNote_Cur_Note", "Title: " + note.getTitle());
        Log.i("Test_01_addNote_Cur_Note", "Content: " + note.getContent());
        Log.i("Test_01_addNote_Cur_Note", "Category: " + note.getCategory());

        assertEquals("A Great Day", note.getTitle());
        assertEquals(cloudNote.getContent(), note.getContent());
        assertEquals("Diary", note.getCategory());
        assertEquals(accountID, note.getAccountId());

        // Check if this note is in all notes
        notes = db.getNoteDao().getRecentNotes(accountID);
        int added_size = notes.size();
        assertEquals(1, added_size - pre_size);

        Log.i("Test_01_addNote_All_Notes_Added", "Size: " + added_size);
        for (Note cnote : notes) {
            Log.i("Test_01_addNote_All_Notes_Added", cnote.toString());
            Log.i("Test_01_addNote_All_Notes_Added", cnote.getTitle());
        }

        Note cloudNote_re0 = new Note(0L, Calendar.getInstance(),
                "A Bad Day", getCurDate() + " You're faking a smile with just a coffee to go (Daniel Powter).", "A Nice Song",
                true, null);
        noteID = db.addNote(accountID, cloudNote_re0);
        note = db.getNoteDao().getNoteById(noteID.getId());
        // Check
        assertEquals("A Bad Day", note.getTitle());
        assertEquals(cloudNote_re0.getContent(), note.getContent());
        assertEquals("A Nice Song", note.getCategory());
        assertEquals(accountID, note.getAccountId());
    }

    @Test
@@ -201,17 +212,17 @@ public class NotesNotesDatabaseTest {
    }

    @Test
    @Ignore
    public void test_04_getCategories() {
//        List<NavigationItem.CategoryNavigationItem> categories = convertToCategoryNavigationItem(context, db.getCategoryDao().getCategories(account.getId()));
//        boolean exitFlag = false;
//        for (NavigationItem categoryItem : categories) {
//            Log.i("Test_04_getCategories_Item", String.format("%s | %s | %d | %d", categoryItem.id, categoryItem.label, categoryItem.count, categoryItem.icon));
//            if (categoryItem.label.equals("Diary")) {
//                exitFlag = true;
//            }
//        }
//        assertTrue(exitFlag);
    public void test_04_getCategories() throws InterruptedException {
        test_01_addNote_CloudNote();
        List<NavigationItem.CategoryNavigationItem> categories = convertToCategoryNavigationItem(context, getOrAwaitValue(db.getNoteDao().getCategories$(account.getId())));
        boolean exitFlag = false;
        for (NavigationItem categoryItem : categories) {
            Log.i("Test_04_getCategories_Item", String.format("%s | %s | %d | %d", categoryItem.id, categoryItem.label, categoryItem.count, categoryItem.icon));
            if (categoryItem.label.equals("Diary")) {
                exitFlag = true;
            }
        }
        assertTrue(exitFlag);
    }

    @Test
@@ -264,68 +275,67 @@ public class NotesNotesDatabaseTest {
    }

    @Test
    @Ignore
    public void test_07_multiAddNote() {
//         TODO LiveData
//        long thisAccountID = account.getId();
//        ArrayList<NoteWithCategory> multiCloudNote = new ArrayList<>();
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "Mike is so cool.", "Mike is a cool guy you know",
//                true, null), "The BiBle"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "Andy is so cool.", "Andy is a cool guy you know",
//                true, null), "The BiBle"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "I Honestly Love You", "I Honestly Love You by Leslie",
//                true, null), "Music"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "Monica", "Monica by Leslie",
//                true, null), "Music"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "Worksheet", "1 2 3 4 5 6 7 8",
//                false, null), "Work"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "PowerPoint.", "8 7 6 5 4 3 2 1",
//                false, null), "Work"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "Farewell My Concubine", "a great movie",
//                true, null), "Movie"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "Leon", "an amazing movie",
//                true, null), "Movie"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "The Dark Knight", "another amazing movie",
//                true, null), "Movies"));
//        multiCloudNote.add(new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "How are you.", "i am fine.",
//                false, null), "Diary"));
//
//        // Pre-check
//        List<Note> notes = db.getNoteDao().getNotes(thisAccountID);
//        int pre_size = notes.size();
//        Log.i("Test_07_multiAddNote_All_Notes_Before_Addition", "Size: " + pre_size);
//
//        long[] multiNoteID = new long[10];
//        for (int i = 0; i < 10; ++i) {
//            multiNoteID[i] = db.addNote(thisAccountID, multiCloudNote.get(i));
//        }
//
//        // check if the node added successfully
//        for (int i = 0; i < 10; ++i) {
//            NoteWithCategory nodeTemp = db.getNoteDao().getNoteWithCategory(thisAccountID, multiNoteID[i]);
//            assertEquals(nodeTemp.getTitle(), multiCloudNote.get(i).getTitle());
//            assertEquals(nodeTemp.getCategory(), multiCloudNote.get(i).getCategory());
//            assertEquals(nodeTemp.getContent(), multiCloudNote.get(i).getContent());
//            assertEquals(nodeTemp.getAccountId().longValue(), thisAccountID);
//            Log.i("Test_07_multiAddNote_All_Notes_Addition_sucessful", nodeTemp.toString());
//        }
//
//        // check if these note is in all notes
//        notes = db.getNoteDao().getNotes(thisAccountID);
//        int add_size = notes.size();
//        assertEquals(10, add_size - pre_size);
//
//        Log.i("Test_07_multiAddNote_All_Notes_After_Addition", "Size: " + add_size);
        long thisAccountID = account.getId();
        ArrayList<Note> multiCloudNote = new ArrayList<>();
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "Mike is so cool.", "Mike is a cool guy you know", "The BiBle",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "Andy is so cool.", "Andy is a cool guy you know", "The BiBle",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "I Honestly Love You", "I Honestly Love You by Leslie", "Music",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "Monica", "Monica by Leslie", "Music",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "Worksheet", "1 2 3 4 5 6 7 8", "Work",
                false, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "PowerPoint.", "8 7 6 5 4 3 2 1", "Work",
                false, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "Farewell My Concubine", "a great movie", "Movie",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "Leon", "an amazing movie", "Movie",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "The Dark Knight", "another amazing movie", "Movies",
                true, null));
        multiCloudNote.add(new Note(1L, Calendar.getInstance(),
                "How are you.", "i am fine.", "Diary",
                false, null));

        // Pre-check
        List<Note> notes = db.getNoteDao().searchRecentByModified(thisAccountID, "%");
        int pre_size = notes.size();
        Log.i("Test_07_multiAddNote_All_Notes_Before_Addition", "Size: " + pre_size);

        Note[] multiNoteID = new Note[10];
        for (int i = 0; i < 10; ++i) {
            multiNoteID[i] = db.addNote(thisAccountID, multiCloudNote.get(i));
        }

        // check if the node added successfully
        for (int i = 0; i < 10; ++i) {
            Note nodeTemp = db.getNoteDao().getNoteById(multiNoteID[i].getId());
            assertEquals(nodeTemp.getTitle(), multiCloudNote.get(i).getTitle());
            assertEquals(nodeTemp.getCategory(), multiCloudNote.get(i).getCategory());
            assertEquals(nodeTemp.getContent(), multiCloudNote.get(i).getContent());
            assertEquals(nodeTemp.getAccountId(), thisAccountID);
            Log.i("Test_07_multiAddNote_All_Notes_Addition_sucessful", nodeTemp.toString());
        }

        // check if these note is in all notes
        notes = db.getNoteDao().searchRecentByModified(thisAccountID, "%");
        int add_size = notes.size();
        assertEquals(10, add_size - pre_size);

        Log.i("Test_07_multiAddNote_All_Notes_After_Addition", "Size: " + add_size);
    }

    @Test
@@ -446,22 +456,22 @@ public class NotesNotesDatabaseTest {

    @Test
    @Ignore
    public void test_12_Chinese() {
    public void test_12_Chinese() throws InterruptedException {
        // TODO LiveData
//        long accountID = account.getId();
//        NoteWithCategory cloudNote = new NoteWithCategory(new Note(1L, Calendar.getInstance(),
//                "美好的一天", getCurDate() + " 兄弟,这真是美好的一天。",
//                true, null), "日记");
//        Note cloudNote = new Note(1L, Calendar.getInstance(),
//                "美好的一天", getCurDate() + " 兄弟,这真是美好的一天。", "日记",
//                true, null);
//
//        // Pre-check
//        List<Note> notes = db.getNoteDao().getNotes(accountID);
//        List<Note> notes = db.getNoteDao().searchRecentByModified(accountID, "%");
//        int pre_size = notes.size();
//        Log.i("Test_12_Chinese_All_Notes_Before_Addition", "Size: " + pre_size);
//
//        // Add a new note
//        long noteID = db.addNote(accountID, cloudNote);
//        Note noteID = db.addNote(accountID, cloudNote);
//        // Check if this note is added successfully
//        NoteWithCategory note = db.getNoteDao().getNoteWithCategory(accountID, noteID);
//        Note note = db.getNoteDao().getNoteById(noteID.getId());
//        Log.i("Test_12_Chinese_Cur_Note", note.toString());
//        Log.i("Test_12_Chinese_Cur_Note", "Title: " + note.getTitle());
//        Log.i("Test_12_Chinese_Cur_Note", "Content: " + note.getContent());
@@ -470,10 +480,10 @@ public class NotesNotesDatabaseTest {
//        assertEquals("美好的一天", note.getTitle());
//        assertEquals(cloudNote.getContent(), note.getContent());
//        assertEquals("日记", note.getCategory());
//        assertEquals(accountID, note.getAccountId().longValue());
//        assertEquals(accountID, note.getAccountId());
//
//        // Check if this note is in all notes
//        notes = db.getNoteDao().getNotes(accountID);
//        notes = db.getNoteDao().searchRecentByModified(accountID, "%");
//        int added_size = notes.size();
//
//        assertEquals(1, added_size - pre_size);
@@ -484,11 +494,11 @@ public class NotesNotesDatabaseTest {
//        }
//
//        long thisAccountID = account.getId();
//        notes = db.getNoteDao().searchNotes(thisAccountID, "美好", "日记", true, null);
//        Log.i("Test_12_Chinese", "Size: " + notes.size());
//        assertEquals(1, notes.size());
////        notes = db.getNoteDao().searchRecentByModified(thisAccountID, "美好", "日记", true, null);
////        Log.i("Test_12_Chinese", "Size: " + notes.size());
////        assertEquals(1, notes.size());
//
//        List<NavigationItem.CategoryNavigationItem> categories = convertToCategoryNavigationItem(context, db.getCategoryDao().getCategories(account.getId()));
//        List<NavigationItem.CategoryNavigationItem> categories = convertToCategoryNavigationItem(context, getOrAwaitValue(db.getNoteDao().getCategories$(account.getId())));
//        boolean exitFlag = false;
//        for (NavigationItem categoryItem : categories) {
//            Log.i("Test_12_Chinese_Item", String.format("%s | %s | %d | %d", categoryItem.id, categoryItem.label, categoryItem.count, categoryItem.icon));
@@ -498,7 +508,7 @@ public class NotesNotesDatabaseTest {
//        }
//        assertTrue(exitFlag);
//
//        categories = convertToCategoryNavigationItem(context, db.getCategoryDao().searchCategories(account.getId(), "记"));
//        categories = convertToCategoryNavigationItem(context, getOrAwaitValue(db.getNoteDao().searchCategories$(account.getId(), "记")));
//        exitFlag = false;
//        for (NavigationItem categoryItem : categories) {
//            Log.i("Test_12_Chinese_Item", String.format("%s | %s | %d | %d", categoryItem.id, categoryItem.label, categoryItem.count, categoryItem.icon));
@@ -508,15 +518,15 @@ public class NotesNotesDatabaseTest {
//        }
//        assertTrue(exitFlag);
//
//        notes = db.getNoteDao().getNotes(thisAccountID);
//        notes = db.getNoteDao().searchRecentByModified(thisAccountID, "%");
//        for (Note cnote : notes) {
//            Log.i("Test_12_Chinese_All_Before_Deletion", cnote.toString());
//            // Delete the note after testing
//            db.deleteNote(cnote.getId(), cnote.getStatus());
//            db.getNoteDao().deleteByNoteId(cnote.getId(), cnote.getStatus());
//        }
//
//        // Check if the note is deleted successfully
//        notes = db.getNoteDao().getNotes(thisAccountID);
//        notes = db.getNoteDao().searchRecentByModified(thisAccountID, "%");
//        int deleted_size = notes.size();
//        assertEquals(1, added_size - deleted_size);
//        Log.i("Test_12_Chinese_All_Notes_After_Deletion", "Size: " + deleted_size);
+3 −3

File changed.

Preview size limit exceeded, changes collapsed.