Search in sources :

Example 1 with ErrorGroup

use of com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup in project google-cloud-java by GoogleCloudPlatform.

the class ErrorGroupServiceClientTest method updateGroupTest.

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

Example 2 with ErrorGroup

use of com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup in project google-cloud-java by GoogleCloudPlatform.

the class ErrorGroupServiceClientTest method updateGroupExceptionTest.

@Test
@SuppressWarnings("all")
public void updateGroupExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockErrorGroupService.addException(exception);
    try {
        ErrorGroup group = ErrorGroup.newBuilder().build();
        client.updateGroup(group);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : ErrorGroup(com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup) StatusRuntimeException(io.grpc.StatusRuntimeException) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Example 3 with ErrorGroup

use of com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup 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)

Aggregations

ErrorGroup (com.google.devtools.clouderrorreporting.v1beta1.ErrorGroup)3 Test (org.junit.Test)3 GroupName (com.google.devtools.clouderrorreporting.v1beta1.GroupName)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 ApiException (com.google.api.gax.grpc.ApiException)1 GetGroupRequest (com.google.devtools.clouderrorreporting.v1beta1.GetGroupRequest)1 UpdateGroupRequest (com.google.devtools.clouderrorreporting.v1beta1.UpdateGroupRequest)1 StatusRuntimeException (io.grpc.StatusRuntimeException)1