Skip to content

Commit

Permalink
Adjusted documentation, removed getProjectId and getProjectNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
mderka committed Feb 3, 2016
1 parent e083dfd commit d6daf09
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 45 deletions.
14 changes: 2 additions & 12 deletions gcloud-java-dns/src/main/java/com/google/gcloud/dns/Dns.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,16 +523,6 @@ public static ChangeRequestListOption sortOrder(SortingOrder order) {
*/
ProjectInfo getProjectInfo(ProjectOption... fields);

/**
* Returns the current project id.
*/
String getProjectId();

/**
* Returns the current project number.
*/
BigInteger getProjectNumber();

/**
* Submits a change request for the specified zone. The returned object contains the following
* read-only fields supplied by the server: id, start time and status. time, id, and list of name
Expand Down Expand Up @@ -566,7 +556,7 @@ ChangeRequest applyChangeRequest(String zoneName, ChangeRequest changeRequest,
* @throws DnsException upon failure or if the zone cannot be found
* @see <a href="https://cloud.google.com/dns/api/v1/changes/get">Cloud DNS Chages: get</a>
*/
ChangeRequest getChangeRequest(String changeRequestId, BigInteger zoneId,
ChangeRequest getChangeRequest(BigInteger zoneId, String changeRequestId,
ChangeRequestOption... options);

/**
Expand All @@ -578,7 +568,7 @@ ChangeRequest getChangeRequest(String changeRequestId, BigInteger zoneId,
* @throws DnsException upon failure or if the zone cannot be found
* @see <a href="https://cloud.google.com/dns/api/v1/changes/get">Cloud DNS Chages: get</a>
*/
ChangeRequest getChangeRequest(String changeRequestId, String zoneName,
ChangeRequest getChangeRequest(String zoneName, String changeRequestId,
ChangeRequestOption... options);

/**
Expand Down
12 changes: 5 additions & 7 deletions gcloud-java-dns/src/main/java/com/google/gcloud/dns/Zone.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ public boolean delete() {
* Lists all {@link DnsRecord}s associated with this zone. First searches for zone by ID and if
* not found then by name.
*
* @param options optional restriction on listing and on what fields of {@link DnsRecord} should
* be returned by the service
* @param options optional restriction on listing and fields of {@link DnsRecord}s returned
* @return a page of DNS records
* @throws DnsException upon failure or if the zone is not found
* @throws NullPointerException if both zone ID and name are not initialized
Expand Down Expand Up @@ -191,11 +190,11 @@ public ChangeRequest getChangeRequest(String changeRequestId,
checkNotNull(changeRequestId);
ChangeRequest updated = null;
if (zoneInfo.id() != null) {
updated = dns.getChangeRequest(changeRequestId, zoneInfo.id(), options);
updated = dns.getChangeRequest(zoneInfo.id(), changeRequestId, options);
}
if (updated == null && zoneInfo.name() != null) {
// zone was not found by id or id is not set at all
updated = dns.getChangeRequest(changeRequestId, zoneInfo.name(), options);
updated = dns.getChangeRequest(zoneInfo.name(), changeRequestId, options);
}
return updated;
}
Expand All @@ -205,8 +204,7 @@ public ChangeRequest getChangeRequest(String changeRequestId,
* then by name. Returns a page of {@link ChangeRequest}s or {@code null} if the zone is not
* found.
*
* @param options optional restriction on listing and on what fields of {@link ChangeRequest}s
* should be returned by the service
* @param options optional restriction on listing and fields to be returned
* @return a page of change requests
* @throws DnsException upon failure or if the zone is not found
* @throws NullPointerException if both zone ID and name are not initialized
Expand Down Expand Up @@ -236,7 +234,7 @@ private void checkNameOrIdNotNull() {
* Returns the {@link ZoneInfo} object containing information about this zone.
*/
public ZoneInfo info() {
return this.zoneInfo;
return zoneInfo;
}

/**
Expand Down
56 changes: 30 additions & 26 deletions gcloud-java-dns/src/test/java/com/google/gcloud/dns/ZoneTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,15 @@ public void testGetById() {
Zone retrieved = Zone.get(dns, ZONE_ID);
assertSame(dns, retrieved.dns());
assertEquals(ZONE_INFO, retrieved.info());
BigInteger id = null;
try {
Zone.get(dns, id);
fail("Cannot get null zone.");
Zone.get(dns, (BigInteger) null);
fail("Cannot get by null id.");
} catch (NullPointerException e) {
// expected
}
try {
Zone.get(null, id);
fail("Cannot get null zone.");
Zone.get(null, new BigInteger("12"));
fail("Cannot get anything from null service.");
} catch (NullPointerException e) {
// expected
}
Expand All @@ -126,16 +125,15 @@ public void testGetByName() {
Zone retrieved = Zone.get(dns, ZONE_NAME);
assertSame(dns, retrieved.dns());
assertEquals(ZONE_INFO, retrieved.info());
String name = null;
try {
Zone.get(dns, name);
fail("Cannot get null zone.");
Zone.get(dns, (String) null);
fail("Cannot get by null name.");
} catch (NullPointerException e) {
// expected
}
try {
Zone.get(null, name);
fail("Cannot get null zone.");
Zone.get(null, "Not null");
fail("Cannot get anything from null service.");
} catch (NullPointerException e) {
// expected
}
Expand Down Expand Up @@ -195,6 +193,7 @@ public void deleteByNameAndNotFound() {

@Test
public void listDnsRecordsByIdAndFound() {
@SuppressWarnings("unchecked")
Page<DnsRecord> pageMock = createStrictMock(Page.class);
replay(pageMock);
expect(dns.listDnsRecords(ZONE_ID)).andReturn(pageMock);
Expand All @@ -210,6 +209,7 @@ public void listDnsRecordsByIdAndFound() {

@Test
public void listDnsRecordsByIdAndNotFoundAndNameSetAndFound() {
@SuppressWarnings("unchecked")
Page<DnsRecord> pageMock = createStrictMock(Page.class);
replay(pageMock);
expect(dns.listDnsRecords(ZONE_ID)).andReturn(null);
Expand Down Expand Up @@ -251,6 +251,7 @@ public void listDnsRecordsByIdAndNotFoundAndNameNotSet() {

@Test
public void listDnsRecordsByNameAndFound() {
@SuppressWarnings("unchecked")
Page<DnsRecord> pageMock = createStrictMock(Page.class);
replay(pageMock);
expect(dns.listDnsRecords(ZONE_NAME)).andReturn(pageMock);
Expand Down Expand Up @@ -486,9 +487,9 @@ public void applyNullChangeRequest() {

@Test
public void getChangeByIdAndFound() {
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(CHANGE_REQUEST_AFTER);
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(CHANGE_REQUEST_AFTER);
// again for options
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(CHANGE_REQUEST_AFTER);
replay(dns);
ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id());
Expand All @@ -503,13 +504,13 @@ public void getChangeByIdAndFound() {

@Test
public void getChangeByIdAndNotFoundAndNameSetAndFound() {
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null);
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME))
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null);
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id()))
.andReturn(CHANGE_REQUEST_AFTER);
// again for options
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(null);
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(CHANGE_REQUEST_AFTER);
replay(dns);
ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id());
Expand All @@ -523,12 +524,12 @@ public void getChangeByIdAndNotFoundAndNameSetAndFound() {

@Test
public void getChangeIdAndNotFoundAndNameSetAndNotFound() {
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null);
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)).andReturn(null);
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null);
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null);
// again with options
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(null);
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(null);
replay(dns);
ChangeRequest result = zone.getChangeRequest(CHANGE_REQUEST.id());
Expand All @@ -540,8 +541,8 @@ public void getChangeIdAndNotFoundAndNameSetAndNotFound() {

@Test
public void getChangeRequestByIdAndNotFoundAndNameNotSet() {
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID)).andReturn(null);
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_ID, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id())).andReturn(null);
expect(dns.getChangeRequest(ZONE_ID, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(null); // for options
replay(dns);
ChangeRequest result = zoneNoName.getChangeRequest(CHANGE_REQUEST.id());
Expand All @@ -554,10 +555,10 @@ public void getChangeRequestByIdAndNotFoundAndNameNotSet() {
@Test
public void getChangeByNameAndFound() {
// ID is not set
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME))
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id()))
.andReturn(CHANGE_REQUEST_AFTER);
// again for options
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(CHANGE_REQUEST_AFTER);
replay(dns);
ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id());
Expand All @@ -570,9 +571,9 @@ public void getChangeByNameAndFound() {
@Test
public void getChangeByNameAndNotFound() {
// ID is not set
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME)).andReturn(null);
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id())).andReturn(null);
// again for options
expect(dns.getChangeRequest(CHANGE_REQUEST.id(), ZONE_NAME, CHANGE_REQUEST_FIELD_OPTIONS))
expect(dns.getChangeRequest(ZONE_NAME, CHANGE_REQUEST.id(), CHANGE_REQUEST_FIELD_OPTIONS))
.andReturn(null);
replay(dns);
ChangeRequest result = zoneNoId.getChangeRequest(CHANGE_REQUEST.id());
Expand Down Expand Up @@ -666,6 +667,7 @@ public void getChangeRequestWithNoId() {

@Test
public void listChangeRequestsByIdAndFound() {
@SuppressWarnings("unchecked")
Page<ChangeRequest> pageMock = createStrictMock(Page.class);
replay(pageMock);
expect(dns.listChangeRequests(ZONE_ID)).andReturn(pageMock);
Expand All @@ -681,6 +683,7 @@ public void listChangeRequestsByIdAndFound() {

@Test
public void listChangeRequestsByIdAndNotFoundAndNameSetAndFound() {
@SuppressWarnings("unchecked")
Page<ChangeRequest> pageMock = createStrictMock(Page.class);
replay(pageMock);
expect(dns.listChangeRequests(ZONE_ID)).andReturn(null);
Expand Down Expand Up @@ -724,6 +727,7 @@ public void listChangeRequestsByIdAndNotFoundAndNameNotSet() {

@Test
public void listChangeRequestsByNameAndFound() {
@SuppressWarnings("unchecked")
Page<ChangeRequest> pageMock = createStrictMock(Page.class);
replay(pageMock);
expect(dns.listChangeRequests(ZONE_NAME)).andReturn(pageMock);
Expand Down

0 comments on commit d6daf09

Please sign in to comment.