@Test public void testSyncOnCreate() throws IOException { /* check that both storage systems are empty */ assertTrue(notebookRepoSync.getRepoCount() > 1); assertEquals(0, notebookRepoSync.list(0).size()); assertEquals(0, notebookRepoSync.list(1).size()); /* create note */ Note note = notebookSync.createNote(); // check that automatically saved on both storages assertEquals(1, notebookRepoSync.list(0).size()); assertEquals(1, notebookRepoSync.list(1).size()); assertEquals(notebookRepoSync.list(0).get(0).getId(), notebookRepoSync.list(1).get(0).getId()); }
@Test public void testSyncOnDelete() throws IOException { /* create note */ assertTrue(notebookRepoSync.getRepoCount() > 1); assertEquals(0, notebookRepoSync.list(0).size()); assertEquals(0, notebookRepoSync.list(1).size()); Note note = notebookSync.createNote(); /* check that created in both storage systems */ assertEquals(1, notebookRepoSync.list(0).size()); assertEquals(1, notebookRepoSync.list(1).size()); assertEquals(notebookRepoSync.list(0).get(0).getId(), notebookRepoSync.list(1).get(0).getId()); /* remove Note */ notebookSync.removeNote(notebookRepoSync.list(0).get(0).getId()); /* check that deleted in both storages */ assertEquals(0, notebookRepoSync.list(0).size()); assertEquals(0, notebookRepoSync.list(1).size()); }
@Test public void testSyncOnReloadedList() throws IOException { /* check that both storage repos are empty */ assertTrue(notebookRepoSync.getRepoCount() > 1); assertEquals(0, notebookRepoSync.list(0).size()); assertEquals(0, notebookRepoSync.list(1).size()); File srcDir = new File("src/test/resources/2A94M5J1Z"); File destDir = new File(secNotebookDir + "/2A94M5J1Z"); /* copy manually new notebook into secondary storage repo and check repos */ try { FileUtils.copyDirectory(srcDir, destDir); } catch (IOException e) { LOG.error(e.toString(), e); } assertEquals(0, notebookRepoSync.list(0).size()); assertEquals(1, notebookRepoSync.list(1).size()); // After reloading notebooks repos should be synchronized notebookSync.reloadAllNotes(); assertEquals(1, notebookRepoSync.list(0).size()); assertEquals(1, notebookRepoSync.list(1).size()); }
@Test public void testRepoCount() throws IOException { assertTrue(notebookRepoSync.getMaxRepoNum() >= notebookRepoSync.getRepoCount()); }