use of com.google.logging.v2.LogExclusion 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()));
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class LoggingImplTest method testGetExclusion.
@Test
public void testGetExclusion() {
LogExclusion exclusionPb = EXCLUSION.toProtobuf();
ApiFuture<LogExclusion> response = ApiFutures.immediateFuture(exclusionPb);
GetExclusionRequest request = GetExclusionRequest.newBuilder().setName(EXCLUSION_NAME_PB).build();
EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
Exclusion exclusion = logging.getExclusion(EXCLUSION_NAME);
assertEquals(EXCLUSION_NAME, exclusion.getName());
assertEquals(DESCRIPTION, exclusion.getDescription());
assertEquals(EXCLUSION_FILTER, exclusion.getFilter());
assertEquals(DISABLED, exclusion.isDisabled());
assertEquals(EXCLUSION_CREATED_TIME, exclusion.getCreateTime());
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class LoggingImplTest method testGetExclusionAsync_Null.
@Test
public void testGetExclusionAsync_Null() throws ExecutionException, InterruptedException {
ApiFuture<LogExclusion> response = ApiFutures.immediateFuture(null);
GetExclusionRequest request = GetExclusionRequest.newBuilder().setName(EXCLUSION_NAME_PB).build();
EasyMock.expect(loggingRpcMock.get(request)).andReturn(response);
EasyMock.replay(rpcFactoryMock, loggingRpcMock);
logging = options.getService();
Exclusion exclusion = logging.getExclusionAsync(EXCLUSION_NAME).get();
assertNull(exclusion);
}
use of com.google.logging.v2.LogExclusion in project java-logging by googleapis.
the class ConfigClientTest method createExclusionTest5.
@Test
public void createExclusionTest5() 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 parent = "parent-995424086";
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, actualRequest.getParent());
Assert.assertEquals(exclusion, actualRequest.getExclusion());
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 updateExclusionTest.
@Test
public void updateExclusionTest() 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 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.toString(), actualRequest.getName());
Assert.assertEquals(exclusion, actualRequest.getExclusion());
Assert.assertEquals(updateMask, actualRequest.getUpdateMask());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations