Search in sources :

Example 1 with OperatorDiscoveryAPI

use of com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI in project connect-android-sdk by telenordigital.

the class MobileConnectTestHelper method getValidOperatorDiscoveryApiMock.

private static OperatorDiscoveryAPI getValidOperatorDiscoveryApiMock() {
    final OperatorDiscoveryAPI.OperatorDiscoveryResult odResult = mock(OperatorDiscoveryAPI.OperatorDiscoveryResult.class);
    when(odResult.getWellKnownEndpoint()).thenReturn(MOCKED_WELL_KNOWN_ENDPONT);
    when(odResult.getMobileConnectApiUrl()).thenReturn(HttpUrl.parse(MOCKED_API_URL));
    when(odResult.getClientId()).thenReturn(MOCKED_CLIENT_ID);
    OperatorDiscoveryAPI api = mock(OperatorDiscoveryAPI.class);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Callback<OperatorDiscoveryResult> callback = (Callback<OperatorDiscoveryResult>) invocation.getArguments()[4];
            callback.success(odResult, null);
            return null;
        }
    }).when(api).getOperatorDiscoveryResult_ForMccMnc(anyString(), anyString(), anyString(), anyString(), any(Callback.class));
    return api;
}
Also used : OperatorDiscoveryAPI(com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Callback(retrofit.Callback) OperatorDiscoveryResult(com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI.OperatorDiscoveryResult) InvocationOnMock(org.mockito.invocation.InvocationOnMock) OperatorDiscoveryResult(com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI.OperatorDiscoveryResult)

Example 2 with OperatorDiscoveryAPI

use of com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI in project connect-android-sdk by telenordigital.

the class MobileConnectTestHelper method getFailingOperatorDiscoveryApiMock.

private static OperatorDiscoveryAPI getFailingOperatorDiscoveryApiMock() {
    OperatorDiscoveryAPI api = mock(OperatorDiscoveryAPI.class);
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            Callback<OperatorDiscoveryResult> callback = (Callback<OperatorDiscoveryResult>) invocation.getArguments()[4];
            callback.failure(null);
            return null;
        }
    }).when(api).getOperatorDiscoveryResult_ForMccMnc(anyString(), anyString(), anyString(), anyString(), any(Callback.class));
    return api;
}
Also used : OperatorDiscoveryAPI(com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Callback(retrofit.Callback) OperatorDiscoveryResult(com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI.OperatorDiscoveryResult) InvocationOnMock(org.mockito.invocation.InvocationOnMock)

Aggregations

OperatorDiscoveryAPI (com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI)2 OperatorDiscoveryResult (com.telenor.mobileconnect.operatordiscovery.OperatorDiscoveryAPI.OperatorDiscoveryResult)2 Mockito.doAnswer (org.mockito.Mockito.doAnswer)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Answer (org.mockito.stubbing.Answer)2 Callback (retrofit.Callback)2