use of org.datatransferproject.test.types.FakeIdempotentImportExecutor in project data-transfer-project by google.
the class LocalImportTestRunner method main.
@SuppressWarnings("unchecked")
public static void main(String... args) throws Exception {
AuthTestDriver authTestDriver = new AuthTestDriver();
MicrosoftTransferExtension serviceProvider = new MicrosoftTransferExtension();
TokenAuthData token = authTestDriver.getOAuthTokenCode();
Importer<TokenAuthData, ContactsModelWrapper> contacts = (Importer<TokenAuthData, ContactsModelWrapper>) serviceProvider.getImporter("CONTACTS");
ContactsModelWrapper wrapper = new ContactsModelWrapper(createCards());
FakeIdempotentImportExecutor executor = new FakeIdempotentImportExecutor();
ImportResult result = contacts.importItem(UUID.randomUUID(), executor, token, wrapper);
}
use of org.datatransferproject.test.types.FakeIdempotentImportExecutor in project data-transfer-project by google.
the class GoogleCalendarImporterTest method setup.
@Before
public void setup() {
calendarClient = mock(Calendar.class);
calendarCalendars = mock(Calendar.Calendars.class);
calendarInsertRequest = mock(Calendar.Calendars.Insert.class);
calendarEvents = mock(Calendar.Events.class);
eventInsertRequest = mock(Calendar.Events.Insert.class);
credentialFactory = mock(GoogleCredentialFactory.class);
executor = new FakeIdempotentImportExecutor();
calendarService = new GoogleCalendarImporter(credentialFactory, calendarClient);
when(calendarClient.calendars()).thenReturn(calendarCalendars);
when(calendarClient.events()).thenReturn(calendarEvents);
verifyNoInteractions(credentialFactory);
}
use of org.datatransferproject.test.types.FakeIdempotentImportExecutor in project data-transfer-project by google.
the class GoogleContactsImporterTest method setup.
@Before
public void setup() throws IOException {
people = mock(People.class);
peopleService = mock(PeopleService.class);
createContact = mock(CreateContact.class);
contactsService = new GoogleContactsImporter(peopleService);
executor = new FakeIdempotentImportExecutor();
when(peopleService.people()).thenReturn(people);
when(people.createContact(any(Person.class))).thenReturn(createContact);
Person person = new Person();
when(createContact.execute()).thenReturn(person);
}
use of org.datatransferproject.test.types.FakeIdempotentImportExecutor in project data-transfer-project by google.
the class GoogleMailImporterTest method setUp.
@Before
public void setUp() throws IOException {
Label label = new Label();
label.setId(LABEL1);
label.setName(LABEL1);
labelsListResponse = new ListLabelsResponse().setLabels(Collections.singletonList(label));
Monitor monitor = new Monitor() {
};
googleMailImporter = new GoogleMailImporter(googleCredentialFactory, gmail, monitor);
executor = new FakeIdempotentImportExecutor();
when(gmail.users()).thenReturn(users);
when(users.messages()).thenReturn(messages);
when(messages.insert(anyString(), any(Message.class))).thenReturn(insert);
when(insert.execute()).thenReturn(new Message().setId("fooBar"));
when(users.labels()).thenReturn(labels);
when(labels.list(anyString())).thenReturn(labelsList);
when(labelsList.execute()).thenReturn(labelsListResponse);
when(labels.create(anyString(), any(Label.class))).thenReturn(labelsCreate);
when(labelsCreate.execute()).thenReturn(label);
verifyNoInteractions(googleCredentialFactory);
}
use of org.datatransferproject.test.types.FakeIdempotentImportExecutor in project data-transfer-project by google.
the class MicrosoftPhotosImporterTest method setUp.
@Before
public void setUp() throws IOException {
executor = new FakeIdempotentImportExecutor();
authData = mock(TokensAndUrlAuthData.class);
client = mock(OkHttpClient.class);
objectMapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
// mocked on a per test basis
jobStore = mock(TemporaryPerJobDataStore.class);
monitor = new ConsoleMonitor(ConsoleMonitor.Level.INFO);
credentialFactory = mock(MicrosoftCredentialFactory.class);
credential = new Credential.Builder(BearerToken.authorizationHeaderAccessMethod()).build();
when(credentialFactory.createCredential(any())).thenReturn(credential);
when(credentialFactory.refreshCredential(any())).thenReturn(credential);
credential.setAccessToken("acc");
credential.setExpirationTimeMilliseconds(null);
importer = new MicrosoftPhotosImporter(BASE_URL, client, objectMapper, jobStore, monitor, credentialFactory);
}
Aggregations