@Test public void testAfterProducer() throws Exception { customizer.customize(getComponent(), new HashMap<>()); Exchange inbound = new DefaultExchange(createCamelContext()); 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)); inbound.getIn().setBody(spreadsheet); 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 Spreadsheet spreadsheet = in.getBody(Spreadsheet.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); if (ObjectHelper.isNotEmpty(spreadsheet)) { model.setSpreadsheetId(spreadsheet.getSpreadsheetId()); SpreadsheetProperties spreadsheetProperties = spreadsheet.getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(spreadsheet.getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(spreadsheet.getSheets())) { spreadsheet.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); }
GoogleSheetsCreateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final Spreadsheet spreadsheet = in.getBody(Spreadsheet.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); if (ObjectHelper.isNotEmpty(spreadsheet)) { model.setSpreadsheetId(spreadsheet.getSpreadsheetId()); SpreadsheetProperties spreadsheetProperties = spreadsheet.getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(spreadsheet.getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(spreadsheet.getSheets())) { spreadsheet.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); } }
GoogleSheetsCreateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final Spreadsheet spreadsheet = in.getBody(Spreadsheet.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); if (ObjectHelper.isNotEmpty(spreadsheet)) { model.setSpreadsheetId(spreadsheet.getSpreadsheetId()); SpreadsheetProperties spreadsheetProperties = spreadsheet.getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(spreadsheet.getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(spreadsheet.getSheets())) { spreadsheet.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); }  }
GoogleSheetsCreateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final Spreadsheet spreadsheet = in.getBody(Spreadsheet.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); if (ObjectHelper.isNotEmpty(spreadsheet)) { model.setSpreadsheetId(spreadsheet.getSpreadsheetId()); SpreadsheetProperties spreadsheetProperties = spreadsheet.getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(spreadsheet.getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(spreadsheet.getSheets())) { spreadsheet.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); }
GoogleSheetsCreateSpreadsheetCustomizer implements ComponentProxyCustomizer { private static void afterProducer(Exchange exchange) { final Message in = exchange.getIn(); final Spreadsheet spreadsheet = in.getBody(Spreadsheet.class); GoogleSpreadsheet model = new GoogleSpreadsheet(); if (ObjectHelper.isNotEmpty(spreadsheet)) { model.setSpreadsheetId(spreadsheet.getSpreadsheetId()); SpreadsheetProperties spreadsheetProperties = spreadsheet.getProperties(); if (ObjectHelper.isNotEmpty(spreadsheetProperties)) { model.setTitle(spreadsheetProperties.getTitle()); model.setUrl(spreadsheet.getSpreadsheetUrl()); model.setTimeZone(spreadsheetProperties.getTimeZone()); model.setLocale(spreadsheetProperties.getLocale()); } List<GoogleSheet> sheets = new ArrayList<>(); if (ObjectHelper.isNotEmpty(spreadsheet.getSheets())) { spreadsheet.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);  }