Search in sources :

Example 1 with UpdateExclusionRequest

use of com.google.logging.v2.UpdateExclusionRequest 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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) UpdateExclusionRequest(com.google.logging.v2.UpdateExclusionRequest) LogExclusion(com.google.logging.v2.LogExclusion) LogExclusionName(com.google.logging.v2.LogExclusionName) FieldMask(com.google.protobuf.FieldMask) Test(org.junit.Test)

Example 2 with UpdateExclusionRequest

use of com.google.logging.v2.UpdateExclusionRequest 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 3 with UpdateExclusionRequest

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

the class LoggingImplTest method testUpdateExclusion.

@Test
public void testUpdateExclusion() {
    LogExclusion exclusionPb = EXCLUSION1.toProtobuf();
    ApiFuture<LogExclusion> response = ApiFutures.immediateFuture(exclusionPb);
    UpdateExclusionRequest request = UpdateExclusionRequest.newBuilder().setName(EXCLUSION_NAME_PB).setExclusion(exclusionPb).build();
    EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Exclusion exclusion = logging.update(EXCLUSION1);
    assertEquals(EXCLUSION_NAME, exclusion.getName());
    assertEquals(DESCRIPTION, exclusion.getDescription());
    assertEquals(EXCLUSION_FILTER, exclusion.getFilter());
    assertEquals(DISABLED, exclusion.isDisabled());
    assertEquals(EXCLUSION_UPDATED_TIME, exclusion.getUpdateTime());
}
Also used : UpdateExclusionRequest(com.google.logging.v2.UpdateExclusionRequest) LogExclusion(com.google.logging.v2.LogExclusion) LogExclusion(com.google.logging.v2.LogExclusion) Test(org.junit.Test)

Example 4 with UpdateExclusionRequest

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

the class LoggingImplTest method testUpdateExclusionAsync.

@Test
public void testUpdateExclusionAsync() throws ExecutionException, InterruptedException {
    LogExclusion exclusionPb = EXCLUSION1.toProtobuf();
    ApiFuture<LogExclusion> response = ApiFutures.immediateFuture(exclusionPb);
    UpdateExclusionRequest request = UpdateExclusionRequest.newBuilder().setName(EXCLUSION_NAME_PB).setExclusion(exclusionPb).build();
    EasyMock.expect(loggingRpcMock.update(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Exclusion exclusion = logging.updateAsync(EXCLUSION1).get();
    assertEquals(EXCLUSION_NAME, exclusion.getName());
    assertEquals(DESCRIPTION, exclusion.getDescription());
    assertEquals(EXCLUSION_FILTER, exclusion.getFilter());
    assertEquals(DISABLED, exclusion.isDisabled());
    assertEquals(EXCLUSION_UPDATED_TIME, exclusion.getUpdateTime());
}
Also used : UpdateExclusionRequest(com.google.logging.v2.UpdateExclusionRequest) LogExclusion(com.google.logging.v2.LogExclusion) LogExclusion(com.google.logging.v2.LogExclusion) Test(org.junit.Test)

Aggregations

LogExclusion (com.google.logging.v2.LogExclusion)4 UpdateExclusionRequest (com.google.logging.v2.UpdateExclusionRequest)4 Test (org.junit.Test)4 AbstractMessage (com.google.protobuf.AbstractMessage)2 FieldMask (com.google.protobuf.FieldMask)2 LogExclusionName (com.google.logging.v2.LogExclusionName)1