Search in sources :

Example 16 with LogExclusion

use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.

the class ConfigClientTest method updateExclusionTest2.

@Test
public void updateExclusionTest2() 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);
    String name = "name3373707";
    LogExclusion exclusion = LogExclusion.newBuilder().build();
    FieldMask updateMask = FieldMask.newBuilder().build();
    LogExclusion actualResponse = client.updateExclusion(name, exclusion, updateMask);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateExclusionRequest actualRequest = ((UpdateExclusionRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertEquals(exclusion, actualRequest.getExclusion());
    Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) UpdateExclusionRequest(com.google.logging.v2.UpdateExclusionRequest) LogExclusion(com.google.logging.v2.LogExclusion) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 17 with LogExclusion

use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.

the class ConfigClientTest method createExclusionExceptionTest3.

@Test
public void createExclusionExceptionTest3() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockConfigServiceV2.addException(exception);
    try {
        OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
        LogExclusion exclusion = LogExclusion.newBuilder().build();
        client.createExclusion(parent, exclusion);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) LogExclusion(com.google.logging.v2.LogExclusion) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 18 with LogExclusion

use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.

the class ConfigClientTest method createSinkTest2.

@Test
public void createSinkTest2() throws Exception {
    LogSink expectedResponse = LogSink.newBuilder().setName(LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]").toString()).setDestination("destination-1429847026").setFilter("filter-1274492040").setDescription("description-1724546052").setDisabled(true).addAllExclusions(new ArrayList<LogExclusion>()).setWriterIdentity("writerIdentity925193809").setIncludeChildren(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    LogSink sink = LogSink.newBuilder().build();
    LogSink actualResponse = client.createSink(parent, sink);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSinkRequest actualRequest = ((CreateSinkRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(sink, actualRequest.getSink());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) CreateSinkRequest(com.google.logging.v2.CreateSinkRequest) FolderName(com.google.logging.v2.FolderName) Test(org.junit.Test)

Example 19 with LogExclusion

use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.

the class ConfigClientTest method updateSinkTest.

@Test
public void updateSinkTest() throws Exception {
    LogSink expectedResponse = LogSink.newBuilder().setName(LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]").toString()).setDestination("destination-1429847026").setFilter("filter-1274492040").setDescription("description-1724546052").setDisabled(true).addAllExclusions(new ArrayList<LogExclusion>()).setWriterIdentity("writerIdentity925193809").setIncludeChildren(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    LogSinkName sinkName = LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]");
    LogSink sink = LogSink.newBuilder().build();
    LogSink actualResponse = client.updateSink(sinkName, sink);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateSinkRequest actualRequest = ((UpdateSinkRequest) actualRequests.get(0));
    Assert.assertEquals(sinkName.toString(), actualRequest.getSinkName());
    Assert.assertEquals(sink, actualRequest.getSink());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) LogSinkName(com.google.logging.v2.LogSinkName) AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) UpdateSinkRequest(com.google.logging.v2.UpdateSinkRequest) Test(org.junit.Test)

Example 20 with LogExclusion

use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.

the class ConfigClientTest method createSinkTest.

@Test
public void createSinkTest() throws Exception {
    LogSink expectedResponse = LogSink.newBuilder().setName(LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]").toString()).setDestination("destination-1429847026").setFilter("filter-1274492040").setDescription("description-1724546052").setDisabled(true).addAllExclusions(new ArrayList<LogExclusion>()).setWriterIdentity("writerIdentity925193809").setIncludeChildren(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
    LogSink sink = LogSink.newBuilder().build();
    LogSink actualResponse = client.createSink(parent, sink);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateSinkRequest actualRequest = ((CreateSinkRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertEquals(sink, actualRequest.getSink());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) AbstractMessage(com.google.protobuf.AbstractMessage) BillingAccountName(com.google.logging.v2.BillingAccountName) ArrayList(java.util.ArrayList) CreateSinkRequest(com.google.logging.v2.CreateSinkRequest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)40 LogExclusion (com.google.logging.v2.LogExclusion)29 AbstractMessage (com.google.protobuf.AbstractMessage)25 LogSink (com.google.logging.v2.LogSink)11 ArrayList (java.util.ArrayList)11 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 CreateExclusionRequest (com.google.logging.v2.CreateExclusionRequest)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 GetExclusionRequest (com.google.logging.v2.GetExclusionRequest)6 FieldMask (com.google.protobuf.FieldMask)6 ListExclusionsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListExclusionsPagedResponse)5 CreateSinkRequest (com.google.logging.v2.CreateSinkRequest)5 ListExclusionsRequest (com.google.logging.v2.ListExclusionsRequest)5 ListExclusionsResponse (com.google.logging.v2.ListExclusionsResponse)5 BillingAccountName (com.google.logging.v2.BillingAccountName)4 FolderName (com.google.logging.v2.FolderName)4 OrganizationName (com.google.logging.v2.OrganizationName)4 ProjectName (com.google.logging.v2.ProjectName)4 UpdateExclusionRequest (com.google.logging.v2.UpdateExclusionRequest)4 UpdateSinkRequest (com.google.logging.v2.UpdateSinkRequest)4