use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class SyncingTest method testDeSelectRemovedNote.
@Test
public void testDeSelectRemovedNote() {
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/book-a.org", "* TODO Note [a-1]\n* TODO Note [a-2]", "1520077116000", 1520077116000L);
ActivityScenario.launch(MainActivity.class);
sync();
onBook(0).perform(click());
onNotesInBook().check(matches(recyclerViewItemCount(3)));
onNoteInBook(1).perform(longClick());
onView(withId(R.id.action_bar_title)).check(matches(withText("1")));
testUtils.setupRook(repo, "mock://repo-a/book-a.org", "* TODO Note [a-1]", "1520681916000", 1520681916000L);
// Sync by starting the service directly, to keep note selected
Intent intent = new Intent(context, SyncService.class);
intent.setAction(AppIntent.ACTION_SYNC_START);
context.startService(intent);
SystemClock.sleep(1000);
onNotesInBook().check(matches(recyclerViewItemCount(2)));
onView(withId(R.id.action_bar_title)).check(doesNotExist());
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class DataRepositoryTest method testLoadRook.
@Test
public void testLoadRook() throws IOException {
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/remote-book-1.org", "", "0abcdef", 1400067156000L);
testUtils.setupRook(repo, "mock://repo-a/remote-book-2.org", "", "1abcdef", 1300067156000L);
testUtils.setupRook(repo, "mock://repo-a/remote-book-3.org", "", "2abcdef", 1200067156000L);
VersionedRook vrook = SyncService.getBooksFromAllRepos(dataRepository, null).get(0);
dataRepository.loadBookFromRepo(vrook);
assertEquals(1, dataRepository.getBooks().size());
BookView book = dataRepository.getBooks().get(0);
assertEquals("remote-book-1", book.getBook().getName());
assertEquals("/remote-book-1.org", book.getSyncedTo().getUri().getPath());
assertEquals("remote-book-1", BookName.getInstance(context, book.getSyncedTo()).getName());
assertEquals("0abcdef", book.getSyncedTo().getRevision());
assertEquals(1400067156000L, book.getSyncedTo().getMtime());
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class DataRepositoryTest method testRepoAndShelfSetup.
@Test
public void testRepoAndShelfSetup() throws IOException {
Repo repo = testUtils.setupRepo(RepoType.MOCK, "mock://repo-a");
testUtils.setupRook(repo, "mock://repo-a/remote-book-1.org", "", "0abcdef", 1400067156000L);
testUtils.setupRook(repo, "mock://repo-a/remote-book-2.org", "", "1abcdef", 1300067156000L);
testUtils.setupRook(repo, "mock://repo-a/remote-book-3.org", "", "2abcdef", 1200067156000L);
testUtils.setupBook("local-book-1", "");
assertEquals("Local books", 1, dataRepository.getBooks().size());
assertEquals("Remote books", 3, SyncService.getBooksFromAllRepos(dataRepository, null).size());
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class GitRepo method getInstance.
public static GitRepo getInstance(RepoWithProps props, Context context) throws IOException {
// TODO: This doesn't seem to be implemented in the same way as WebdavRepo.kt, do
// we want to store configuration data the same way they do?
Repo repo = props.getRepo();
Uri repoUri = Uri.parse(repo.getUrl());
RepoPreferences repoPreferences = new RepoPreferences(context, repo.getId(), repoUri);
GitPreferencesFromRepoPrefs prefs = new GitPreferencesFromRepoPrefs(repoPreferences);
return build(props.getRepo().getId(), prefs, false);
}
use of com.orgzly.android.db.entity.Repo in project orgzly-android by orgzly.
the class DirectoryRepoTest method testExtension.
@Test
public void testExtension() throws IOException {
RepoWithProps repoWithProps = new RepoWithProps(new Repo(13, RepoType.DIRECTORY, repoUriString));
DirectoryRepo repo = new DirectoryRepo(repoWithProps, true);
MiscUtils.writeStringToFile("Notebook content 1", new File(dirFile, "01.txt"));
MiscUtils.writeStringToFile("Notebook content 2", new File(dirFile, "02.o"));
MiscUtils.writeStringToFile("Notebook content 3", new File(dirFile, "03.org"));
List<VersionedRook> books = repo.getBooks();
assertEquals(1, books.size());
assertEquals("03", BookName.getInstance(context, books.get(0)).getName());
assertEquals("03.org", BookName.getInstance(context, books.get(0)).getFileName());
assertEquals(13, books.get(0).getRepoId());
assertEquals(repoUriString, books.get(0).getRepoUri().toString());
assertEquals(repoUriString + "/03.org", books.get(0).getUri().toString());
}
Aggregations