Search in sources :

Example 1 with ListLogsPagedResponse

use of com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse in project java-logging by googleapis.

the class LoggingClientTest method listLogsTest5.

@Test
public void listLogsTest5() throws Exception {
    String responsesElement = "responsesElement-318365110";
    ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken("").addAllLogNames(Arrays.asList(responsesElement)).build();
    mockLoggingServiceV2.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
    List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockLoggingServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogsRequest actualRequest = ((ListLogsRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListLogsResponse(com.google.logging.v2.ListLogsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse) Test(org.junit.Test)

Example 2 with ListLogsPagedResponse

use of com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse in project java-logging by googleapis.

the class LoggingClientTest method listLogsTest3.

@Test
public void listLogsTest3() throws Exception {
    String responsesElement = "responsesElement-318365110";
    ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken("").addAllLogNames(Arrays.asList(responsesElement)).build();
    mockLoggingServiceV2.addResponse(expectedResponse);
    OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
    ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
    List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockLoggingServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogsRequest actualRequest = ((ListLogsRequest) 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) ListLogsResponse(com.google.logging.v2.ListLogsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse) Test(org.junit.Test)

Example 3 with ListLogsPagedResponse

use of com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse in project java-logging by googleapis.

the class LoggingClientTest method listLogsTest4.

@Test
public void listLogsTest4() throws Exception {
    String responsesElement = "responsesElement-318365110";
    ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken("").addAllLogNames(Arrays.asList(responsesElement)).build();
    mockLoggingServiceV2.addResponse(expectedResponse);
    ProjectName parent = ProjectName.of("[PROJECT]");
    ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
    List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockLoggingServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogsRequest actualRequest = ((ListLogsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListLogsResponse(com.google.logging.v2.ListLogsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.logging.v2.ProjectName) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse) Test(org.junit.Test)

Example 4 with ListLogsPagedResponse

use of com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse in project java-logging by googleapis.

the class LoggingClientTest method listLogsTest2.

@Test
public void listLogsTest2() throws Exception {
    String responsesElement = "responsesElement-318365110";
    ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken("").addAllLogNames(Arrays.asList(responsesElement)).build();
    mockLoggingServiceV2.addResponse(expectedResponse);
    FolderName parent = FolderName.of("[FOLDER]");
    ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
    List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockLoggingServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogsRequest actualRequest = ((ListLogsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListLogsResponse(com.google.logging.v2.ListLogsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse) FolderName(com.google.logging.v2.FolderName) Test(org.junit.Test)

Example 5 with ListLogsPagedResponse

use of com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse in project java-logging by googleapis.

the class LoggingClientTest method listLogsTest.

@Test
public void listLogsTest() throws Exception {
    String responsesElement = "responsesElement-318365110";
    ListLogsResponse expectedResponse = ListLogsResponse.newBuilder().setNextPageToken("").addAllLogNames(Arrays.asList(responsesElement)).build();
    mockLoggingServiceV2.addResponse(expectedResponse);
    BillingAccountName parent = BillingAccountName.of("[BILLING_ACCOUNT]");
    ListLogsPagedResponse pagedListResponse = client.listLogs(parent);
    List<String> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getLogNamesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockLoggingServiceV2.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListLogsRequest actualRequest = ((ListLogsRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListLogsResponse(com.google.logging.v2.ListLogsResponse) AbstractMessage(com.google.protobuf.AbstractMessage) BillingAccountName(com.google.logging.v2.BillingAccountName) ListLogsRequest(com.google.logging.v2.ListLogsRequest) ListLogsPagedResponse(com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse) Test(org.junit.Test)

Aggregations

ListLogsPagedResponse (com.google.cloud.logging.v2.LoggingClient.ListLogsPagedResponse)5 ListLogsRequest (com.google.logging.v2.ListLogsRequest)5 ListLogsResponse (com.google.logging.v2.ListLogsResponse)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