com.google.api.services.dns.model.ManagedZonesListResponse

Here are the examples of the java api class com.google.api.services.dns.model.ManagedZonesListResponse taken from open source projects.

1. DnsBatchTest#testListZonesWithOptions()

Project: gcloud-java
Source File: DnsBatchTest.java
View license
@Test
public void testListZonesWithOptions() {
    EasyMock.reset(batchMock);
    Capture<RpcBatch.Callback<ManagedZonesListResponse>> callback = Capture.newInstance();
    Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
    batchMock.addListZones(EasyMock.capture(callback), EasyMock.capture(capturedOptions));
    EasyMock.replay(batchMock);
    DnsBatchResult<Page<Zone>> batchResult = dnsBatch.listZones(ZONE_LIST_OPTIONS);
    assertNotNull(callback.getValue());
    Integer size = (Integer) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[0].rpcOption());
    assertEquals(MAX_SIZE, size);
    String selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[1].rpcOption());
    assertEquals(PAGE_TOKEN, selector);
    selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[2].rpcOption());
    assertTrue(selector.contains(Dns.ZoneField.DESCRIPTION.selector()));
    assertTrue(selector.contains(Dns.ZoneField.NAME.selector()));
    selector = (String) capturedOptions.getValue().get(ZONE_LIST_OPTIONS[3].rpcOption());
    assertEquals(DNS_NAME, selector);
    // check the callback
    ManagedZonesListResponse response = new ManagedZonesListResponse().setManagedZones(ZONE_LIST).setNextPageToken(PAGE_TOKEN);
    RpcBatch.Callback<ManagedZonesListResponse> capturedCallback = callback.getValue();
    EasyMock.verify(optionsMock);
    EasyMock.reset(optionsMock);
    EasyMock.expect(optionsMock.service()).andReturn(dns).times(ZONE_LIST.size());
    EasyMock.replay(optionsMock);
    capturedCallback.onSuccess(response);
    Page<Zone> page = batchResult.get();
    assertEquals(PAGE_TOKEN, page.nextPageCursor());
    Iterator<Zone> iterator = page.values().iterator();
    int resultSize = 0;
    EasyMock.verify(dns);
    EasyMock.reset(dns);
    EasyMock.expect(dns.options()).andReturn(optionsMock).times(ZONE_LIST.size() + 1);
    EasyMock.replay(dns);
    Zone zoneInfoFunctional = new Zone(dns, new ZoneInfo.BuilderImpl(ZONE_INFO));
    while (iterator.hasNext()) {
        assertEquals(zoneInfoFunctional, iterator.next());
        resultSize++;
    }
    assertEquals(ZONE_LIST.size(), resultSize);
}