@Override public Iterable<Subscription> extractResources(ListSubscriptionsResponse payload) { return payload.getSubscriptionsList() != null ? payload.getSubscriptionsList() : ImmutableList.<Subscription>of(); } };
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.ListSubscriptionsResponse)) { return super.equals(obj); } com.google.pubsub.v1.ListSubscriptionsResponse other = (com.google.pubsub.v1.ListSubscriptionsResponse) obj; boolean result = true; result = result && getSubscriptionsList().equals(other.getSubscriptionsList()); result = result && getNextPageToken().equals(other.getNextPageToken()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getSubscriptionsCount() > 0) { hash = (37 * hash) + SUBSCRIPTIONS_FIELD_NUMBER; hash = (53 * hash) + getSubscriptionsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@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.of("[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, ProjectName.parse(actualRequest.getProject())); Assert.assertTrue( channelProvider.isHeaderSent( ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern())); }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.ListSubscriptionsResponse)) { return super.equals(obj); } com.google.pubsub.v1.ListSubscriptionsResponse other = (com.google.pubsub.v1.ListSubscriptionsResponse) obj; boolean result = true; result = result && getSubscriptionsList().equals(other.getSubscriptionsList()); result = result && getNextPageToken().equals(other.getNextPageToken()); result = result && unknownFields.equals(other.unknownFields); return result; }
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof com.google.pubsub.v1.ListSubscriptionsResponse)) { return super.equals(obj); } com.google.pubsub.v1.ListSubscriptionsResponse other = (com.google.pubsub.v1.ListSubscriptionsResponse) obj; boolean result = true; result = result && getSubscriptionsList() .equals(other.getSubscriptionsList()); result = result && getNextPageToken() .equals(other.getNextPageToken()); return result; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptorForType().hashCode(); if (getSubscriptionsCount() > 0) { hash = (37 * hash) + SUBSCRIPTIONS_FIELD_NUMBER; hash = (53 * hash) + getSubscriptionsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); if (getSubscriptionsCount() > 0) { hash = (37 * hash) + SUBSCRIPTIONS_FIELD_NUMBER; hash = (53 * hash) + getSubscriptionsList().hashCode(); } hash = (37 * hash) + NEXT_PAGE_TOKEN_FIELD_NUMBER; hash = (53 * hash) + getNextPageToken().hashCode(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
@Override public List<SubscriptionPath> listSubscriptions(ProjectPath project, TopicPath topic) throws IOException { ListSubscriptionsRequest.Builder request = ListSubscriptionsRequest.newBuilder() .setProject(project.getPath()) .setPageSize(LIST_BATCH_SIZE); ListSubscriptionsResponse response = subscriberStub().listSubscriptions(request.build()); if (response.getSubscriptionsCount() == 0) { return ImmutableList.of(); } List<SubscriptionPath> subscriptions = new ArrayList<>(response.getSubscriptionsCount()); while (true) { for (Subscription subscription : response.getSubscriptionsList()) { if (subscription.getTopic().equals(topic.getPath())) { subscriptions.add(subscriptionPathFromPath(subscription.getName())); } } if (response.getNextPageToken().isEmpty()) { break; } request.setPageToken(response.getNextPageToken()); response = subscriberStub().listSubscriptions(request.build()); } return subscriptions; }