Search in sources :

Example 36 with LogExclusion

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

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

the class LoggingImplTest method testCreateExclusion.

@Test
public void testCreateExclusion() {
    LogExclusion exclusionPb = EXCLUSION.toProtobuf();
    ApiFuture<LogExclusion> response = ApiFutures.immediateFuture(exclusionPb);
    CreateExclusionRequest request = CreateExclusionRequest.newBuilder().setParent(PROJECT_PARENT).setExclusion(exclusionPb).build();
    EasyMock.expect(loggingRpcMock.create(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Exclusion exclusion = logging.create(EXCLUSION);
    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 : CreateExclusionRequest(com.google.logging.v2.CreateExclusionRequest) LogExclusion(com.google.logging.v2.LogExclusion) LogExclusion(com.google.logging.v2.LogExclusion) Test(org.junit.Test)

Example 38 with LogExclusion

use of com.google.logging.v2.LogExclusion 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)

Example 39 with LogExclusion

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

the class LoggingImplTest method testCreateExclusionAsync.

@Test
public void testCreateExclusionAsync() throws ExecutionException, InterruptedException {
    LogExclusion exclusionPb = EXCLUSION.toProtobuf();
    ApiFuture<LogExclusion> response = ApiFutures.immediateFuture(exclusionPb);
    CreateExclusionRequest request = CreateExclusionRequest.newBuilder().setParent(PROJECT_PARENT).setExclusion(exclusionPb).build();
    EasyMock.expect(loggingRpcMock.create(request)).andReturn(response);
    EasyMock.replay(rpcFactoryMock, loggingRpcMock);
    logging = options.getService();
    Exclusion exclusion = logging.createAsync(EXCLUSION).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 : CreateExclusionRequest(com.google.logging.v2.CreateExclusionRequest) LogExclusion(com.google.logging.v2.LogExclusion) LogExclusion(com.google.logging.v2.LogExclusion) Test(org.junit.Test)

Example 40 with LogExclusion

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

the class LoggingImplTest method testGetExclusion_Null.

@Test
public void testGetExclusion_Null() {
    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.getExclusion(EXCLUSION_NAME);
    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)

Aggregations

Test (org.junit.Test)40 LogExclusion (com.google.logging.v2.LogExclusion)29 AbstractMessage (com.google.protobuf.AbstractMessage)25 LogSink (com.google.logging.v2.LogSink)11 ArrayList (java.util.ArrayList)11 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)7 CreateExclusionRequest (com.google.logging.v2.CreateExclusionRequest)7 StatusRuntimeException (io.grpc.StatusRuntimeException)7 GetExclusionRequest (com.google.logging.v2.GetExclusionRequest)6 FieldMask (com.google.protobuf.FieldMask)6 ListExclusionsPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListExclusionsPagedResponse)5 CreateSinkRequest (com.google.logging.v2.CreateSinkRequest)5 ListExclusionsRequest (com.google.logging.v2.ListExclusionsRequest)5 ListExclusionsResponse (com.google.logging.v2.ListExclusionsResponse)5 BillingAccountName (com.google.logging.v2.BillingAccountName)4 FolderName (com.google.logging.v2.FolderName)4 OrganizationName (com.google.logging.v2.OrganizationName)4 ProjectName (com.google.logging.v2.ProjectName)4 UpdateExclusionRequest (com.google.logging.v2.UpdateExclusionRequest)4 UpdateSinkRequest (com.google.logging.v2.UpdateSinkRequest)4