@Test public void testBeforeConsumer() throws Exception { 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().getBeforeConsumer().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())); } }
private void beforeConsumer(Exchange exchange) throws JsonProcessingException { final Message in = exchange.getIn(); if (splitResults) { in.setBody(createModelFromSplitValues(in)); } else { in.setBody(createModelFromValueRange(in)); } }
GoogleSheetsGetValuesCustomizer implements ComponentProxyCustomizer { private void beforeConsumer(Exchange exchange) throws JsonProcessingException { final Message in = exchange.getIn(); if (splitResults) { in.setBody(createModelFromSplitValues(in)); } else { in.setBody(createModelFromValueRange(in)); } } }
GoogleSheetsGetValuesCustomizer implements ComponentProxyCustomizer { private void beforeConsumer(Exchange exchange) throws JsonProcessingException { final Message in = exchange.getIn(); if (splitResults) { in.setBody(createModelFromSplitValues(in)); } else { in.setBody(createModelFromValueRange(in)); } }  }
GoogleSheetsGetValuesCustomizer implements ComponentProxyCustomizer { private void beforeConsumer(Exchange exchange) throws JsonProcessingException { final Message in = exchange.getIn(); if (splitResults) { in.setBody(createModelFromSplitValues(in)); } else { in.setBody(createModelFromValueRange(in)); } }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); }
GoogleSheetsGetValuesCustomizer implements ComponentProxyCustomizer { private void beforeConsumer(Exchange exchange) throws JsonProcessingException { final Message in = exchange.getIn(); if (splitResults) { in.setBody(createModelFromSplitValues(in)); } else { in.setBody(createModelFromValueRange(in)); } }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); static final String SPREADSHEET_ID; }