use of org.apache.tapestry5.Binding in project java-resourcemanager by googleapis.
the class OrganizationsClientTest method setIamPolicyTest2.
@Test
public void setIamPolicyTest2() throws Exception {
Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
mockOrganizations.addResponse(expectedResponse);
String resource = "resource-341064690";
Policy actualResponse = client.setIamPolicy(resource);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockOrganizations.getRequests();
Assert.assertEquals(1, actualRequests.size());
SetIamPolicyRequest actualRequest = ((SetIamPolicyRequest) actualRequests.get(0));
Assert.assertEquals(resource, actualRequest.getResource());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.apache.tapestry5.Binding in project java-resourcemanager by googleapis.
the class ProjectsClientTest method getIamPolicyTest2.
@Test
public void getIamPolicyTest2() throws Exception {
Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
mockProjects.addResponse(expectedResponse);
String resource = "resource-341064690";
Policy actualResponse = client.getIamPolicy(resource);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockProjects.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
Assert.assertEquals(resource, actualRequest.getResource());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.apache.tapestry5.Binding in project java-resourcemanager by googleapis.
the class FoldersClientTest method getIamPolicyTest.
@Test
public void getIamPolicyTest() throws Exception {
Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
mockFolders.addResponse(expectedResponse);
ResourceName resource = FolderName.of("[FOLDER]");
Policy actualResponse = client.getIamPolicy(resource);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFolders.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
Assert.assertEquals(resource.toString(), actualRequest.getResource());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.apache.tapestry5.Binding in project java-resourcemanager by googleapis.
the class TagValuesClientTest method getIamPolicyTest2.
@Test
public void getIamPolicyTest2() throws Exception {
Policy expectedResponse = Policy.newBuilder().setVersion(351608024).addAllBindings(new ArrayList<Binding>()).setEtag(ByteString.EMPTY).build();
mockTagValues.addResponse(expectedResponse);
String resource = "resource-341064690";
Policy actualResponse = client.getIamPolicy(resource);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockTagValues.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIamPolicyRequest actualRequest = ((GetIamPolicyRequest) actualRequests.get(0));
Assert.assertEquals(resource, actualRequest.getResource());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of org.apache.tapestry5.Binding in project java-notification by googleapis.
the class ITSystemTest method testNotifications.
@Test
public void testNotifications() {
// Use Pubsub to create a Topic.
final ProjectTopicName topic = ProjectTopicName.of(projectId, formatForTest("testing-topic-foo"));
topicAdminClient.createTopic(topic);
Policy policy = topicAdminClient.getIamPolicy(topic.toString());
Binding binding = Binding.newBuilder().setRole("roles/owner").addMembers("allAuthenticatedUsers").build();
Policy newPolicy = topicAdminClient.setIamPolicy(topic.toString(), policy.toBuilder().addBindings(binding).build());
assertTrue(newPolicy.getBindingsList().contains(binding));
String permissionName = "pubsub.topics.get";
List<String> permissions = topicAdminClient.testIamPermissions(topic.toString(), Collections.singletonList(permissionName)).getPermissionsList();
assertTrue(permissions.contains(permissionName));
// Use Storage API to create a Notification on that Topic.
NotificationInfo notification = notificationService.createNotification(BUCKET, NotificationInfo.of(topic));
assertNotNull(notification);
List<NotificationInfo> notifications = notificationService.listNotifications(BUCKET);
assertTrue(notifications.contains(notification));
assertEquals(1, notifications.size());
NotificationInfo notification2 = notificationService.createNotification(BUCKET, NotificationInfo.of(topic).toBuilder().setPayloadFormat(PayloadFormat.JSON_API_V1).build());
assertEquals(topic, notification2.getTopic());
notifications = notificationService.listNotifications(BUCKET);
assertTrue(notifications.contains(notification));
assertTrue(notifications.contains(notification2));
assertEquals(2, notifications.size());
assertTrue(notificationService.deleteNotification(BUCKET, notification.getGeneratedId()));
assertTrue(notificationService.deleteNotification(BUCKET, notification2.getGeneratedId()));
assertNull(notificationService.listNotifications(BUCKET));
topicAdminClient.deleteTopic(topic);
}
Aggregations