Search in sources :

Example 11 with GeneratedMessageV3

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());
}
Also used : Empty(com.google.protobuf.Empty) ModifyAckDeadlineRequest(com.google.pubsub.v1.ModifyAckDeadlineRequest) ArrayList(java.util.ArrayList) SubscriptionName(com.google.pubsub.v1.SubscriptionName) ByteString(com.google.protobuf.ByteString) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 12 with GeneratedMessageV3

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());
}
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 13 with GeneratedMessageV3

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());
}
Also used : ListSubscriptionsPagedResponse(com.google.cloud.pubsub.spi.v1.PagedResponseWrappers.ListSubscriptionsPagedResponse) ListSubscriptionsResponse(com.google.pubsub.v1.ListSubscriptionsResponse) ProjectName(com.google.pubsub.v1.ProjectName) ListSubscriptionsRequest(com.google.pubsub.v1.ListSubscriptionsRequest) ByteString(com.google.protobuf.ByteString) Subscription(com.google.pubsub.v1.Subscription) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 14 with GeneratedMessageV3

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());
}
Also used : Policy(com.google.iam.v1.Policy) ByteString(com.google.protobuf.ByteString) ByteString(com.google.protobuf.ByteString) GetIamPolicyRequest(com.google.iam.v1.GetIamPolicyRequest) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Example 15 with GeneratedMessageV3

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());
}
Also used : Empty(com.google.protobuf.Empty) AcknowledgeRequest(com.google.pubsub.v1.AcknowledgeRequest) ArrayList(java.util.ArrayList) SubscriptionName(com.google.pubsub.v1.SubscriptionName) ByteString(com.google.protobuf.ByteString) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) Test(org.junit.Test)

Aggregations

GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)75 Test (org.junit.Test)75 ByteString (com.google.protobuf.ByteString)13 Empty (com.google.protobuf.Empty)13 SubscriptionName (com.google.pubsub.v1.SubscriptionName)9 ArrayList (java.util.ArrayList)8 TopicName (com.google.pubsub.v1.TopicName)7 Document (com.google.cloud.language.v1beta2.Document)5 GroupName (com.google.monitoring.v3.GroupName)5 ProjectName (com.google.monitoring.v3.ProjectName)5 Document (com.google.cloud.language.v1.Document)4 EncodingType (com.google.cloud.language.v1beta2.EncodingType)4 ProjectName (com.google.devtools.clouderrorreporting.v1beta1.ProjectName)4 LogMetric (com.google.logging.v2.LogMetric)4 LogSink (com.google.logging.v2.LogSink)4 ParentNameOneof (com.google.logging.v2.ParentNameOneof)4 MetricDescriptor (com.google.api.MetricDescriptor)3 ResourceName (com.google.api.resourcenames.ResourceName)3 EncodingType (com.google.cloud.language.v1.EncodingType)3 Policy (com.google.iam.v1.Policy)3