@Test public void testCmdToFileChanges() throws Exception { byte[] data = new byte[3]; data[1] = 1; DropboxCmd add = new DropboxCmd(OpCode.ADD, TEST_FILE, data); client_.handleCmd(add); verify(fileManager_).write(TEST_FILE_RESOLVED_PATH, data, true); DropboxCmd update = new DropboxCmd(OpCode.UPDATE, TEST_FILE, data); client_.handleCmd(update); verify(fileManager_, times(2)).write(TEST_FILE_RESOLVED_PATH, data, true); DropboxCmd delete = new DropboxCmd(OpCode.REMOVE, TEST_FILE, data); client_.handleCmd(delete); verify(fileManager_).delete(TEST_FILE_RESOLVED_PATH); }
@Test public void testFileEventAndCmdNonPropagation() throws IOException { when(fileSystemState_.updateState(any(FileChangeEvent.class))).thenReturn(false); FileEvent evt = new FileEvent(StandardWatchEventKinds.ENTRY_CREATE, TEST_FILE_PATH, new byte[1]); client_.handleEvent(evt); verify(transport_, never()).publish(any(DropboxCmd.class)); DropboxCmd update = new DropboxCmd(OpCode.UPDATE, TEST_FILE, new byte[1]); client_.handleCmd(update); verify(fileManager_, never()).write(any(Path.class), any(byte[].class), any(boolean.class)); }