@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfAll and = IfAll.createAndCondition(counter, counter, counter); and.beforeFileTreeWalk(); assertEquals(3, counter.getBeforeFileTreeWalkCount()); }
@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfAccumulatedFileSize filter = IfAccumulatedFileSize.createFileSizeCondition("2GB", counter, counter, counter); filter.beforeFileTreeWalk(); assertEquals(3, counter.getBeforeFileTreeWalkCount()); }
@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfAny or = IfAny.createOrCondition(counter, counter, counter); or.beforeFileTreeWalk(); assertEquals(3, counter.getBeforeFileTreeWalkCount()); }
@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfFileName pathFilter = IfFileName.createNameCondition("path", null, counter, counter, counter); pathFilter.beforeFileTreeWalk(); assertEquals(3, counter.getBeforeFileTreeWalkCount()); } }
@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfNot not = IfNot.createNotCondition(counter); not.beforeFileTreeWalk(); assertEquals(1, counter.getBeforeFileTreeWalkCount()); }
@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfAccumulatedFileCount filter = IfAccumulatedFileCount.createFileCountCondition(30, counter, counter, counter); filter.beforeFileTreeWalk(); assertEquals(3, counter.getBeforeFileTreeWalkCount()); }
@Test public void testBeforeTreeWalk() { final CountingCondition counter = new CountingCondition(true); final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"), counter, counter, counter); filter.beforeFileTreeWalk(); assertEquals(3, counter.getBeforeFileTreeWalkCount()); } }
@Test public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() { final CountingCondition counter = new CountingCondition(true); final IfAccumulatedFileCount condition = IfAccumulatedFileCount.createFileCountCondition(3, counter); for (int i = 1; i < 10; i++) { if (i <= 3) { assertFalse("i=" + i, condition.accept(null, null, null)); assertEquals(0, counter.getAcceptCount()); } else { assertTrue(condition.accept(null, null, null)); assertEquals(i - 3, counter.getAcceptCount()); } } }
@Test public void testAcceptCallsNestedConditionsOnlyIfPathAccepted2() { final CountingCondition counter = new CountingCondition(true); final IfFileName globFilter = IfFileName.createNameCondition("glob", null, counter); final Path pathMatchingGlob = Paths.get("glob"); assertTrue(globFilter.accept(null, pathMatchingGlob, null)); assertEquals(1, counter.getAcceptCount()); assertTrue(globFilter.accept(null, pathMatchingGlob, null)); assertEquals(2, counter.getAcceptCount()); assertTrue(globFilter.accept(null, pathMatchingGlob, null)); assertEquals(3, counter.getAcceptCount()); final Path noMatch = Paths.get("nomatch"); assertFalse(globFilter.accept(null, noMatch, null)); assertEquals(3, counter.getAcceptCount()); // no increase assertFalse(globFilter.accept(null, noMatch, null)); assertEquals(3, counter.getAcceptCount()); assertFalse(globFilter.accept(null, noMatch, null)); assertEquals(3, counter.getAcceptCount()); }
@Test public void testAcceptCallsNestedConditionsOnlyIfPathAccepted1() { final CountingCondition counter = new CountingCondition(true); final IfFileName regexFilter = IfFileName.createNameCondition(null, "regex", counter); final Path pathMatchingRegex = Paths.get("regex"); assertTrue(regexFilter.accept(null, pathMatchingRegex, null)); assertEquals(1, counter.getAcceptCount()); assertTrue(regexFilter.accept(null, pathMatchingRegex, null)); assertEquals(2, counter.getAcceptCount()); assertTrue(regexFilter.accept(null, pathMatchingRegex, null)); assertEquals(3, counter.getAcceptCount()); final Path noMatch = Paths.get("nomatch"); assertFalse(regexFilter.accept(null, noMatch, null)); assertEquals(3, counter.getAcceptCount()); // no increase assertFalse(regexFilter.accept(null, noMatch, null)); assertEquals(3, counter.getAcceptCount()); assertFalse(regexFilter.accept(null, noMatch, null)); assertEquals(3, counter.getAcceptCount()); }
@Test public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() { final CountingCondition counter = new CountingCondition(true); final IfLastModified filter = IfLastModified.createAgeCondition(Duration.parse("PT33S"), counter); final DummyFileAttributes attrs = new DummyFileAttributes(); final long oldEnough = 33 * 1000 + 5; attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - oldEnough); assertTrue(filter.accept(null, null, attrs)); assertEquals(1, counter.getAcceptCount()); assertTrue(filter.accept(null, null, attrs)); assertEquals(2, counter.getAcceptCount()); assertTrue(filter.accept(null, null, attrs)); assertEquals(3, counter.getAcceptCount()); final long tooYoung = 33 * 1000 - 5; attrs.lastModified = FileTime.fromMillis(System.currentTimeMillis() - tooYoung); assertFalse(filter.accept(null, null, attrs)); assertEquals(3, counter.getAcceptCount()); // no increase assertFalse(filter.accept(null, null, attrs)); assertEquals(3, counter.getAcceptCount()); assertFalse(filter.accept(null, null, attrs)); assertEquals(3, counter.getAcceptCount()); }
@Test public void testAcceptCallsNestedConditionsOnlyIfPathAccepted() { final CountingCondition counter = new CountingCondition(true); final IfAccumulatedFileSize condition = IfAccumulatedFileSize.createFileSizeCondition("2KB", counter); final DummyFileAttributes attribs = new DummyFileAttributes(); final long quarter = condition.getThresholdBytes() / 4; attribs.size = quarter; assertFalse(condition.accept(null, null, attribs)); assertEquals(0, counter.getAcceptCount()); assertFalse(condition.accept(null, null, attribs)); assertEquals(0, counter.getAcceptCount()); assertFalse(condition.accept(null, null, attribs)); assertEquals(0, counter.getAcceptCount()); assertFalse(condition.accept(null, null, attribs)); assertEquals(0, counter.getAcceptCount()); assertTrue(condition.accept(null, null, attribs)); assertEquals(1, counter.getAcceptCount()); assertTrue(condition.accept(null, null, attribs)); assertEquals(2, counter.getAcceptCount()); }