Search in sources :

Example 6 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method testGetExportServices2.

@Test
public void testGetExportServices2() {
    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("PHOTOS");
    final String[] services = new String[] { "mockAuthProvider1" };
    Set<String> expected = new HashSet<>(Arrays.asList(services));
    Assert.assertEquals(actual, expected);
}
Also used : AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method testGetImportServices2.

@Test
public void testGetImportServices2() {
    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("PHOTOS");
    final String[] services = new String[] { "mockAuthProvider1" };
    Set<String> expected = new HashSet<>(Arrays.asList(services));
    Assert.assertEquals(actual, expected);
}
Also used : AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 8 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class PortabilityAuthServiceExtensionRegistryTest method testGetAuthDataGenerator.

@Test
public void testGetAuthDataGenerator() {
    List<String> supportedServiceTypes = ImmutableList.of("PHOTOS", "CONTACTS");
    AuthServiceExtension mockAuthProvider = getMockedAuthProvider(supportedServiceTypes, supportedServiceTypes, "mockAuthProvider");
    when(mockAuthProvider.getAuthDataGenerator("CONTACTS", AuthServiceProviderRegistry.AuthMode.EXPORT)).thenReturn(mock(AuthDataGenerator.class));
    AuthServiceProviderRegistry registry = new PortabilityAuthServiceProviderRegistry(ImmutableMap.of("mockServiceProvider", mockAuthProvider));
    AuthDataGenerator actual = registry.getAuthDataGenerator("mockServiceProvider", "CONTACTS", AuthServiceProviderRegistry.AuthMode.EXPORT);
    Assert.assertNotNull(actual);
}
Also used : AuthDataGenerator(org.datatransferproject.spi.api.auth.AuthDataGenerator) AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) AuthServiceExtension(org.datatransferproject.spi.api.auth.extension.AuthServiceExtension) Test(org.junit.Test)

Example 9 with AuthServiceProviderRegistry

use of org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry in project data-transfer-project by google.

the class DataTypesActionTest method testGetRequestType.

@Test
public void testGetRequestType() {
    AuthServiceProviderRegistry registry = mock(AuthServiceProviderRegistry.class);
    DataTypesAction dataTypesAction = new DataTypesAction(registry, new Monitor() {
    });
    Class<GetDataTypes> actual = dataTypesAction.getRequestType();
    Assert.assertNotEquals(actual, null);
    Assert.assertEquals(actual, GetDataTypes.class);
}
Also used : Monitor(org.datatransferproject.api.launcher.Monitor) AuthServiceProviderRegistry(org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry) GetDataTypes(org.datatransferproject.types.client.datatype.GetDataTypes) Test(org.junit.Test)

Aggregations

AuthServiceProviderRegistry (org.datatransferproject.spi.api.auth.AuthServiceProviderRegistry)9 Test (org.junit.Test)9 AuthServiceExtension (org.datatransferproject.spi.api.auth.extension.AuthServiceExtension)7 HashSet (java.util.HashSet)6 Monitor (org.datatransferproject.api.launcher.Monitor)2 GetDataTypes (org.datatransferproject.types.client.datatype.GetDataTypes)2 AuthDataGenerator (org.datatransferproject.spi.api.auth.AuthDataGenerator)1 DataTypes (org.datatransferproject.types.client.datatype.DataTypes)1