Search in sources :

Example 6 with PushConfig

use of com.google.pubsub.v1.PushConfig in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method modifyPushConfigTest.

@Test
@SuppressWarnings("all")
public void modifyPushConfigTest() {
    Empty expectedResponse = Empty.newBuilder().build();
    mockSubscriber.addResponse(expectedResponse);
    SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
    PushConfig pushConfig = PushConfig.newBuilder().build();
    client.modifyPushConfig(subscription, pushConfig);
    List<GeneratedMessageV3> actualRequests = mockSubscriber.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ModifyPushConfigRequest actualRequest = (ModifyPushConfigRequest) actualRequests.get(0);
    Assert.assertEquals(subscription, actualRequest.getSubscriptionAsSubscriptionName());
    Assert.assertEquals(pushConfig, actualRequest.getPushConfig());
}
Also used : PushConfig(com.google.pubsub.v1.PushConfig) Empty(com.google.protobuf.Empty) SubscriptionName(com.google.pubsub.v1.SubscriptionName) GeneratedMessageV3(com.google.protobuf.GeneratedMessageV3) ModifyPushConfigRequest(com.google.pubsub.v1.ModifyPushConfigRequest) Test(org.junit.Test)

Example 7 with PushConfig

use of com.google.pubsub.v1.PushConfig in project google-cloud-java by GoogleCloudPlatform.

the class SubscriptionAdminClientTest method modifyPushConfigExceptionTest.

@Test
@SuppressWarnings("all")
public void modifyPushConfigExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(Status.INVALID_ARGUMENT);
    mockSubscriber.addException(exception);
    try {
        SubscriptionName subscription = SubscriptionName.create("[PROJECT]", "[SUBSCRIPTION]");
        PushConfig pushConfig = PushConfig.newBuilder().build();
        client.modifyPushConfig(subscription, pushConfig);
        Assert.fail("No exception raised");
    } catch (ApiException e) {
        Assert.assertEquals(Status.INVALID_ARGUMENT.getCode(), e.getStatusCode());
    }
}
Also used : PushConfig(com.google.pubsub.v1.PushConfig) StatusRuntimeException(io.grpc.StatusRuntimeException) SubscriptionName(com.google.pubsub.v1.SubscriptionName) ApiException(com.google.api.gax.grpc.ApiException) Test(org.junit.Test)

Aggregations

PushConfig (com.google.pubsub.v1.PushConfig)6 SubscriptionName (com.google.pubsub.v1.SubscriptionName)6 Test (org.junit.Test)4 TopicName (com.google.pubsub.v1.TopicName)3 ApiException (com.google.api.gax.grpc.ApiException)2 SubscriptionAdminClient (com.google.cloud.pubsub.spi.v1.SubscriptionAdminClient)2 GeneratedMessageV3 (com.google.protobuf.GeneratedMessageV3)2 ModifyPushConfigRequest (com.google.pubsub.v1.ModifyPushConfigRequest)2 Subscription (com.google.pubsub.v1.Subscription)2 StatusRuntimeException (io.grpc.StatusRuntimeException)2 Empty (com.google.protobuf.Empty)1 TopicNameOneof (com.google.pubsub.v1.TopicNameOneof)1