Search in sources :

Example 16 with Repo

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());
}
Also used : Repo(com.orgzly.android.db.entity.Repo) Intent(android.content.Intent) AppIntent(com.orgzly.android.AppIntent) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 17 with Repo

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());
}
Also used : Repo(com.orgzly.android.db.entity.Repo) BookView(com.orgzly.android.db.entity.BookView) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 18 with Repo

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());
}
Also used : Repo(com.orgzly.android.db.entity.Repo) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Example 19 with Repo

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);
}
Also used : RepoPreferences(com.orgzly.android.prefs.RepoPreferences) Repo(com.orgzly.android.db.entity.Repo) GitPreferencesFromRepoPrefs(com.orgzly.android.git.GitPreferencesFromRepoPrefs) Uri(android.net.Uri)

Example 20 with Repo

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());
}
Also used : Repo(com.orgzly.android.db.entity.Repo) File(java.io.File) OrgzlyTest(com.orgzly.android.OrgzlyTest) Test(org.junit.Test)

Aggregations

Repo (com.orgzly.android.db.entity.Repo)38 OrgzlyTest (com.orgzly.android.OrgzlyTest)35 Test (org.junit.Test)35 BookView (com.orgzly.android.db.entity.BookView)11 BookNamesake (com.orgzly.android.sync.BookNamesake)5 File (java.io.File)4 Intent (android.content.Intent)2 Uri (android.net.Uri)2 AppIntent (com.orgzly.android.AppIntent)2 Book (com.orgzly.android.db.entity.Book)2 AlertDialog (android.app.AlertDialog)1 BroadcastReceiver (android.content.BroadcastReceiver)1 Context (android.content.Context)1 IntentFilter (android.content.IntentFilter)1 Configuration (android.content.res.Configuration)1 Bundle (android.os.Bundle)1 Handler (android.os.Handler)1 Menu (android.view.Menu)1 MenuItem (android.view.MenuItem)1 View (android.view.View)1