Search in sources :

Example 96 with ProjectName

use of com.google.cloud.asset.v1.ProjectName in project java-dlp by googleapis.

the class DlpServiceClientTest method createDlpJobTest3.

@Test
public void createDlpJobTest3() throws Exception {
    DlpJob expectedResponse = DlpJob.newBuilder().setName(DlpJobName.ofProjectDlpJobName("[PROJECT]", "[DLP_JOB]").toString()).setType(DlpJobType.forNumber(0)).setCreateTime(Timestamp.newBuilder().build()).setStartTime(Timestamp.newBuilder().build()).setEndTime(Timestamp.newBuilder().build()).setJobTriggerName("jobTriggerName494333030").addAllErrors(new ArrayList<Error>()).build();
    mockDlpService.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    InspectJobConfig inspectJob = InspectJobConfig.newBuilder().build();
    DlpJob actualResponse = client.createDlpJob(parent, inspectJob);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockDlpService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateDlpJobRequest actualRequest = ((CreateDlpJobRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(inspectJob, actualRequest.getInspectJob());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.privacy.dlp.v2.ProjectName) ArrayList(java.util.ArrayList) DlpJob(com.google.privacy.dlp.v2.DlpJob) CreateDlpJobRequest(com.google.privacy.dlp.v2.CreateDlpJobRequest) InspectJobConfig(com.google.privacy.dlp.v2.InspectJobConfig) Test(org.junit.Test)

Example 97 with ProjectName

use of com.google.cloud.asset.v1.ProjectName in project java-logging by googleapis.

the class LoggingClientTest method listLogsExceptionTest4.

@Test
public void listLogsExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockLoggingServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listLogs(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 98 with ProjectName

use of com.google.cloud.asset.v1.ProjectName in project java-logging by googleapis.

the class ConfigClientTest method createExclusionTest4.

@Test
public void createExclusionTest4() throws Exception {
    LogExclusion expectedResponse = LogExclusion.newBuilder().setName(LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]").toString()).setDescription("description-1724546052").setFilter("filter-1274492040").setDisabled(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    LogExclusion exclusion = LogExclusion.newBuilder().build();
    LogExclusion actualResponse = client.createExclusion(parent, exclusion);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateExclusionRequest actualRequest = ((CreateExclusionRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(exclusion, actualRequest.getExclusion());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : CreateExclusionRequest(com.google.logging.v2.CreateExclusionRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.logging.v2.ProjectName) LogExclusion(com.google.logging.v2.LogExclusion) Test(org.junit.Test)

Example 99 with ProjectName

use of com.google.cloud.asset.v1.ProjectName in project java-logging by googleapis.

the class ConfigClientTest method listExclusionsTest4.

@Test
public void listExclusionsTest4() throws Exception {
    LogExclusion responsesElement = LogExclusion.newBuilder().build();
    ListExclusionsResponse expectedResponse = ListExclusionsResponse.newBuilder().setNextPageToken("").addAllExclusions(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListExclusionsPagedResponse pagedListResponse = client.listExclusions(parent);
    List<LogExclusion> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getExclusionsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListExclusionsRequest actualRequest = ((ListExclusionsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListExclusionsRequest(com.google.logging.v2.ListExclusionsRequest) AbstractMessage(com.google.protobuf.AbstractMessage) ListExclusionsResponse(com.google.logging.v2.ListExclusionsResponse) ProjectName(com.google.logging.v2.ProjectName) LogExclusion(com.google.logging.v2.LogExclusion) ListExclusionsPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListExclusionsPagedResponse) Test(org.junit.Test)

Example 100 with ProjectName

use of com.google.cloud.asset.v1.ProjectName in project java-logging by googleapis.

the class ConfigClientTest method listExclusionsExceptionTest4.

@Test
public void listExclusionsExceptionTest4() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        ProjectName parent = ProjectName.of("[PROJECT]");
        client.listExclusions(parent);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) ProjectName(com.google.logging.v2.ProjectName) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)178 StatusRuntimeException (io.grpc.StatusRuntimeException)89 AbstractMessage (com.google.protobuf.AbstractMessage)76 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)74 ProjectName (com.google.monitoring.v3.ProjectName)62 ProjectName (com.google.pubsub.v1.ProjectName)44 ProjectName (com.google.logging.v2.ProjectName)31 ArrayList (java.util.ArrayList)31 ProjectName (com.google.privacy.dlp.v2.ProjectName)22 ByteString (com.google.protobuf.ByteString)20 DataTransferServiceClient (com.google.cloud.bigquery.datatransfer.v1.DataTransferServiceClient)17 ProjectName (com.google.cloud.bigquery.datatransfer.v1.ProjectName)17 IOException (java.io.IOException)17 CreateTransferConfigRequest (com.google.cloud.bigquery.datatransfer.v1.CreateTransferConfigRequest)16 TransferConfig (com.google.cloud.bigquery.datatransfer.v1.TransferConfig)16 ProjectName (com.google.cloud.secretmanager.v1.ProjectName)16 ProjectName (com.google.containeranalysis.v1beta1.ProjectName)16 ApiException (com.google.api.gax.rpc.ApiException)15 MetricServiceClient (com.google.cloud.monitoring.v3.MetricServiceClient)15 TimeSeries (com.google.monitoring.v3.TimeSeries)15