@Test public void testFileEventToCmd() { DropboxCmd expected = new DropboxCmd(OpCode.ADD, TEST_FILE, new byte[1]); FileEvent evt = new FileEvent(StandardWatchEventKinds.ENTRY_CREATE, TEST_FILE_PATH, new byte[1]); client_.handleEvent(evt); verify(transport_).publish(eq(expected)); DropboxCmd expected2 = new DropboxCmd(OpCode.UPDATE, TEST_FILE, new byte[1]); FileEvent evt2 = new FileEvent(StandardWatchEventKinds.ENTRY_MODIFY, TEST_FILE_PATH, new byte[1]); client_.handleEvent(evt2); verify(transport_).publish(eq(expected2)); DropboxCmd expected3 = new DropboxCmd(OpCode.REMOVE, TEST_FILE, new byte[1]); FileEvent evt3 = new FileEvent(StandardWatchEventKinds.ENTRY_DELETE, TEST_FILE_PATH, new byte[1]); client_.handleEvent(evt3); verify(transport_).publish(eq(expected3)); }
@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)); }