Search in sources :

Example 11 with GroupName

use of com.google.monitoring.v3.GroupName in project google-cloud-java by GoogleCloudPlatform.

the class ErrorGroupServiceClientTest method getGroupTest.

@Test
@SuppressWarnings("all")
public void getGroupTest() {
    GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
    String groupId = "groupId506361563";
    ErrorGroup expectedResponse = ErrorGroup.newBuilder().setNameWithGroupName(name).setGroupId(groupId).build();
    mockErrorGroupService.addResponse(expectedResponse);
    GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
    ErrorGroup actualResponse = client.getGroup(groupName);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockErrorGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetGroupRequest actualRequest = (GetGroupRequest) actualRequests.get(0);
    Assert.assertEquals(groupName, actualRequest.getGroupNameAsGroupName());
}
Also used : GroupName(com.google.devtools.clouderrorreporting.v1beta1.GroupName) ErrorGroup(com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup) GetGroupRequest(com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 12 with GroupName

use of com.google.monitoring.v3.GroupName in project google-cloud-java by GoogleCloudPlatform.

the class ErrorGroupServiceClientTest method getGroupExceptionTest.

@Test
@SuppressWarnings("all")
public void getGroupExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockErrorGroupService.addException(exception);
    try {
        GroupName groupName = GroupName.create("[PROJECT]", "[GROUP]");
        client.getGroup(groupName);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : GroupName(com.google.devtools.clouderrorreporting.v1beta1.GroupName) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)11 GroupName (com.google.monitoring.v3.GroupName)8 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)7 ApiException (com.google.api.gax.grpc.ApiException)4 StatusRuntimeException (io.grpc.StatusRuntimeException)4 GroupName (com.google.devtools.clouderrorreporting.v1beta1.GroupName)3 Group (com.google.monitoring.v3.Group)3 ErrorGroup (com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup)2 DeleteGroupRequest (com.google.monitoring.v3.DeleteGroupRequest)2 MonitoredResource (com.google.api.MonitoredResource)1 ListGroupMembersPagedResponse (com.google.cloud.monitoring.spi.v3.PagedResponseWrappers.ListGroupMembersPagedResponse)1 GetGroupRequest (com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest)1 UpdateGroupRequest (com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest)1 CreateGroupRequest (com.google.monitoring.v3.CreateGroupRequest)1 GetGroupRequest (com.google.monitoring.v3.GetGroupRequest)1 ListGroupMembersRequest (com.google.monitoring.v3.ListGroupMembersRequest)1 ListGroupMembersResponse (com.google.monitoring.v3.ListGroupMembersResponse)1 ProjectName (com.google.monitoring.v3.ProjectName)1 UpdateGroupRequest (com.google.monitoring.v3.UpdateGroupRequest)1 Empty (com.google.protobuf.Empty)1