use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method modifyAckDeadlineTest.
@Test
@SuppressWarnings("all")
public void modifyAckDeadlineTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
List<String> ackIds = new ArrayList<>();
int ackDeadlineSeconds = 2135351438;
client.modifyAckDeadline(subscription, ackIds, ackDeadlineSeconds);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ModifyAckDeadlineRequest actualRequest = (ModifyAckDeadlineRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
Assert.assertEquals(ackIds, actualRequest.getAckIdsList());
Assert.assertEquals(ackDeadlineSeconds, actualRequest.getAckDeadlineSeconds());
}
use of com.google.protobuf.GeneratedMessageV3 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());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method listSubscriptionsTest.
@Test
@SuppressWarnings("all")
public void listSubscriptionsTest() {
String nextPageToken = "";
Subscription subscriptionsElement = Subscription.newBuilder().build();
List<Subscription> subscriptions = Arrays.asList(subscriptionsElement);
ListSubscriptionsResponse expectedResponse = ListSubscriptionsResponse.newBuilder().setNextPageToken(nextPageToken).addAllSubscriptions(subscriptions).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.create("[PROJECT]");
ListSubscriptionsPagedResponse pagedListResponse = client.listSubscriptions(project);
List<Subscription> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSubscriptionsList().get(0), resources.get(0));
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSubscriptionsRequest actualRequest = (ListSubscriptionsRequest) actualRequests.get(0);
Assert.assertEquals(project, actualRequest.getProjectAsProjectName());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method getIamPolicyTest.
@Test
@SuppressWarnings("all")
public void getIamPolicyTest() {
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 actualResponse = client.getIamPolicy(formattedResource);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockIAMPolicy.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIamPolicyRequest actualRequest = (GetIamPolicyRequest) actualRequests.get(0);
Assert.assertEquals(formattedResource, actualRequest.getResource());
}
use of com.google.protobuf.GeneratedMessageV3 in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method acknowledgeTest.
@Test
@SuppressWarnings("all")
public void acknowledgeTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
List<String> ackIds = new ArrayList<>();
client.acknowledge(subscription, ackIds);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
AcknowledgeRequest actualRequest = (AcknowledgeRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
Assert.assertEquals(ackIds, actualRequest.getAckIdsList());
}
Aggregations