use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method createExclusionExceptionTest.
@Test
public void createExclusionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
client.createExclusion(parent, exclusion);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method updateExclusionExceptionTest2.
@Test
public void updateExclusionExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
String name = "name3373707";
LogExclusion exclusion = LogExclusion.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
client.updateExclusion(name, exclusion, updateMask);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method createExclusionExceptionTest2.
@Test
public void createExclusionExceptionTest2() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
FolderName parent = FolderName.of("[FOLDER]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
client.createExclusion(parent, exclusion);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method createSinkTest3.
@Test
public void createSinkTest3() 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);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
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()));
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method getSinkTest2.
@Test
public void getSinkTest2() 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);
String sinkName = "sinkName508775358";
LogSink actualResponse = client.getSink(sinkName);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSinkRequest actualRequest = ((GetSinkRequest) actualRequests.get(0));
Assert.assertEquals(sinkName, actualRequest.getSinkName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations