Search in sources :

Example 1 with ListSinksPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse in project java-logging by googleapis.

the class ConfigClientTest method listSinksTest2.

@Test
public void listSinksTest2() throws Exception {
    LogSink responsesElement = LogSink.newBuilder().build();
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken("").addAllSinks(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = ((ListSinksRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListSinksPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse) ListSinksRequest(com.google.logging.v2.ListSinksRequest) FolderName(com.google.logging.v2.FolderName) Test(org.junit.Test)

Example 2 with ListSinksPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse in project java-logging by googleapis.

the class ConfigClientTest method listSinksTest3.

@Test
public void listSinksTest3() throws Exception {
    LogSink responsesElement = LogSink.newBuilder().build();
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken("").addAllSinks(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = ((ListSinksRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : OrganizationName(com.google.logging.v2.OrganizationName) LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListSinksPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse) ListSinksRequest(com.google.logging.v2.ListSinksRequest) Test(org.junit.Test)

Example 3 with ListSinksPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse in project java-logging by googleapis.

the class ConfigClientTest method listSinksTest.

@Test
public void listSinksTest() throws Exception {
    LogSink responsesElement = LogSink.newBuilder().build();
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken("").addAllSinks(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = ((ListSinksRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListSinksPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse) BillingAccountName(com.google.logging.v2.BillingAccountName) ListSinksRequest(com.google.logging.v2.ListSinksRequest) Test(org.junit.Test)

Example 4 with ListSinksPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse in project java-logging by googleapis.

the class ConfigClientTest method listSinksTest5.

@Test
public void listSinksTest5() throws Exception {
    LogSink responsesElement = LogSink.newBuilder().build();
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken("").addAllSinks(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = ((ListSinksRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListSinksPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse) ListSinksRequest(com.google.logging.v2.ListSinksRequest) Test(org.junit.Test)

Example 5 with ListSinksPagedResponse

use of com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse in project java-logging by googleapis.

the class ConfigClientTest method listSinksTest4.

@Test
public void listSinksTest4() throws Exception {
    LogSink responsesElement = LogSink.newBuilder().build();
    ListSinksResponse expectedResponse = ListSinksResponse.newBuilder().setNextPageToken("").addAllSinks(Arrays.asList(responsesElement)).build();
    mockConfigServiceV2.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListSinksPagedResponse pagedListResponse = client.listSinks(parent);
    List<LogSink> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getSinksList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListSinksRequest actualRequest = ((ListSinksRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : LogSink(com.google.logging.v2.LogSink) ListSinksResponse(com.google.logging.v2.ListSinksResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListSinksPagedResponse(com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse) ProjectName(com.google.logging.v2.ProjectName) ListSinksRequest(com.google.logging.v2.ListSinksRequest) Test(org.junit.Test)

Aggregations

ListSinksPagedResponse (com.google.cloud.logging.v2.ConfigClient.ListSinksPagedResponse)5 ListSinksRequest (com.google.logging.v2.ListSinksRequest)5 ListSinksResponse (com.google.logging.v2.ListSinksResponse)5 LogSink (com.google.logging.v2.LogSink)5 AbstractMessage (com.google.protobuf.AbstractMessage)5 Test (org.junit.Test)5 BillingAccountName (com.google.logging.v2.BillingAccountName)1 FolderName (com.google.logging.v2.FolderName)1 OrganizationName (com.google.logging.v2.OrganizationName)1 ProjectName (com.google.logging.v2.ProjectName)1