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);
}
Aggregations