@Test public void testBeforeProducerFromModel() throws Exception { customizer.customize(getComponent(), new HashMap<>()); Exchange inbound = new DefaultExchange(createCamelContext()); GooglePivotTable model = new GooglePivotTable(); model.setSpreadsheetId(getSpreadsheetId()); model.setSourceSheetId(0); model.setSheetId(0); model.setSourceRange("A1:G10"); GooglePivotTable.PivotGroup rowGroup = new GooglePivotTable.PivotGroup(); rowGroup.setLabel("RowGROUP"); rowGroup.setSourceColumn("A"); rowGroup.setValueBucket("Bucket"); rowGroup.setShowTotals(false); rowGroup.setSortOrder("DESCENDING"); model.setRowGroups(Collections.singletonList(rowGroup)); GooglePivotTable.PivotGroup columnGroup = new GooglePivotTable.PivotGroup(); columnGroup.setLabel("ColumnGROUP"); columnGroup.setSourceColumn("E"); model.setColumnGroups(Collections.singletonList(columnGroup)); GooglePivotTable.ValueGroup valueGroup = new GooglePivotTable.ValueGroup(); valueGroup.setSourceColumn("D"); model.setValueGroups(Collections.singletonList(valueGroup)); inbound.getIn().setBody(model); getComponent().getBeforeProducer().process(inbound); Assert.assertNotNull(inbound.getIn().getHeader(GoogleSheetsStreamConstants.SPREADSHEET_ID)); Assert.assertEquals(model.getSpreadsheetId(), inbound.getIn().getHeader(GoogleSheetsStreamConstants.SPREADSHEET_ID)); BatchUpdateSpreadsheetRequest batchUpdateRequest = (BatchUpdateSpreadsheetRequest) inbound.getIn().getHeader(GoogleSheetsConstants.PROPERTY_PREFIX + "batchUpdateSpreadsheetRequest"); Assert.assertEquals(1, batchUpdateRequest.getRequests().size()); UpdateCellsRequest updateCellsRequest = batchUpdateRequest.getRequests().get(0).getUpdateCells(); Assert.assertEquals(Integer.valueOf(0), updateCellsRequest.getStart().getSheetId()); Assert.assertEquals(Integer.valueOf(8), updateCellsRequest.getStart().getColumnIndex()); Assert.assertEquals(Integer.valueOf(0), updateCellsRequest.getStart().getRowIndex()); PivotTable pivotTable = updateCellsRequest.getRows().get(0).getValues().get(0).getPivotTable(); Assert.assertEquals("HORIZONTAL", pivotTable.getValueLayout()); Assert.assertEquals(Integer.valueOf(0), pivotTable.getSource().getStartRowIndex()); Assert.assertEquals(Integer.valueOf(10), pivotTable.getSource().getEndRowIndex()); Assert.assertEquals(Integer.valueOf(0), pivotTable.getSource().getStartColumnIndex()); Assert.assertEquals(Integer.valueOf(7), pivotTable.getSource().getEndColumnIndex()); Assert.assertEquals(1, pivotTable.getRows().size()); Assert.assertEquals("RowGROUP", pivotTable.getRows().get(0).getLabel()); Assert.assertEquals(Integer.valueOf(0), pivotTable.getRows().get(0).getSourceColumnOffset()); Assert.assertEquals("DESCENDING", pivotTable.getRows().get(0).getSortOrder()); Assert.assertFalse(pivotTable.getRows().get(0).getShowTotals()); Assert.assertNotNull(pivotTable.getRows().get(0).getValueBucket()); Assert.assertEquals("Bucket", pivotTable.getRows().get(0).getValueBucket().getBuckets().get(0).getStringValue()); Assert.assertEquals(1, pivotTable.getColumns().size()); Assert.assertEquals("ColumnGROUP", pivotTable.getColumns().get(0).getLabel()); Assert.assertEquals(Integer.valueOf(4), pivotTable.getColumns().get(0).getSourceColumnOffset()); Assert.assertEquals("ASCENDING", pivotTable.getColumns().get(0).getSortOrder()); Assert.assertTrue(pivotTable.getColumns().get(0).getShowTotals()); Assert.assertNull(pivotTable.getColumns().get(0).getValueBucket()); Assert.assertEquals(1, pivotTable.getValues().size()); Assert.assertEquals("SUM", pivotTable.getValues().get(0).getSummarizeFunction()); Assert.assertEquals(Integer.valueOf(3), pivotTable.getValues().get(0).getSourceColumnOffset()); }
@Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); }
GoogleSheetsAddPivotTableCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); } }
GoogleSheetsAddPivotTableCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); }  }
GoogleSheetsAddPivotTableCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); }
GoogleSheetsAddPivotTableCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options);  }