use of com.orgzly.android.Book in project orgzly-android by orgzly.
the class SyncTest method testDeletedRepoShouldStayAsBookLink.
@Test
public void testDeletedRepoShouldStayAsBookLink() {
shelfTestUtils.setupRepo("mock://repo-a");
shelfTestUtils.setupRepo("mock://repo-b");
shelfTestUtils.setupRook("mock://repo-a", "mock://repo-a/booky.org", "", "1abcdef", 1400067155);
Book book;
Map<String, BookNamesake> namesakes;
namesakes = shelf.sync();
book = shelf.getBook("booky");
assertEquals(BookSyncStatus.DUMMY_WITHOUT_LINK_AND_ONE_ROOK, namesakes.get("booky").getStatus());
assertFalse(book.isDummy());
assertEquals("mock://repo-a", book.getLinkRepo().toString());
assertEquals("mock://repo-a", book.getLastSyncedToRook().getRepoUri().toString());
shelfTestUtils.deleteRepo("mock://repo-a");
shelfTestUtils.deleteRepo("mock://repo-b");
shelfTestUtils.setupRepo("mock://repo-c");
// TODO: Don't use namesakes, be consistent and use book.status like in some methods
namesakes = shelf.sync();
book = shelf.getBook("booky");
assertEquals(BookSyncStatus.ONLY_BOOK_WITHOUT_LINK_AND_ONE_REPO, namesakes.get("booky").getStatus());
assertFalse(book.isDummy());
assertEquals("mock://repo-c", book.getLinkRepo().toString());
assertEquals("mock://repo-c", book.getLastSyncedToRook().getRepoUri().toString());
}
use of com.orgzly.android.Book in project orgzly-android by orgzly.
the class SyncTest method testMultipleRooks.
@Test
public void testMultipleRooks() {
shelfTestUtils.setupRepo("mock://repo-a");
shelfTestUtils.setupRook("mock://repo-a", "mock://repo-a/book.org", "Content A", "revA", 1234567890000L);
shelfTestUtils.setupRepo("mock://repo-b");
shelfTestUtils.setupRook("mock://repo-b", "mock://repo-b/book.org", "Content B", "revB", 1234567890000L);
shelf.sync();
Book book = shelf.getBooks().get(0);
assertEquals(BookSyncStatus.DUMMY_WITHOUT_LINK_AND_MULTIPLE_ROOKS, book.getSyncStatus());
assertTrue(book.isDummy());
shelfTestUtils.setBookLink(book.getId(), "mock://repo-a");
shelf.sync();
book = shelf.getBooks().get(0);
assertEquals(BookSyncStatus.DUMMY_WITH_LINK, book.getSyncStatus());
assertTrue(!book.isDummy());
assertEquals("mock://repo-a/book.org", book.getLastSyncedToRook().getUri().toString());
}
use of com.orgzly.android.Book in project orgzly-android by orgzly.
the class SyncTest method testEncodingStaysTheSameAfterSecondSync.
@Test
public void testEncodingStaysTheSameAfterSecondSync() {
Book book;
shelfTestUtils.setupRepo("mock://repo-a");
shelfTestUtils.setupRook("mock://repo-a", "mock://repo-a/book.org", "Content A", "1abcde", 1400067156000L);
shelf.sync();
book = shelf.getBooks().get(0);
assertEquals(BookSyncStatus.DUMMY_WITHOUT_LINK_AND_ONE_ROOK, book.getSyncStatus());
switch(EncodingDetect.USED_METHOD) {
// assertEquals("ASCII", versionedRook.getUsedEncoding());
case JUNIVERSALCHARDET:
assertNull(book.getDetectedEncoding());
assertEquals("UTF-8", book.getUsedEncoding());
break;
}
assertNull(book.getSelectedEncoding());
shelf.sync();
book = shelf.getBooks().get(0);
assertEquals(BookSyncStatus.NO_CHANGE, book.getSyncStatus());
switch(EncodingDetect.USED_METHOD) {
// break;
case JUNIVERSALCHARDET:
assertNull(book.getDetectedEncoding());
assertEquals("UTF-8", book.getUsedEncoding());
break;
}
assertNull(book.getSelectedEncoding());
}
use of com.orgzly.android.Book in project orgzly-android by orgzly.
the class SyncTest method testOnlyBookWithLink.
@Test
public void testOnlyBookWithLink() {
shelfTestUtils.setupRepo("mock://repo-a");
shelfTestUtils.setupBook("book-1", "Content");
shelfTestUtils.setBookLink(1, "mock://repo-a");
shelf.sync();
Book book = shelf.getBooks().get(0);
assertEquals(BookSyncStatus.ONLY_BOOK_WITH_LINK, book.getSyncStatus());
}
use of com.orgzly.android.Book in project orgzly-android by orgzly.
the class StructureTest method testCut.
@Test
public void testCut() {
Book book = shelfTestUtils.setupBook("notebook", "" + "description\n" + "* Note #1.\n" + "* Note #2.\n" + "** Note #3.\n" + "** Note #4.\n" + "*** Note #5.\n" + "**** Note #6.\n" + "** Note #7.\n" + "* Note #8.\n" + "**** Note #9.\n" + "** Note #10.\n" + "");
Set<Long> ids = new HashSet<>();
ids.add(1L);
ids.add(2L);
shelf.cut(book.getId(), ids);
assertEquals("There should be less notes in the book", 8, NotesClient.getCount(context, book.getId()));
Cursor cursor = NotesClient.getCursorForBook(context, book.getName());
try {
Note note;
OrgHead head;
cursor.moveToFirst();
note = NotesClient.fromCursor(cursor);
head = note.getHead();
assertEquals("Title for book should match", "Note #2.", head.getTitle());
assertEquals("Level for book should match", 1, note.getPosition().getLevel());
cursor.moveToNext();
note = NotesClient.fromCursor(cursor);
head = note.getHead();
assertEquals("Title for book should match", "Note #4.", head.getTitle());
assertEquals("Level for book should match", 2, note.getPosition().getLevel());
cursor.moveToNext();
note = NotesClient.fromCursor(cursor);
head = note.getHead();
assertEquals("Title for book should match", "Note #5.", head.getTitle());
assertEquals("Level for book should match", 3, note.getPosition().getLevel());
} finally {
cursor.close();
}
}
Aggregations