@Test public void testAfterProducer() throws Exception { customizer.customize(getComponent(), new HashMap<>()); Exchange inbound = new DefaultExchange(createCamelContext()); BatchUpdateSpreadsheetResponse batchUpdateResponse = new BatchUpdateSpreadsheetResponse(); batchUpdateResponse.setSpreadsheetId(getSpreadsheetId()); Spreadsheet spreadsheet = new Spreadsheet(); spreadsheet.setSpreadsheetId(getSpreadsheetId()); SpreadsheetProperties spreadsheetProperties = new SpreadsheetProperties(); spreadsheetProperties.setTitle("SyndesisTest"); spreadsheetProperties.setTimeZone("America/New_York"); spreadsheetProperties.setLocale("en"); spreadsheet.setProperties(spreadsheetProperties); Sheet sheet = new Sheet(); SheetProperties sheetProperties = new SheetProperties(); sheetProperties.setTitle("Sheet1"); sheetProperties.setSheetId(1); sheetProperties.setIndex(1); sheet.setProperties(sheetProperties); spreadsheet.setSheets(Collections.singletonList(sheet)); batchUpdateResponse.setUpdatedSpreadsheet(spreadsheet); inbound.getIn().setBody(batchUpdateResponse); getComponent().getAfterProducer().process(inbound); GoogleSpreadsheet model = (GoogleSpreadsheet) inbound.getIn().getBody(); Assert.assertEquals(getSpreadsheetId(), model.getSpreadsheetId()); Assert.assertEquals("SyndesisTest", model.getTitle()); Assert.assertEquals("America/New_York", model.getTimeZone()); Assert.assertEquals("en", model.getLocale()); Assert.assertEquals(1, model.getSheets().size()); Assert.assertEquals("Sheet1", model.getSheets().get(0).getTitle()); Assert.assertEquals(Integer.valueOf(1), model.getSheets().get(0).getSheetId()); Assert.assertEquals(Integer.valueOf(1), model.getSheets().get(0).getIndex()); }
private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final BatchUpdateSpreadsheetResponse batchUpdateResponse = in.getBody(BatchUpdateSpreadsheetResponse.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); model.setSpreadsheetId(batchUpdateResponse.getSpreadsheetId()); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet())) { SpreadsheetProperties spreadsheetProperties = batchUpdateResponse.getUpdatedSpreadsheet().getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(batchUpdateResponse.getUpdatedSpreadsheet().getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet().getSheets())) { batchUpdateResponse.getUpdatedSpreadsheet().getSheets().stream() .map(Sheet::getProperties) .forEach(props -> { GoogleSheet sheet = new GoogleSheet(); sheet.setSheetId(props.getSheetId()); sheet.setIndex(props.getIndex()); sheet.setTitle(props.getTitle()); sheets.add(sheet); }); } model.setSheets(sheets); } in.setBody(model); }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final BatchUpdateSpreadsheetResponse batchUpdateResponse = in.getBody(BatchUpdateSpreadsheetResponse.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); model.setSpreadsheetId(batchUpdateResponse.getSpreadsheetId()); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet())) { SpreadsheetProperties spreadsheetProperties = batchUpdateResponse.getUpdatedSpreadsheet().getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(batchUpdateResponse.getUpdatedSpreadsheet().getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet().getSheets())) { batchUpdateResponse.getUpdatedSpreadsheet().getSheets().stream() .map(Sheet::getProperties) .forEach(props -> { GoogleSheet sheet = new GoogleSheet(); sheet.setSheetId(props.getSheetId()); sheet.setIndex(props.getIndex()); sheet.setTitle(props.getTitle()); sheets.add(sheet); }); } model.setSheets(sheets); } in.setBody(model); } }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final BatchUpdateSpreadsheetResponse batchUpdateResponse = in.getBody(BatchUpdateSpreadsheetResponse.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); model.setSpreadsheetId(batchUpdateResponse.getSpreadsheetId()); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet())) { SpreadsheetProperties spreadsheetProperties = batchUpdateResponse.getUpdatedSpreadsheet().getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(batchUpdateResponse.getUpdatedSpreadsheet().getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet().getSheets())) { batchUpdateResponse.getUpdatedSpreadsheet().getSheets().stream() .map(Sheet::getProperties) .forEach(props -> { GoogleSheet sheet = new GoogleSheet(); sheet.setSheetId(props.getSheetId()); sheet.setIndex(props.getIndex()); sheet.setTitle(props.getTitle()); sheets.add(sheet); }); } model.setSheets(sheets); } in.setBody(model); }  }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final BatchUpdateSpreadsheetResponse batchUpdateResponse = in.getBody(BatchUpdateSpreadsheetResponse.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); model.setSpreadsheetId(batchUpdateResponse.getSpreadsheetId()); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet())) { SpreadsheetProperties spreadsheetProperties = batchUpdateResponse.getUpdatedSpreadsheet().getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(batchUpdateResponse.getUpdatedSpreadsheet().getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet().getSheets())) { batchUpdateResponse.getUpdatedSpreadsheet().getSheets().stream() .map(Sheet::getProperties) .forEach(props -> { GoogleSheet sheet = new GoogleSheet(); sheet.setSheetId(props.getSheetId()); sheet.setIndex(props.getIndex()); sheet.setTitle(props.getTitle()); sheets.add(sheet); }); } model.setSheets(sheets); } in.setBody(model); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options); }
GoogleSheetsUpdateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final BatchUpdateSpreadsheetResponse batchUpdateResponse = in.getBody(BatchUpdateSpreadsheetResponse.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); model.setSpreadsheetId(batchUpdateResponse.getSpreadsheetId()); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet())) { SpreadsheetProperties spreadsheetProperties = batchUpdateResponse.getUpdatedSpreadsheet().getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(batchUpdateResponse.getUpdatedSpreadsheet().getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(batchUpdateResponse.getUpdatedSpreadsheet().getSheets())) { batchUpdateResponse.getUpdatedSpreadsheet().getSheets().stream() .map(Sheet::getProperties) .forEach(props -> { GoogleSheet sheet = new GoogleSheet(); sheet.setSheetId(props.getSheetId()); sheet.setIndex(props.getIndex()); sheet.setTitle(props.getTitle()); sheets.add(sheet); }); } model.setSheets(sheets); } in.setBody(model); }  @Override void customize(ComponentProxyComponent component, Map<String, Object> options);  }