Search in sources :

Example 1 with GetExclusionRequest

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

Example 2 with GetExclusionRequest

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

Example 3 with GetExclusionRequest

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

the class LoggingImplTest method testGetExclusionAsync.

@Test
public void testGetExclusionAsync() throws ExecutionException, InterruptedException {
    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.getExclusionAsync(EXCLUSION_NAME).get();
    assertEquals(EXCLUSION_NAME, exclusion.getName());
    assertEquals(DESCRIPTION, exclusion.getDescription());
    assertEquals(EXCLUSION_FILTER, exclusion.getFilter());
    assertEquals(DISABLED, exclusion.isDisabled());
    assertEquals(EXCLUSION_CREATED_TIME, exclusion.getCreateTime());
}
Also used : LogExclusion(com.google.logging.v2.LogExclusion) LogExclusion(com.google.logging.v2.LogExclusion) GetExclusionRequest(com.google.logging.v2.GetExclusionRequest) Test(org.junit.Test)

Example 4 with GetExclusionRequest

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

the class ConfigClientTest method getExclusionTest2.

@Test
public void getExclusionTest2() 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 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, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) LogExclusion(com.google.logging.v2.LogExclusion) GetExclusionRequest(com.google.logging.v2.GetExclusionRequest) Test(org.junit.Test)

Example 5 with GetExclusionRequest

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

Aggregations

GetExclusionRequest (com.google.logging.v2.GetExclusionRequest)6 LogExclusion (com.google.logging.v2.LogExclusion)6 Test (org.junit.Test)6 AbstractMessage (com.google.protobuf.AbstractMessage)2 LogExclusionName (com.google.logging.v2.LogExclusionName)1