blob: e9b8bcd87ee60da56306795bd2397fd0222388d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# Single Operator Unit Test
It is possible to run an end to end test of an operator in isolation by extending
[PhysicalOpUnitTestBase](../../exec/java-exec/src/test/java/org/apache/drill/exec/physical/unit/PhysicalOpUnitTestBase.java).
A simple example of an operator level unit test is the following:
```
public class BasicPhysicalOpUnitTest extends PhysicalOpUnitTestBase {
@Test
public void testSimpleProject() {
Project projectConf = new Project(parseExprs("x+5", "x"), null);
List<String> jsonBatches = Lists.newArrayList(
"[{\"x\": 5 },{\"x\": 10 }]",
"[{\"x\": 20 },{\"x\": 30 },{\"x\": 40 }]");
opTestBuilder()
.physicalOperator(projectConf)
.inputDataStreamJson(jsonBatches)
.baselineColumns("x")
.baselineValues(10l)
.baselineValues(15l)
.baselineValues(25l)
.baselineValues(35l)
.baselineValues(45l)
.go();
}
}
```
|