use of com.google.iam.v1.SetIamPolicyRequest in project google-cloud-java by GoogleCloudPlatform.
the class TopicAdminClientTest method setIamPolicyTest.
@Test
@SuppressWarnings("all")
public void setIamPolicyTest() {
int version = 351608024;
ByteString etag = ByteString.copyFromUtf8("21");
Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build();
mockIAMPolicy.addResponse(expectedResponse);
String formattedResource = TopicName.create("[PROJECT]", "[TOPIC]").toString();
Policy policy = Policy.newBuilder().build();
Policy actualResponse = client.setIamPolicy(formattedResource, policy);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
Assert.assertEquals(1, actualRequests.size());
SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0);
Assert.assertEquals(formattedResource, actualRequest.getResource());
Assert.assertEquals(policy, actualRequest.getPolicy());
}
use of com.google.iam.v1.SetIamPolicyRequest in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method setIamPolicyTest.
@Test
@SuppressWarnings("all")
public void setIamPolicyTest() {
int version = 351608024;
ByteString etag = ByteString.copyFromUtf8("21");
Policy expectedResponse = Policy.newBuilder().setVersion(version).setEtag(etag).build();
mockIAMPolicy.addResponse(expectedResponse);
String formattedResource = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]").toString();
Policy policy = Policy.newBuilder().build();
Policy actualResponse = client.setIamPolicy(formattedResource, policy);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
Assert.assertEquals(1, actualRequests.size());
SetIamPolicyRequest actualRequest = (SetIamPolicyRequest) actualRequests.get(0);
Assert.assertEquals(formattedResource, actualRequest.getResource());
Assert.assertEquals(policy, actualRequest.getPolicy());
}
Aggregations