@Test public void testBeforeProducerFromOptions() throws Exception { Map<String, Object> options = new HashMap<>(); options.put("spreadsheetId", getSpreadsheetId()); options.put("title", "SyndesisTest"); options.put("timeZone", "America/New_York"); options.put("locale", "en"); customizer.customize(getComponent(), options); Exchange inbound = new DefaultExchange(createCamelContext()); getComponent().getBeforeProducer().process(inbound); Assert.assertEquals(GoogleSheetsApiCollection.getCollection().getApiName(SheetsSpreadsheetsApiMethod.class).getName(), ConnectorOptions.extractOption(options, "apiName")); Assert.assertEquals("batchUpdate", ConnectorOptions.extractOption(options, "methodName")); Assert.assertNotNull(inbound.getIn().getHeader(GoogleSheetsStreamConstants.SPREADSHEET_ID)); Assert.assertEquals(getSpreadsheetId(), inbound.getIn().getHeader(GoogleSheetsStreamConstants.SPREADSHEET_ID)); BatchUpdateSpreadsheetRequest batchUpdateRequest = (BatchUpdateSpreadsheetRequest) inbound.getIn().getHeader(GoogleSheetsConstants.PROPERTY_PREFIX + "batchUpdateSpreadsheetRequest"); Assert.assertEquals(1, 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()); }
@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);  }