use of com.google.pubsub.v1.SubscriptionName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method pullExceptionTest.
@Test
@SuppressWarnings("all")
public void pullExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
boolean returnImmediately = false;
int maxMessages = 496131527;
client.pull(subscription, returnImmediately, maxMessages);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.pubsub.v1.SubscriptionName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method createSubscriptionExceptionTest.
@Test
@SuppressWarnings("all")
public void createSubscriptionExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
SubscriptionName name = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
PushConfig pushConfig = PushConfig.newBuilder().build();
int ackDeadlineSeconds = 2135351438;
client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
Assert.fail("No exception raised");
} catch (ApiException e) {
Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
}
}
use of com.google.pubsub.v1.SubscriptionName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method pullTest.
@Test
@SuppressWarnings("all")
public void pullTest() {
PullResponse expectedResponse = PullResponse.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
boolean returnImmediately = false;
int maxMessages = 496131527;
PullResponse actualResponse = client.pull(subscription, returnImmediately, maxMessages);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
PullRequest actualRequest = (PullRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
Assert.assertEquals(returnImmediately, actualRequest.getReturnImmediately());
Assert.assertEquals(maxMessages, actualRequest.getMaxMessages());
}
use of com.google.pubsub.v1.SubscriptionName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method deleteSubscriptionTest.
@Test
@SuppressWarnings("all")
public void deleteSubscriptionTest() {
Empty expectedResponse = Empty.newBuilder().build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
client.deleteSubscription(subscription);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
DeleteSubscriptionRequest actualRequest = (DeleteSubscriptionRequest) actualRequests.get(0);
Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
}
use of com.google.pubsub.v1.SubscriptionName in project google-cloud-java by GoogleCloudPlatform.
the class SubscriptionAdminClientTest method createSubscriptionTest.
@Test
@SuppressWarnings("all")
public void createSubscriptionTest() {
SubscriptionName name2 = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
TopicNameOneof topic2 = TopicNameOneof.from(TopicName.create("[PROJECT]", "[TOPIC]"));
int ackDeadlineSeconds2 = -921632575;
boolean retainAckedMessages = false;
Subscription expectedResponse = Subscription.newBuilder().setNameWithSubscriptionName(name2).setTopicWithTopicNameOneof(topic2).setAckDeadlineSeconds(ackDeadlineSeconds2).setRetainAckedMessages(retainAckedMessages).build();
mockSubscriber.addResponse(expectedResponse);
SubscriptionName name = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
TopicName topic = TopicName.create("[PROJECT]", "[TOPIC]");
PushConfig pushConfig = PushConfig.newBuilder().build();
int ackDeadlineSeconds = 2135351438;
Subscription actualResponse = client.createSubscription(name, topic, pushConfig, ackDeadlineSeconds);
Assert.assertEquals(expectedResponse, actualResponse);
List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
Subscription actualRequest = (Subscription) actualRequests.get(0);
Assert.assertEquals(name, actualRequest.getNameAsSubscriptionName());
Assert.assertEquals(TopicNameOneof.from(topic), actualRequest.getTopicAsTopicNameOneof());
Assert.assertEquals(pushConfig, actualRequest.getPushConfig());
Assert.assertEquals(ackDeadlineSeconds, actualRequest.getAckDeadlineSeconds());
}
Aggregations