com.google.api.services.dns.model.ChangesListResponse

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

1. DnsBatchTest#testListChangeRequestsWithOptions()

Project: gcloud-java
Source File: DnsBatchTest.java
View license
@Test
public void testListChangeRequestsWithOptions() {
    EasyMock.reset(batchMock);
    Capture<RpcBatch.Callback<ChangesListResponse>> callback = Capture.newInstance();
    Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
    batchMock.addListChangeRequests(EasyMock.eq(ZONE_NAME), EasyMock.capture(callback), EasyMock.capture(capturedOptions));
    EasyMock.replay(batchMock);
    DnsBatchResult<Page<ChangeRequest>> batchResult = dnsBatch.listChangeRequests(ZONE_NAME, CHANGE_LIST_OPTIONS);
    assertNotNull(callback.getValue());
    Integer size = (Integer) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[0].rpcOption());
    assertEquals(MAX_SIZE, size);
    String selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[1].rpcOption());
    assertEquals(PAGE_TOKEN, selector);
    selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[2].rpcOption());
    assertTrue(selector.contains(Dns.ChangeRequestField.STATUS.selector()));
    assertTrue(selector.contains(Dns.ChangeRequestField.ID.selector()));
    selector = (String) capturedOptions.getValue().get(CHANGE_LIST_OPTIONS[3].rpcOption());
    assertTrue(selector.contains(Dns.SortingOrder.ASCENDING.selector()));
    // check the callback
    ChangesListResponse response = new ChangesListResponse().setChanges(CHANGE_LIST).setNextPageToken(PAGE_TOKEN);
    RpcBatch.Callback<ChangesListResponse> capturedCallback = callback.getValue();
    EasyMock.verify(optionsMock);
    EasyMock.reset(optionsMock);
    EasyMock.expect(optionsMock.service()).andReturn(dns);
    EasyMock.replay(optionsMock);
    capturedCallback.onSuccess(response);
    Page<ChangeRequest> page = batchResult.get();
    assertEquals(PAGE_TOKEN, page.nextPageCursor());
    Iterator<ChangeRequest> iterator = page.values().iterator();
    int resultSize = 0;
    EasyMock.verify(dns);
    EasyMock.reset(dns);
    EasyMock.expect(dns.options()).andReturn(optionsMock).times(CHANGE_LIST.size());
    EasyMock.replay(dns);
    while (iterator.hasNext()) {
        assertEquals(CHANGE_REQUEST_COMPLETE.toPb(), iterator.next().toPb());
        resultSize++;
    }
    assertEquals(CHANGE_LIST.size(), resultSize);
}