Search in sources :

Example 1 with TestIamPermissionsRequest

use of com.google.iam.v1.TestIamPermissionsRequest in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method testIamPermissionsTest.

@Test
@SuppressWarnings("all")
public void testIamPermissionsTest() {
    TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build();
    mockIAMPolicy.addResponse(expectedResponse);
    String formattedResource = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]").toString();
    List<String> permissions = new ArrayList<>();
    TestIamPermissionsResponse actualResponse = client.testIamPermissions(formattedResource, permissions);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0);
    Assert.assertEquals(formattedResource, actualRequest.getResource());
    Assert.assertEquals(permissions, actualRequest.getPermissionsList());
}
Also used : TestIamPermissionsResponse(com.google.iam.v1.TestIamPermissionsResponse) TestIamPermissionsRequest(com.google.iam.v1.TestIamPermissionsRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 2 with TestIamPermissionsRequest

use of com.google.iam.v1.TestIamPermissionsRequest in project google-cloud-java by GoogleCloudPlatform.

the class TopicAdminClientTest method testIamPermissionsTest.

@Test
@SuppressWarnings("all")
public void testIamPermissionsTest() {
    TestIamPermissionsResponse expectedResponse = TestIamPermissionsResponse.newBuilder().build();
    mockIAMPolicy.addResponse(expectedResponse);
    String formattedResource = TopicName.create("[PROJECT]", "[TOPIC]").toString();
    List<String> permissions = new ArrayList<>();
    TestIamPermissionsResponse actualResponse = client.testIamPermissions(formattedResource, permissions);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    TestIamPermissionsRequest actualRequest = (TestIamPermissionsRequest) actualRequests.get(0);
    Assert.assertEquals(formattedResource, actualRequest.getResource());
    Assert.assertEquals(permissions, actualRequest.getPermissionsList());
}
Also used : TestIamPermissionsResponse(com.google.iam.v1.TestIamPermissionsResponse) TestIamPermissionsRequest(com.google.iam.v1.TestIamPermissionsRequest) ArrayList(java.util.ArrayList) ByteString(com.google.protobuf.ByteString) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

TestIamPermissionsRequest (com.google.iam.v1.TestIamPermissionsRequest)2 TestIamPermissionsResponse (com.google.iam.v1.TestIamPermissionsResponse)2 ByteString (com.google.protobuf.ByteString)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2