Search in sources :

Example 11 with Page

use of com.microsoft.azure.Page in project autorest.java by Azure.

the class PagingsImpl method getMultiplePagesNextSinglePageAsync.

/**
 * A paging operation that includes a nextLink that has 10 pages.
 *
 * @param nextPageLink The NextLink from the previous successful call to List operation.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the PagedList<Product> object wrapped in {@link ServiceResponse} if successful.
 */
public Observable<ServiceResponse<Page<Product>>> getMultiplePagesNextSinglePageAsync(final String nextPageLink) {
    if (nextPageLink == null) {
        throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
    }
    final String clientRequestId = null;
    final PagingGetMultiplePagesOptions pagingGetMultiplePagesOptions = null;
    Integer maxresults = null;
    Integer timeout = null;
    String nextUrl = String.format("%s", nextPageLink);
    return service.getMultiplePagesNext(nextUrl, clientRequestId, this.client.acceptLanguage(), maxresults, timeout, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<Product>>>>() {

        @Override
        public Observable<ServiceResponse<Page<Product>>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<PageImpl<Product>> result = getMultiplePagesNextDelegate(response);
                return Observable.just(new ServiceResponse<Page<Product>>(result.body(), result.response()));
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : Product(fixtures.paging.models.Product) Page(com.microsoft.azure.Page) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody) PagingGetMultiplePagesOptions(fixtures.paging.models.PagingGetMultiplePagesOptions) Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse)

Example 12 with Page

use of com.microsoft.azure.Page in project autorest.java by Azure.

the class PagingsImpl method getMultiplePagesWithOffsetNextSinglePageAsync.

/**
 * A paging operation that includes a nextLink that has 10 pages.
 *
 * @param nextPageLink The NextLink from the previous successful call to List operation.
 * @throws IllegalArgumentException thrown if parameters fail the validation
 * @return the PagedList&lt;Product&gt; object wrapped in {@link ServiceResponse} if successful.
 */
public Observable<ServiceResponse<Page<Product>>> getMultiplePagesWithOffsetNextSinglePageAsync(final String nextPageLink) {
    if (nextPageLink == null) {
        throw new IllegalArgumentException("Parameter nextPageLink is required and cannot be null.");
    }
    final String clientRequestId = null;
    final PagingGetMultiplePagesWithOffsetNextOptions pagingGetMultiplePagesWithOffsetNextOptions = null;
    Integer maxresults = null;
    Integer timeout = null;
    String nextUrl = String.format("%s", nextPageLink);
    return service.getMultiplePagesWithOffsetNext(nextUrl, clientRequestId, this.client.acceptLanguage(), maxresults, timeout, this.client.userAgent()).flatMap(new Func1<Response<ResponseBody>, Observable<ServiceResponse<Page<Product>>>>() {

        @Override
        public Observable<ServiceResponse<Page<Product>>> call(Response<ResponseBody> response) {
            try {
                ServiceResponse<PageImpl<Product>> result = getMultiplePagesWithOffsetNextDelegate(response);
                return Observable.just(new ServiceResponse<Page<Product>>(result.body(), result.response()));
            } catch (Throwable t) {
                return Observable.error(t);
            }
        }
    });
}
Also used : PagingGetMultiplePagesWithOffsetNextOptions(fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions) Product(fixtures.paging.models.Product) Page(com.microsoft.azure.Page) Observable(rx.Observable) ResponseBody(okhttp3.ResponseBody) Response(retrofit2.Response) ServiceResponse(com.microsoft.rest.ServiceResponse) ServiceResponse(com.microsoft.rest.ServiceResponse)

Example 13 with Page

use of com.microsoft.azure.Page in project azure-tools-for-java by Microsoft.

the class ContainerRegistryMvpModelTest method testListContainerRegistries.

@Test
public void testListContainerRegistries() throws IOException {
    List<Subscription> subscriptions = new ArrayList<Subscription>();
    Subscription sub1 = mock(Subscription.class);
    when(sub1.getId()).thenReturn("1");
    Subscription sub2 = mock(Subscription.class);
    when(sub2.getId()).thenReturn("2");
    Subscription sub3 = mock(Subscription.class);
    when(sub3.getId()).thenReturn("3");
    when(mvpModel.getSelectedSubscriptions()).thenReturn(subscriptions);
    ContainerRegistryMvpModel mockModel = spy(containerRegistryMvpModel);
    when(authMethodManagerMock.getAzureClient(anyString())).thenReturn(azureMock);
    when(registriesMock.list()).thenReturn(new PagedList<Registry>() {

        @Override
        public Page<Registry> nextPage(String nextPageLink) throws RestException, IOException {
            return null;
        }
    });
    mockModel.listContainerRegistries(false);
    verify(mockModel, times(0)).listRegistryBySubscriptionId(anyString(), eq(false));
    subscriptions.add(sub1);
    subscriptions.add(sub2);
    subscriptions.add(sub3);
    mockModel.listContainerRegistries(false);
    verify(mockModel, times(3)).listRegistryBySubscriptionId(anyString(), eq(false));
    reset(mockModel);
    mockModel.listContainerRegistries(true);
    verify(mockModel, times(3)).listRegistryBySubscriptionId(anyString(), eq(true));
}
Also used : ArrayList(java.util.ArrayList) RestException(com.microsoft.rest.RestException) Page(com.microsoft.azure.Page) Registry(com.microsoft.azure.management.containerregistry.Registry) Mockito.anyString(org.mockito.Mockito.anyString) IOException(java.io.IOException) Subscription(com.microsoft.azure.toolkit.lib.common.model.Subscription) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Page (com.microsoft.azure.Page)13 ServiceResponse (com.microsoft.rest.ServiceResponse)8 ResponseBody (okhttp3.ResponseBody)8 Response (retrofit2.Response)8 Observable (rx.Observable)8 Product (fixtures.paging.models.Product)7 PagingGetMultiplePagesWithOffsetNextOptions (fixtures.paging.models.PagingGetMultiplePagesWithOffsetNextOptions)3 PagedList (com.microsoft.azure.PagedList)2 TopLevelDomainAgreementOption (com.microsoft.azure.management.appservice.TopLevelDomainAgreementOption)2 VirtualMachineInner (com.microsoft.azure.management.compute.implementation.VirtualMachineInner)2 PagingGetMultiplePagesOptions (fixtures.paging.models.PagingGetMultiplePagesOptions)2 Action1 (rx.functions.Action1)2 Azure (com.microsoft.azure.management.Azure)1 SkuName (com.microsoft.azure.management.appservice.SkuName)1 DataDisk (com.microsoft.azure.management.compute.DataDisk)1 InstanceViewStatus (com.microsoft.azure.management.compute.InstanceViewStatus)1 InstanceViewTypes (com.microsoft.azure.management.compute.InstanceViewTypes)1 OSDisk (com.microsoft.azure.management.compute.OSDisk)1 OperatingSystemTypes (com.microsoft.azure.management.compute.OperatingSystemTypes)1 StorageAccountTypes (com.microsoft.azure.management.compute.StorageAccountTypes)1