@Test public void testBeforeProducerFromModel() throws Exception { customizer.customize(getComponent(), new HashMap<>()); Exchange inbound = new DefaultExchange(createCamelContext()); GoogleSpreadsheet model = new GoogleSpreadsheet(); model.setSpreadsheetId(getSpreadsheetId()); model.setTitle("SyndesisTest"); model.setTimeZone("America/New_York"); model.setLocale("en"); GoogleSheet sheet1 = new GoogleSheet(); sheet1.setTitle("Sheet1"); sheet1.setSheetId(1); sheet1.setIndex(1); GoogleSheet sheet2 = new GoogleSheet(); sheet2.setTitle("Sheet2"); sheet2.setSheetId(2); model.setSheets(Arrays.asList(sheet1, sheet2)); 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(3, batchUpdateRequest.getRequests().size()); UpdateSpreadsheetPropertiesRequest updateSpreadsheetPropertiesRequest = batchUpdateRequest.getRequests().get(0).getUpdateSpreadsheetProperties(); Assert.assertEquals("title,timeZone,locale", updateSpreadsheetPropertiesRequest.getFields()); Assert.assertEquals("SyndesisTest", updateSpreadsheetPropertiesRequest.getProperties().getTitle()); Assert.assertEquals("America/New_York", updateSpreadsheetPropertiesRequest.getProperties().getTimeZone()); Assert.assertEquals("en", updateSpreadsheetPropertiesRequest.getProperties().getLocale()); UpdateSheetPropertiesRequest updateSheetPropertiesRequest = batchUpdateRequest.getRequests().get(1).getUpdateSheetProperties(); Assert.assertEquals("title", updateSheetPropertiesRequest.getFields()); Assert.assertEquals(Integer.valueOf(1), updateSheetPropertiesRequest.getProperties().getIndex()); Assert.assertEquals(Integer.valueOf(1), updateSheetPropertiesRequest.getProperties().getSheetId()); Assert.assertEquals("Sheet1", updateSheetPropertiesRequest.getProperties().getTitle()); updateSheetPropertiesRequest = batchUpdateRequest.getRequests().get(2).getUpdateSheetProperties(); Assert.assertEquals("title", updateSheetPropertiesRequest.getFields()); Assert.assertNull(updateSheetPropertiesRequest.getProperties().getIndex()); Assert.assertEquals(Integer.valueOf(2), updateSheetPropertiesRequest.getProperties().getSheetId()); Assert.assertEquals("Sheet2", updateSheetPropertiesRequest.getProperties().getTitle()); }
@Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(GoogleSheetsUpdateSpreadsheetCustomizer::afterProducer); }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(GoogleSheetsUpdateSpreadsheetCustomizer::afterProducer); } }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(GoogleSheetsUpdateSpreadsheetCustomizer::afterProducer); }  }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(GoogleSheetsUpdateSpreadsheetCustomizer::afterProducer); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(GoogleSheetsUpdateSpreadsheetCustomizer::afterProducer); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options);  }