Search in sources :

Example 1 with GroupName

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

the class GroupServiceClientTest method getGroupExceptionTest.

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

Example 2 with GroupName

use of com.google.monitoring.v3.GroupName 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 3 with GroupName

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

the class GroupServiceClientTest method createGroupTest.

@Test
@SuppressWarnings("all")
public void createGroupTest() {
    GroupName name2 = GroupName.create("[PROJECT]", "[GROUP]");
    String displayName = "displayName1615086568";
    GroupName parentName = GroupName.create("[PROJECT]", "[GROUP]");
    String filter = "filter-1274492040";
    boolean isCluster = false;
    Group expectedResponse = Group.newBuilder().setNameWithGroupName(name2).setDisplayName(displayName).setParentNameWithGroupName(parentName).setFilter(filter).setIsCluster(isCluster).build();
    mockGroupService.addResponse(expectedResponse);
    ProjectName name = ProjectName.create("[PROJECT]");
    Group group = Group.newBuilder().build();
    Group actualResponse = client.createGroup(name, group);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateGroupRequest actualRequest = (CreateGroupRequest) actualRequests.get(0);
    Assert.assertEquals(name, actualRequest.getNameAsProjectName());
    Assert.assertEquals(group, actualRequest.getGroup());
}
Also used : GroupName(com.google.monitoring.v3.GroupName) Group(com.google.monitoring.v3.Group) ProjectName(com.google.monitoring.v3.ProjectName) CreateGroupRequest(com.google.monitoring.v3.CreateGroupRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 4 with GroupName

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

the class GroupServiceClientTest method updateGroupTest.

@Test
@SuppressWarnings("all")
public void updateGroupTest() {
    GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
    String displayName = "displayName1615086568";
    GroupName parentName = GroupName.create("[PROJECT]", "[GROUP]");
    String filter = "filter-1274492040";
    boolean isCluster = false;
    Group expectedResponse = Group.newBuilder().setNameWithGroupName(name).setDisplayName(displayName).setParentNameWithGroupName(parentName).setFilter(filter).setIsCluster(isCluster).build();
    mockGroupService.addResponse(expectedResponse);
    Group group = Group.newBuilder().build();
    Group actualResponse = client.updateGroup(group);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockGroupService.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    UpdateGroupRequest actualRequest = (UpdateGroupRequest) actualRequests.get(0);
    Assert.assertEquals(group, actualRequest.getGroup());
}
Also used : GroupName(com.google.monitoring.v3.GroupName) Group(com.google.monitoring.v3.Group) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) UpdateGroupRequest(com.google.monitoring.v3.UpdateGroupRequest) Test(org.junit.Test)

Example 5 with GroupName

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

the class GroupServiceClientTest method deleteGroupExceptionTest.

@Test
@SuppressWarnings("all")
public void deleteGroupExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockGroupService.addException(exception);
    try {
        GroupName name = GroupName.create("[PROJECT]", "[GROUP]");
        client.deleteGroup(name);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : GroupName(com.google.monitoring.v3.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