Java Code Examples for org.apache.beam.sdk.transforms.DoFnTester#peekOutputElements()
The following examples show how to use
org.apache.beam.sdk.transforms.DoFnTester#peekOutputElements() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
private void checkSimpleInputValidOutput(DoFnTester<IndexedRecord, IndexedRecord> fnTester) throws Exception { List<IndexedRecord> outputs = fnTester.processBundle(inputSimpleRecord); assertEquals(1, outputs.size()); assertEquals("aaa", outputs.get(0).get(0)); assertEquals("BBB", outputs.get(0).get(1)); assertEquals("Ccc", outputs.get(0).get(2)); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(0, rejects.size()); }
Example 2
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
private void checkSimpleInputInvalidOutput(DoFnTester<IndexedRecord, IndexedRecord> fnTester) throws Exception { List<IndexedRecord> outputs = fnTester.processBundle(inputSimpleRecord); assertEquals(0, outputs.size()); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(1, rejects.size()); assertEquals("aaa", rejects.get(0).get(0)); assertEquals("BBB", rejects.get(0).get(1)); assertEquals("Ccc", rejects.get(0).get(2)); }
Example 3
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
private void checkNumericInputValidOutput(DoFnTester<IndexedRecord, IndexedRecord> fnTester) throws Exception { List<IndexedRecord> outputs = fnTester.processBundle(inputNumericRecord); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(1, outputs.size()); assertEquals(10, outputs.get(0).get(0)); assertEquals(-100, outputs.get(0).get(1)); assertEquals(1000, outputs.get(0).get(2)); assertEquals(0, rejects.size()); }
Example 4
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
private void checkNumericInputInvalidOutput(DoFnTester<IndexedRecord, IndexedRecord> fnTester) throws Exception { List<IndexedRecord> outputs = fnTester.processBundle(inputNumericRecord); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(0, outputs.size()); assertEquals(1, rejects.size()); assertEquals(10, rejects.get(0).get(0)); assertEquals(-100, rejects.get(0).get(1)); assertEquals(1000, rejects.get(0).get(2)); }
Example 5
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
@Test public void test_FilterBetween() throws Exception { FilterRowProperties properties = new FilterRowProperties("test"); properties.init(); FilterRowCriteriaProperties filterGreater = new FilterRowCriteriaProperties("filter1"); filterGreater.init(); filterGreater.columnName.setValue("a"); filterGreater.operator.setValue(ConditionsRowConstant.Operator.GREATER); filterGreater.value.setValue("10"); properties.filters.addRow(filterGreater); FilterRowCriteriaProperties filterLess = new FilterRowCriteriaProperties("filter2"); filterLess.init(); filterLess.columnName.setValue("a"); filterLess.operator.setValue(ConditionsRowConstant.Operator.LOWER); filterLess.value.setValue("30"); properties.filters.addRow(filterLess); FilterRowDoFn function = new FilterRowDoFn(properties); DoFnTester<IndexedRecord, IndexedRecord> fnTester = DoFnTester.of(function); List<IndexedRecord> outputs = fnTester.processBundle(input_30_300_3000_Record, input_10_100_1000_Record, input_20_200_2000_Record); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(1, outputs.size()); assertEquals(2, rejects.size()); }
Example 6
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
@Test public void test_FilterLogicalOpAny() throws Exception { FilterRowProperties properties = new FilterRowProperties("test"); properties.init(); properties.logicalOp.setValue(LogicalOpType.ANY); FilterRowCriteriaProperties condition1 = new FilterRowCriteriaProperties("filter1"); condition1.init(); condition1.columnName.setValue("a"); condition1.operator.setValue(ConditionsRowConstant.Operator.EQUAL); condition1.value.setValue("10"); properties.filters.addRow(condition1); FilterRowCriteriaProperties condition2 = new FilterRowCriteriaProperties("filter2"); condition2.init(); condition2.columnName.setValue("b"); condition2.operator.setValue(ConditionsRowConstant.Operator.EQUAL); condition2.value.setValue("300"); properties.filters.addRow(condition2); FilterRowDoFn function = new FilterRowDoFn(properties); DoFnTester<IndexedRecord, IndexedRecord> fnTester = DoFnTester.of(function); List<IndexedRecord> outputs = fnTester.processBundle(input_30_300_3000_Record, input_10_100_1000_Record, input_20_200_2000_Record); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(2, outputs.size()); assertEquals(30, outputs.get(0).get(0)); assertEquals(10, outputs.get(1).get(0)); assertEquals(1, rejects.size()); assertEquals(20, rejects.get(0).get(0)); }
Example 7
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 5 votes |
@Test public void test_FilterLogicalOpNone() throws Exception { FilterRowProperties properties = new FilterRowProperties("test"); properties.init(); properties.logicalOp.setValue(LogicalOpType.NONE); FilterRowCriteriaProperties condition1 = new FilterRowCriteriaProperties("filter1"); condition1.init(); condition1.columnName.setValue("a"); condition1.operator.setValue(ConditionsRowConstant.Operator.EQUAL); condition1.value.setValue("10"); properties.filters.addRow(condition1); FilterRowCriteriaProperties condition2 = new FilterRowCriteriaProperties("filter2"); condition2.init(); condition2.columnName.setValue("b"); condition2.operator.setValue(ConditionsRowConstant.Operator.EQUAL); condition2.value.setValue("100"); properties.filters.addRow(condition2); FilterRowCriteriaProperties condition3 = new FilterRowCriteriaProperties("filter3"); condition3.init(); condition3.columnName.setValue("a"); condition3.operator.setValue(ConditionsRowConstant.Operator.EQUAL); condition3.value.setValue("20"); properties.filters.addRow(condition3); FilterRowDoFn function = new FilterRowDoFn(properties); DoFnTester<IndexedRecord, IndexedRecord> fnTester = DoFnTester.of(function); List<IndexedRecord> outputs = fnTester.processBundle(input_30_300_3000_Record, input_10_100_1000_Record, input_20_200_2000_Record); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(1, outputs.size()); assertEquals(2, rejects.size()); }
Example 8
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 4 votes |
private void checkSimpleInputNoOutput(DoFnTester<Object, IndexedRecord> fnTester) throws Exception { List<IndexedRecord> outputs = fnTester.processBundle(inputSimpleRecord); assertEquals(0, outputs.size()); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(0, rejects.size()); }
Example 9
Source File: FilterRowDoFnTest.java From components with Apache License 2.0 | 4 votes |
private void checkNumericInputNoOutput(DoFnTester<Object, IndexedRecord> fnTester) throws Exception { List<IndexedRecord> outputs = fnTester.processBundle(inputNumericRecord); assertEquals(0, outputs.size()); List<IndexedRecord> rejects = fnTester.peekOutputElements(FilterRowRuntime.rejectOutput); assertEquals(0, rejects.size()); }