use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.
the class TestAnd method testFailBoth.
// test both expressions failing
@Test
public void testFailBoth() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.FAIL);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.FAIL);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.FAIL, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.
the class TestAnd method testFailFirst.
// test the first expression failing
@Test
public void testFailFirst() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.FAIL);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.PASS);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.FAIL, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.
the class TestAnd method testStopSecond.
// test the second expression stopping
@Test
public void testStopSecond() throws IOException {
And and = new And();
PathData pathData = mock(PathData.class);
Expression first = mock(Expression.class);
when(first.apply(pathData, -1)).thenReturn(Result.PASS);
Expression second = mock(Expression.class);
when(second.apply(pathData, -1)).thenReturn(Result.STOP);
Deque<Expression> children = new LinkedList<Expression>();
children.add(second);
children.add(first);
and.addChildren(children);
assertEquals(Result.STOP, and.apply(pathData, -1));
verify(first).apply(pathData, -1);
verify(second).apply(pathData, -1);
verifyNoMoreInteractions(first);
verifyNoMoreInteractions(second);
}
use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.
the class TestFilterExpression method apply.
// test the apply method is called and the result returned
@Test
public void apply() throws IOException {
PathData item = mock(PathData.class);
when(expr.apply(item, -1)).thenReturn(Result.PASS).thenReturn(Result.FAIL);
assertEquals(Result.PASS, test.apply(item, -1));
assertEquals(Result.FAIL, test.apply(item, -1));
verify(expr, times(2)).apply(item, -1);
verifyNoMoreInteractions(expr);
}
use of org.apache.hadoop.fs.shell.PathData in project hadoop by apache.
the class TestFind method processArgumentsMaxDepth.
// check maximum depth is handled
@Test
public void processArgumentsMaxDepth() throws IOException {
LinkedList<PathData> items = createDirectories();
Find find = new Find();
find.getOptions().setMaxDepth(1);
find.setConf(conf);
PrintStream out = mock(PrintStream.class);
find.getOptions().setOut(out);
PrintStream err = mock(PrintStream.class);
find.getOptions().setErr(err);
Expression expr = mock(Expression.class);
when(expr.apply((PathData) any(), anyInt())).thenReturn(Result.PASS);
FileStatusChecker fsCheck = mock(FileStatusChecker.class);
Expression test = new TestExpression(expr, fsCheck);
find.setRootExpression(test);
find.processArguments(items);
InOrder inOrder = inOrder(expr);
inOrder.verify(expr).setOptions(find.getOptions());
inOrder.verify(expr).prepare();
inOrder.verify(expr).apply(item1, 0);
inOrder.verify(expr).apply(item1a, 1);
inOrder.verify(expr).apply(item1b, 1);
inOrder.verify(expr).apply(item2, 0);
inOrder.verify(expr).apply(item3, 0);
inOrder.verify(expr).apply(item4, 0);
inOrder.verify(expr).apply(item5, 0);
inOrder.verify(expr).apply(item5a, 1);
inOrder.verify(expr).apply(item5b, 1);
inOrder.verify(expr).apply(item5c, 1);
inOrder.verify(expr).apply(item5d, 1);
inOrder.verify(expr).apply(item5e, 1);
inOrder.verify(expr).finish();
verifyNoMoreInteractions(expr);
InOrder inOrderFsCheck = inOrder(fsCheck);
inOrderFsCheck.verify(fsCheck).check(item1.stat);
inOrderFsCheck.verify(fsCheck).check(item1a.stat);
inOrderFsCheck.verify(fsCheck).check(item1b.stat);
inOrderFsCheck.verify(fsCheck).check(item2.stat);
inOrderFsCheck.verify(fsCheck).check(item3.stat);
inOrderFsCheck.verify(fsCheck).check(item4.stat);
inOrderFsCheck.verify(fsCheck).check(item5.stat);
inOrderFsCheck.verify(fsCheck).check(item5a.stat);
inOrderFsCheck.verify(fsCheck).check(item5b.stat);
inOrderFsCheck.verify(fsCheck).check(item5c.stat);
inOrderFsCheck.verify(fsCheck).check(item5d.stat);
inOrderFsCheck.verify(fsCheck).check(item5e.stat);
verifyNoMoreInteractions(fsCheck);
verifyNoMoreInteractions(out);
verifyNoMoreInteractions(err);
}
Aggregations