/** * Asserts that the given {@link MonitoringRequest} is for {@link #CRUD_OPERATIONS} on the current * directory. * * @param monitoringRequest the request to check (required) * @param expectedToWatchSubTree whether we expect the sub-tree to be monitored as well */ private void assertMonitorsCurrentDirectory( final MonitoringRequest monitoringRequest, final boolean expectedToWatchSubTree) { assertEquals(DirectoryMonitoringRequest.class, monitoringRequest.getClass()); assertEquals( expectedToWatchSubTree, ((DirectoryMonitoringRequest) monitoringRequest).isWatchSubtree()); final Collection<FileOperation> notifyOn = monitoringRequest.getNotifyOn(); assertEquals(CRUD_OPERATIONS.length, notifyOn.size()); assertTrue(notifyOn.containsAll(Arrays.asList(CRUD_OPERATIONS))); assertEquals(new File("."), monitoringRequest.getFile()); }
@Test public void testGetMonitoringRequestForCurrentDirectoryOnly() { assertMonitorsCurrentDirectory(MonitoringRequest.getInitialMonitoringRequest(null), false); }
@Test public void testGetMonitoringRequestForCurrentDirectoryAndSubTree() { assertMonitorsCurrentDirectory( MonitoringRequest.getInitialSubTreeMonitoringRequest(null), true); }