use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.
the class DataTypesActionTest method testHandle.
@Test
public void testHandle() {
AuthServiceProviderRegistry registry = mock(AuthServiceProviderRegistry.class);
Set<String> dataTypes = new HashSet<>(Arrays.asList("CONTACTS", "PHOTOS"));
when(registry.getTransferDataTypes()).thenReturn(dataTypes);
DataTypesAction dataTypesAction = new DataTypesAction(registry, new Monitor() {
});
GetDataTypes request = mock(GetDataTypes.class);
DataTypes actual = dataTypesAction.handle(request);
Assert.assertEquals(actual.getDataTypes(), dataTypes);
}
use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.
the class PortabilityAuthServiceExtensionRegistryTest method testGetTransferDataTypes.
@Test
public void testGetTransferDataTypes() {
List<String> supportedServiceTypes = ImmutableList.of("PHOTOS", "CONTACTS");
AuthServiceExtension mockAuthProvider = getMockedAuthProvider(supportedServiceTypes, supportedServiceTypes, "mockAuthProvider");
AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider", mockAuthProvider));
Set<String> actual = registry.getTransferDataTypes();
final String[] services = new String[] { "PHOTOS", "CONTACTS" };
Set<String> expected = new HashSet<>(Arrays.asList(services));
Assert.assertEquals(actual, expected);
}
use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.
the class PortabilityAuthServiceExtensionRegistryTest method testGetImportServices1.
@Test
public void testGetImportServices1() {
List<String> supportedServiceTypes1 = ImmutableList.of("PHOTOS", "CONTACTS");
List<String> supportedServiceTypes2 = ImmutableList.of("CONTACTS");
AuthServiceExtension mockAuthProvider1 = getMockedAuthProvider(supportedServiceTypes1, supportedServiceTypes1, "mockAuthProvider1");
AuthServiceExtension mockAuthProvider2 = getMockedAuthProvider(supportedServiceTypes2, supportedServiceTypes2, "mockAuthProvider2");
AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider1", mockAuthProvider1, "mockServiceProvider2", mockAuthProvider2));
Set<String> actual = registry.getImportServices("CONTACTS");
final String[] services = new String[] { "mockAuthProvider1", "mockAuthProvider2" };
Set<String> expected = new HashSet<>(Arrays.asList(services));
Assert.assertEquals(actual, expected);
}
use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.
the class PortabilityAuthServiceExtensionRegistryTest method requireImportAndExportTest.
@Test
public void requireImportAndExportTest() {
List<String> supportedImportTypes = ImmutableList.of("PHOTOS", "CONTACTS");
List<String> supportedExportTypes = ImmutableList.of("CONTACTS");
AuthServiceExtension mockAuthProvider = getMockedAuthProvider(supportedImportTypes, supportedExportTypes, "mockAuthProvider");
thrown.expect(IllegalArgumentException.class);
thrown.expectMessage("available for import but not export");
AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider", mockAuthProvider));
}
use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.
the class PortabilityAuthServiceExtensionRegistryTest method testGetExportServices1.
@Test
public void testGetExportServices1() {
List<String> supportedServiceTypes1 = ImmutableList.of("PHOTOS", "CONTACTS");
List<String> supportedServiceTypes2 = ImmutableList.of("CONTACTS");
AuthServiceExtension mockAuthProvider1 = getMockedAuthProvider(supportedServiceTypes1, supportedServiceTypes1, "mockAuthProvider1");
AuthServiceExtension mockAuthProvider2 = getMockedAuthProvider(supportedServiceTypes2, supportedServiceTypes2, "mockAuthProvider2");
AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider1", mockAuthProvider1, "mockServiceProvider2", mockAuthProvider2));
Set<String> actual = registry.getExportServices("CONTACTS");
final String[] services = new String[] { "mockAuthProvider1", "mockAuthProvider2" };
Set<String> expected = new HashSet<>(Arrays.asList(services));
Assert.assertEquals(actual, expected);
}
Aggregations