@Test public void testAfterProducerRowDimension() throws Exception { String range = "A1:A5"; String sheetName = "Sheet1"; String majorDimension = RangeCoordinate.DIMENSION_ROWS; List<List<Object>> values = Arrays.asList(Collections.singletonList("a1"), Collections.singletonList("a2"), Collections.singletonList("a3"), Collections.singletonList("a4"), Collections.singletonList("a5")); List<String> expectedValueModel = Arrays.asList("{\"spreadsheetId\":\"%s\", \"A\":\"a1\"}", "{\"spreadsheetId\":\"%s\", \"A\":\"a2\"}", "{\"spreadsheetId\":\"%s\", \"A\":\"a3\"}", "{\"spreadsheetId\":\"%s\", \"A\":\"a4\"}", "{\"spreadsheetId\":\"%s\", \"A\":\"a5\"}"); Map<String, Object> options = new HashMap<>(); options.put("spreadsheetId", getSpreadsheetId()); options.put("range", range); options.put("splitResults", false); customizer.customize(getComponent(), options); Exchange inbound = new DefaultExchange(createCamelContext()); ValueRange valueRange = new ValueRange(); valueRange.setRange(sheetName + "!" + range); valueRange.setMajorDimension(majorDimension); valueRange.setValues(values); inbound.getIn().setBody(valueRange); getComponent().getAfterProducer().process(inbound); Assert.assertEquals(GoogleSheetsApiCollection.getCollection().getApiName(SheetsSpreadsheetsValuesApiMethod.class).getName(), ConnectorOptions.extractOption(options, "apiName")); Assert.assertEquals("get", ConnectorOptions.extractOption(options, "methodName")); @SuppressWarnings("unchecked") List<String> model = inbound.getIn().getBody(List.class); Assert.assertEquals(expectedValueModel.size(), model.size()); Iterator<String> modelIterator = model.iterator(); for (String expected : expectedValueModel) { assertThatJson(modelIterator.next()).isEqualTo(String.format(expected, getSpreadsheetId())); } }
@Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(this::afterProducer); }
GoogleSheetsRetrieveValuesCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(this::afterProducer); } }
GoogleSheetsRetrieveValuesCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(this::afterProducer); }  }
GoogleSheetsRetrieveValuesCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(this::afterProducer); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); }
GoogleSheetsRetrieveValuesCustomizer implements ComponentProxyCustomizer { @Override public void customize(ComponentProxyComponent component, Map<String, Object> options) { setApiMethod(options); component.setBeforeProducer(this::beforeProducer); component.setAfterProducer(this::afterProducer); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); static final String SPREADSHEET_ID; }