Java Code Examples for com.google.api.services.sheets.v4.model.Spreadsheet#setSpreadsheetId()

The following examples show how to use com.google.api.services.sheets.v4.model.Spreadsheet#setSpreadsheetId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GoogleSheetsCreateSpreadsheetCustomizerTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example 2
Source File: GoogleSheetsUpdateSpreadsheetCustomizerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@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());
}
 
Example 3
Source File: GoogleSheetsGetSpreadsheetCustomizerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testBeforeConsumer() throws Exception {
    Map<String, Object> options = new HashMap<>();
    options.put("spreadsheetId", getSpreadsheetId());

    customizer.customize(getComponent(), options);

    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().getBeforeConsumer().process(inbound);

    Assert.assertEquals(GoogleSheetsApiCollection.getCollection().getApiName(SheetsSpreadsheetsApiMethod.class).getName(), ConnectorOptions.extractOption(options, "apiName"));
    Assert.assertEquals("get", ConnectorOptions.extractOption(options, "methodName"));

    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());
}