Search in sources :

Example 1 with ResourceRecordSetsListResponse

use of com.google.api.services.dns.model.ResourceRecordSetsListResponse in project google-cloud-java by GoogleCloudPlatform.

the class DnsBatchTest method testListRecordSetsWithOptions.

@Test
public void testListRecordSetsWithOptions() {
    EasyMock.reset(batchMock);
    Capture<RpcBatch.Callback<ResourceRecordSetsListResponse>> callback = Capture.newInstance();
    Capture<Map<DnsRpc.Option, Object>> capturedOptions = Capture.newInstance();
    batchMock.addListRecordSets(EasyMock.eq(ZONE_NAME), EasyMock.capture(callback), EasyMock.capture(capturedOptions));
    EasyMock.replay(batchMock);
    DnsBatchResult<Page<RecordSet>> batchResult = dnsBatch.listRecordSets(ZONE_NAME, RECORD_SET_LIST_OPTIONS);
    assertNotNull(callback.getValue());
    Integer size = (Integer) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[0].getRpcOption());
    assertEquals(MAX_SIZE, size);
    String selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[1].getRpcOption());
    assertEquals(PAGE_TOKEN, selector);
    selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[2].getRpcOption());
    assertTrue(selector.contains(Dns.RecordSetField.NAME.getSelector()));
    assertTrue(selector.contains(Dns.RecordSetField.TTL.getSelector()));
    selector = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[3].getRpcOption());
    assertEquals(RECORD_SET_LIST_OPTIONS[3].getValue(), selector);
    String type = (String) capturedOptions.getValue().get(RECORD_SET_LIST_OPTIONS[4].getRpcOption());
    assertEquals(RECORD_SET_LIST_OPTIONS[4].getValue(), type);
    RpcBatch.Callback<ResourceRecordSetsListResponse> capturedCallback = callback.getValue();
    ResourceRecordSetsListResponse response = new ResourceRecordSetsListResponse().setRrsets(RECORD_SET_LIST).setNextPageToken(PAGE_TOKEN);
    capturedCallback.onSuccess(response);
    Page<RecordSet> page = batchResult.get();
    assertEquals(PAGE_TOKEN, page.getNextPageToken());
    Iterator<RecordSet> iterator = page.getValues().iterator();
    int resultSize = 0;
    while (iterator.hasNext()) {
        assertEquals(RECORD_SET, iterator.next());
        resultSize++;
    }
    assertEquals(RECORD_SET_LIST.size(), resultSize);
}
Also used : ResourceRecordSetsListResponse(com.google.api.services.dns.model.ResourceRecordSetsListResponse) Page(com.google.api.gax.paging.Page) RpcBatch(com.google.cloud.dns.spi.v1.RpcBatch) DnsRpc(com.google.cloud.dns.spi.v1.DnsRpc) ResourceRecordSet(com.google.api.services.dns.model.ResourceRecordSet) Map(java.util.Map) Test(org.junit.Test)

Aggregations

Page (com.google.api.gax.paging.Page)1 ResourceRecordSet (com.google.api.services.dns.model.ResourceRecordSet)1 ResourceRecordSetsListResponse (com.google.api.services.dns.model.ResourceRecordSetsListResponse)1 DnsRpc (com.google.cloud.dns.spi.v1.DnsRpc)1 RpcBatch (com.google.cloud.dns.spi.v1.RpcBatch)1 Map (java.util.Map)1 Test (org.junit.Test)1