use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method updateSinkTest4.
@Test
public void updateSinkTest4() 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 sink = LogSink.newBuilder().build();
FieldMask updateMask = FieldMask.newBuilder().build();
LogSink actualResponse = client.updateSink(sinkName, sink, updateMask);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
UpdateSinkRequest actualRequest = ((UpdateSinkRequest) actualRequests.get(0));
Assert.assertEquals(sinkName, actualRequest.getSinkName());
Assert.assertEquals(sink, actualRequest.getSink());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
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 getExclusionTest.
@Test
public void getExclusionTest() 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);
LogExclusionName name = LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]");
LogExclusion actualResponse = client.getExclusion(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetExclusionRequest actualRequest = ((GetExclusionRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
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 updateSinkTest3.
@Test
public void updateSinkTest3() 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();
FieldMask updateMask = FieldMask.newBuilder().build();
LogSink actualResponse = client.updateSink(sinkName, sink, updateMask);
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.assertEquals(updateMask, actualRequest.getUpdateMask());
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 listExclusionsTest5.
@Test
public void listExclusionsTest5() throws Exception {
LogExclusion responsesElement = LogExclusion.newBuilder().build();
ListExclusionsResponse expectedResponse = ListExclusionsResponse.newBuilder().setNextPageToken("").addAllExclusions(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
String parent = "parent-995424086";
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, actualRequest.getParent());
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 listExclusionsTest.
@Test
public void listExclusionsTest() throws Exception {
LogExclusion responsesElement = LogExclusion.newBuilder().build();
ListExclusionsResponse expectedResponse = ListExclusionsResponse.newBuilder().setNextPageToken("").addAllExclusions(Arrays.asList(responsesElement)).build();
mockConfigServiceV2.addResponse(expectedResponse);
BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
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()));
}
Aggregations