com.google.api.services.calendar.model.CalendarList Java Examples
The following examples show how to use
com.google.api.services.calendar.model.CalendarList.
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: GoogleCalendarExporterTest.java From data-transfer-project with Apache License 2.0 | 6 votes |
@Before public void setup() throws IOException { calendarClient = mock(Calendar.class); calendarCalendars = mock(Calendar.Calendars.class); calendarCalendarList = mock(Calendar.CalendarList.class); calendarListRequest = mock(Calendar.CalendarList.List.class); calendarEvents = mock(Calendar.Events.class); eventListRequest = mock(Calendar.Events.List.class); credentialFactory = mock(GoogleCredentialFactory.class); googleCalendarExporter = new GoogleCalendarExporter(credentialFactory, calendarClient); when(calendarClient.calendars()).thenReturn(calendarCalendars); when(calendarClient.calendarList()).thenReturn(calendarCalendarList); when(calendarCalendarList.list()).thenReturn(calendarListRequest); when(calendarClient.events()).thenReturn(calendarEvents); when(calendarEvents.list(CALENDAR_ID)).thenReturn(eventListRequest); when(eventListRequest.setMaxAttendees(MAX_ATTENDEES)).thenReturn(eventListRequest); verifyNoInteractions(credentialFactory); }
Example #2
Source File: AddEventWorkitemHandler.java From jbpm-work-items with Apache License 2.0 | 6 votes |
public String getCalendarIdBySummary(com.google.api.services.calendar.Calendar client, String summary) { String resultId = null; try { CalendarList calendarList = getAllCalendars(client); List<CalendarListEntry> entryList = calendarList.getItems(); for (CalendarListEntry entry : entryList) { if (entry.getSummary().equalsIgnoreCase(summary)) { resultId = entry.getId(); } } } catch (Exception e) { logger.error(MessageFormat.format("Error retrieveing calendars: {0}", e.getMessage())); } return resultId; }
Example #3
Source File: GetEventsWorkitemHandler.java From jbpm-work-items with Apache License 2.0 | 6 votes |
public String getCalendarIdBySummary(com.google.api.services.calendar.Calendar client, String summary) { String resultId = null; try { CalendarList calendarList = getAllCalendars(client); List<CalendarListEntry> entryList = calendarList.getItems(); for (CalendarListEntry entry : entryList) { if (entry.getSummary().equalsIgnoreCase(summary)) { resultId = entry.getId(); } } } catch (Exception e) { logger.error(MessageFormat.format("Error retrieveing calendars: {0}", e.getMessage())); } return resultId; }
Example #4
Source File: GoogleCalendarWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Before public void setUp() { try { CalendarList calendarListModel = new com.google.api.services.calendar.model.CalendarList(); when(client.calendars()).thenReturn(calendars); when(calendars.insert(anyObject())).thenReturn(calendarsInsert); when(calendarsInsert.execute()).thenReturn(new com.google.api.services.calendar.model.Calendar()); when(client.calendarList()).thenReturn(calendarsList); when(calendarsList.list()).thenReturn(calendarsListList); when(calendarsListList.execute()).thenReturn(calendarListModel); when(auth.getAuthorizedCalendar(anyString(), anyString())).thenReturn(client); when(client.events()).thenReturn(clientEvents); when(clientEvents.insert(anyString(), anyObject())).thenReturn(calendarEventsInsert); when(calendarEventsInsert.execute()).thenReturn(new com.google.api.services.calendar.model.Event()); when(clientEvents.list(anyString())).thenReturn(calendarEventsList); when(calendarEventsList.execute()).thenReturn(new com.google.api.services.calendar.model.Events()); } catch (Exception e) { fail(e.getMessage()); } }
Example #5
Source File: GoogleCalendarWorkitemHandlerTest.java From jbpm-work-items with Apache License 2.0 | 6 votes |
@Test public void testGetCalendarsHandler() throws Exception { TestWorkItemManager manager = new TestWorkItemManager(); WorkItemImpl workItem = new WorkItemImpl(); GetCalendarsWorkitemHandler handler = new GetCalendarsWorkitemHandler("myAppName", "{}"); handler.setAuth(auth); handler.executeWorkItem(workItem, manager); assertNotNull(manager.getResults()); assertEquals(1, manager.getResults().size()); assertTrue(manager.getResults().containsKey(workItem.getId())); assertTrue((manager.getResults().get(workItem.getId())).get("AllCalendars") instanceof com.google.api.services.calendar.model.CalendarList); }
Example #6
Source File: GoogleCalendarExporterTest.java From data-transfer-project with Apache License 2.0 | 5 votes |
/** Sets up a response with a single calendar, containing a single event */ private void setUpSingleCalendarResponse() throws IOException { setUpSingleEventResponse(); calendarListResponse = new CalendarList().setItems(Collections.singletonList(CALENDAR_LIST_ENTRY)); when(calendarListRequest.execute()).thenReturn(calendarListResponse); }
Example #7
Source File: AddEventWorkitemHandler.java From jbpm-work-items with Apache License 2.0 | 5 votes |
public CalendarList getAllCalendars(com.google.api.services.calendar.Calendar client) { try { return client.calendarList().list().execute(); } catch (Exception e) { logger.error(MessageFormat.format("Error trying to get calendars: {0}.", e.getMessage())); return null; } }
Example #8
Source File: GetCalendarsWorkitemHandler.java From jbpm-work-items with Apache License 2.0 | 5 votes |
public CalendarList getAllCalendars(com.google.api.services.calendar.Calendar client) { try { return client.calendarList().list().execute(); } catch (Exception e) { logger.error(MessageFormat.format("Error trying to get calendars: {0}.", e.getMessage())); return null; } }
Example #9
Source File: GetEventsWorkitemHandler.java From jbpm-work-items with Apache License 2.0 | 5 votes |
public CalendarList getAllCalendars(com.google.api.services.calendar.Calendar client) { try { return client.calendarList().list().execute(); } catch (Exception e) { logger.error(MessageFormat.format("Error trying to get calendars: {0}.", e.getMessage())); return null; } }
Example #10
Source File: GoogleCalendarMetaDataExtension.java From syndesis with Apache License 2.0 | 5 votes |
@Override public Optional<MetaData> meta(Map<String, Object> parameters) { String clientId = ConnectorOptions.extractOption(parameters, "clientId"); if (clientId == null) { return Optional.empty(); } LOG.debug("Retrieving calendars for connection to google calendar"); String clientSecret = ConnectorOptions.extractOption(parameters, "clientSecret"); String googleScopes = "https://www.googleapis.com/auth/calendar"; String applicationName = ConnectorOptions.extractOption(parameters, "applicationName"); String accessToken = ConnectorOptions.extractOption(parameters, "accessToken"); String refreshToken = ConnectorOptions.extractOption(parameters, "refreshToken"); Calendar client = new BatchGoogleCalendarClientFactory().makeClient(clientId, clientSecret, getScopes(googleScopes), applicationName, refreshToken, accessToken, null, null, "me"); final CalendarList calendars; try { calendars = client.calendarList().list().execute(); } catch (IOException e) { throw new IllegalStateException("Unable to fetch the list of calendars", e); } Set<CalendarListEntry> setCalendars = new HashSet<CalendarListEntry>(); if (calendars.getItems() != null) { for (CalendarListEntry entry : calendars.getItems()) { setCalendars.add(entry); } } return Optional.of(MetaDataBuilder.on(getCamelContext()).withAttribute(MetaData.CONTENT_TYPE, "text/plain") .withAttribute(MetaData.JAVA_TYPE, String.class).withPayload(setCalendars).build()); }
Example #11
Source File: GoogleCalendarExporter.java From data-transfer-project with Apache License 2.0 | 4 votes |
private ExportResult<CalendarContainerResource> exportCalendars( TokensAndUrlAuthData authData, Optional<PaginationData> pageData) { Calendar.CalendarList.List listRequest; CalendarList listResult; // Get calendar information try { listRequest = getOrCreateCalendarInterface(authData).calendarList().list(); if (pageData.isPresent()) { StringPaginationToken paginationToken = (StringPaginationToken) pageData.get(); Preconditions.checkState( paginationToken.getToken().startsWith(CALENDAR_TOKEN_PREFIX), "Token is not applicable"); listRequest.setPageToken( ((StringPaginationToken) pageData.get()) .getToken() .substring(CALENDAR_TOKEN_PREFIX.length())); } listResult = listRequest.execute(); } catch (IOException e) { return new ExportResult<>(e); } // Set up continuation data PaginationData nextPageData = null; if (listResult.getNextPageToken() != null) { nextPageData = new StringPaginationToken(CALENDAR_TOKEN_PREFIX + listResult.getNextPageToken()); } ContinuationData continuationData = new ContinuationData(nextPageData); // Process calendar list List<CalendarModel> calendarModels = new ArrayList<>(listResult.getItems().size()); for (CalendarListEntry calendarData : listResult.getItems()) { CalendarModel model = convertToCalendarModel(calendarData); continuationData.addContainerResource(new IdOnlyContainerResource(calendarData.getId())); calendarModels.add(model); } CalendarContainerResource calendarContainerResource = new CalendarContainerResource(calendarModels, null); // Get result type ExportResult.ResultType resultType = ResultType.CONTINUE; if (calendarModels.isEmpty()) { resultType = ResultType.END; } return new ExportResult<>(resultType, calendarContainerResource, continuationData); }