Search in sources :

Example 1 with ListNotificationsPagedResponse

use of com.google.storage.v2.StorageClient.ListNotificationsPagedResponse in project java-storage by googleapis.

the class StorageClientTest method listNotificationsTest.

@Test
public void listNotificationsTest() throws Exception {
    Notification responsesElement = Notification.newBuilder().build();
    ListNotificationsResponse expectedResponse = ListNotificationsResponse.newBuilder().setNextPageToken("").addAllNotifications(Arrays.asList(responsesElement)).build();
    mockStorage.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListNotificationsPagedResponse pagedListResponse = client.listNotifications(parent);
    List<Notification> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getNotificationsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockStorage.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListNotificationsRequest actualRequest = ((ListNotificationsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListNotificationsPagedResponse(com.google.storage.v2.StorageClient.ListNotificationsPagedResponse) Test(org.junit.Test)

Example 2 with ListNotificationsPagedResponse

use of com.google.storage.v2.StorageClient.ListNotificationsPagedResponse in project gapic-generator-java by googleapis.

the class StorageClientTest method listNotificationsTest2.

@Test
public void listNotificationsTest2() throws Exception {
    Notification responsesElement = Notification.newBuilder().build();
    ListNotificationsResponse expectedResponse = ListNotificationsResponse.newBuilder().setNextPageToken("").addAllNotifications(Arrays.asList(responsesElement)).build();
    mockStorage.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListNotificationsPagedResponse pagedListResponse = client.listNotifications(parent);
    List<Notification> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getNotificationsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockStorage.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListNotificationsRequest actualRequest = ((ListNotificationsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) ListNotificationsPagedResponse(com.google.storage.v2.StorageClient.ListNotificationsPagedResponse) Test(org.junit.Test)

Example 3 with ListNotificationsPagedResponse

use of com.google.storage.v2.StorageClient.ListNotificationsPagedResponse in project java-storage by googleapis.

the class StorageClientTest method listNotificationsTest2.

@Test
public void listNotificationsTest2() throws Exception {
    Notification responsesElement = Notification.newBuilder().build();
    ListNotificationsResponse expectedResponse = ListNotificationsResponse.newBuilder().setNextPageToken("").addAllNotifications(Arrays.asList(responsesElement)).build();
    mockStorage.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListNotificationsPagedResponse pagedListResponse = client.listNotifications(parent);
    List<Notification> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getNotificationsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockStorage.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListNotificationsRequest actualRequest = ((ListNotificationsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ByteString(com.google.protobuf.ByteString) ListNotificationsPagedResponse(com.google.storage.v2.StorageClient.ListNotificationsPagedResponse) Test(org.junit.Test)

Example 4 with ListNotificationsPagedResponse

use of com.google.storage.v2.StorageClient.ListNotificationsPagedResponse in project gapic-generator-java by googleapis.

the class StorageClientTest method listNotificationsTest.

@Test
public void listNotificationsTest() throws Exception {
    Notification responsesElement = Notification.newBuilder().build();
    ListNotificationsResponse expectedResponse = ListNotificationsResponse.newBuilder().setNextPageToken("").addAllNotifications(Arrays.asList(responsesElement)).build();
    mockStorage.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListNotificationsPagedResponse pagedListResponse = client.listNotifications(parent);
    List<Notification> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getNotificationsList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockStorage.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListNotificationsRequest actualRequest = ((ListNotificationsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ListNotificationsPagedResponse(com.google.storage.v2.StorageClient.ListNotificationsPagedResponse) Test(org.junit.Test)

Aggregations

AbstractMessage (com.google.protobuf.AbstractMessage)4 ListNotificationsPagedResponse (com.google.storage.v2.StorageClient.ListNotificationsPagedResponse)4 Test (org.junit.Test)4 ByteString (com.google.protobuf.ByteString)2