Search in sources :

Example 1 with ProjectInfo

use of com.google.cloud.dns.ProjectInfo in project google-cloud-java by GoogleCloudPlatform.

the class ITDnsTest method testGetProject.

@Test
public void testGetProject() {
    // fetches all fields
    ProjectInfo project = DNS.getProject();
    assertNotNull(project.getQuota());
    // options
    project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.QUOTA));
    assertNotNull(project.getQuota());
    project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_ID));
    assertNull(project.getQuota());
    project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER));
    assertNull(project.getQuota());
    project = DNS.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER, ProjectField.QUOTA, ProjectField.PROJECT_ID));
    assertNotNull(project.getQuota());
}
Also used : ProjectInfo(com.google.cloud.dns.ProjectInfo) Test(org.junit.Test)

Example 2 with ProjectInfo

use of com.google.cloud.dns.ProjectInfo in project google-cloud-java by GoogleCloudPlatform.

the class ITDnsTest method testBatchCombined.

@Test
public void testBatchCombined() {
    // the results are validated in the other test methods
    try {
        DNS.create(ZONE1);
        DnsBatch batch = DNS.batch();
        DnsBatchResult<Zone> zoneResult = batch.getZone(ZONE_NAME1);
        DnsBatchResult<ChangeRequest> changeRequestResult = batch.getChangeRequest(ZONE_NAME1, "0");
        DnsBatchResult<Page<RecordSet>> pageResult = batch.listRecordSets(ZONE_NAME1);
        DnsBatchResult<ProjectInfo> projectResult = batch.getProject();
        assertFalse(zoneResult.completed());
        try {
            zoneResult.get();
            fail("this should be submitted first");
        } catch (IllegalStateException ex) {
        // expected
        }
        batch.submit();
        assertNotNull(zoneResult.get().getCreationTimeMillis());
        assertEquals(ZONE1.getDnsName(), zoneResult.get().getDnsName());
        assertEquals(ZONE1.getDescription(), zoneResult.get().getDescription());
        assertFalse(zoneResult.get().getNameServers().isEmpty());
        // we did not set it
        assertNull(zoneResult.get().getNameServerSet());
        assertNotNull(zoneResult.get().getGeneratedId());
        assertNotNull(projectResult.get().getQuota());
        assertEquals(2, Iterables.size(pageResult.get().getValues()));
        assertNotNull(changeRequestResult.get());
    } finally {
        DNS.delete(ZONE1.getName());
    }
}
Also used : Zone(com.google.cloud.dns.Zone) ProjectInfo(com.google.cloud.dns.ProjectInfo) Page(com.google.api.gax.paging.Page) DnsBatch(com.google.cloud.dns.DnsBatch) ChangeRequest(com.google.cloud.dns.ChangeRequest) Test(org.junit.Test)

Example 3 with ProjectInfo

use of com.google.cloud.dns.ProjectInfo in project google-cloud-java by GoogleCloudPlatform.

the class ITDnsTest method testGetProjectBatch.

@Test
public void testGetProjectBatch() {
    // fetches all fields
    DnsBatch batch = DNS.batch();
    DnsBatchResult<ProjectInfo> result = batch.getProject();
    DnsBatchResult<ProjectInfo> resultQuota = batch.getProject(Dns.ProjectOption.fields(ProjectField.QUOTA));
    DnsBatchResult<ProjectInfo> resultId = batch.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_ID));
    DnsBatchResult<ProjectInfo> resultNumber = batch.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER));
    DnsBatchResult<ProjectInfo> resultCombination = batch.getProject(Dns.ProjectOption.fields(ProjectField.PROJECT_NUMBER, ProjectField.QUOTA, ProjectField.PROJECT_ID));
    batch.submit();
    assertNotNull(result.get().getQuota());
    assertNotNull(resultQuota.get().getQuota());
    assertNull(resultId.get().getQuota());
    assertNull(resultNumber.get().getQuota());
    assertNotNull(resultCombination.get().getQuota());
}
Also used : ProjectInfo(com.google.cloud.dns.ProjectInfo) DnsBatch(com.google.cloud.dns.DnsBatch) Test(org.junit.Test)

Aggregations

ProjectInfo (com.google.cloud.dns.ProjectInfo)3 Test (org.junit.Test)3 DnsBatch (com.google.cloud.dns.DnsBatch)2 Page (com.google.api.gax.paging.Page)1 ChangeRequest (com.google.cloud.dns.ChangeRequest)1 Zone (com.google.cloud.dns.Zone)1