use of org.dataportabilityproject.transfer.microsoft.calendar.MicrosoftCalendarExporter in project data-transfer-project by google.
the class MicrosoftTransferExtension method getExporter.
@Override
public Exporter<?, ?> getExporter(String transferDataType) {
// TODO consider memoizing w/ Supplier but we will only use once and pass to worker.
// This could allow us to refactor these params into supplier.
OkHttpClient client = new OkHttpClient.Builder().build();
ObjectMapper mapper = new ObjectMapper();
TransformerService transformerService = new TransformerServiceImpl();
if (transferDataType.equals(CONTACTS)) {
return new MicrosoftContactsExporter(BASE_GRAPH_URL, client, mapper, transformerService);
}
if (transferDataType.equals(CALENDAR)) {
return new MicrosoftCalendarExporter(BASE_GRAPH_URL, client, mapper, transformerService);
}
return null;
}
use of org.dataportabilityproject.transfer.microsoft.calendar.MicrosoftCalendarExporter in project data-transfer-project by google.
the class MicrosoftCalendarExportTest method testExport.
@Test
public void testExport() throws Exception {
server.enqueue(new MockResponse().setBody(CALENDARS_RESPONSE));
server.enqueue(new MockResponse().setBody(CALENDAR1_EVENTS_RESPONSE));
server.enqueue(new MockResponse().setBody(CALENDAR2_EVENTS_RESPONSE));
server.start();
HttpUrl baseUrl = server.url("");
MicrosoftCalendarExporter exporter = new MicrosoftCalendarExporter(baseUrl.toString(), client, mapper, transformerService);
ExportResult<CalendarContainerResource> resource = exporter.export(UUID.randomUUID(), token);
CalendarContainerResource calendarResource = resource.getExportedData();
Assert.assertEquals(2, calendarResource.getCalendars().size());
Assert.assertFalse(calendarResource.getCalendars().stream().anyMatch(c -> "Calendar1".equals(c.getId()) && "Calendar2".equals(c.getId())));
Assert.assertEquals(2, calendarResource.getEvents().size());
Assert.assertFalse(calendarResource.getEvents().stream().anyMatch(e -> "Test Appointment 1".equals(e.getTitle()) && "Test Appointment 2".equals(e.getTitle())));
}
Aggregations