use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java 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()));
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class ConfigClientTest method listExclusionsExceptionTest3.
@Test
public void listExclusionsExceptionTest3() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockConfigServiceV2.addException(exception);
try {
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
client.listExclusions(parent);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class ConfigClientTest method createSinkTest3.
@Test
public void createSinkTest3() throws Exception {
LogSink expectedResponse = LogSink.newBuilder().setName(LogSinkName.ofProjectSinkName("[PROJECT]", "[SINK]").toString()).setDestination("destination-1429847026").setFilter("filter-1274492040").setDescription("description-1724546052").setDisabled(true).addAllExclusions(new ArrayList<LogExclusion>()).setWriterIdentity("writerIdentity925193809").setIncludeChildren(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
mockConfigServiceV2.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
LogSink sink = LogSink.newBuilder().build();
LogSink actualResponse = client.createSink(parent, sink);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSinkRequest actualRequest = ((CreateSinkRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(sink, actualRequest.getSink());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java by googleapis.
the class ConfigClientTest method createExclusionTest3.
@Test
public void createExclusionTest3() throws Exception {
LogExclusion expectedResponse = LogExclusion.newBuilder().setName(LogExclusionName.ofProjectExclusionName("[PROJECT]", "[EXCLUSION]").toString()).setDescription("description-1724546052").setFilter("filter-1274492040").setDisabled(true).setCreateTime(Timestamp.newBuilder().build()).setUpdateTime(Timestamp.newBuilder().build()).build();
mockConfigServiceV2.addResponse(expectedResponse);
OrganizationName parent = OrganizationName.of("[ORGANIZATION]");
LogExclusion exclusion = LogExclusion.newBuilder().build();
LogExclusion actualResponse = client.createExclusion(parent, exclusion);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockConfigServiceV2.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateExclusionRequest actualRequest = ((CreateExclusionRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(exclusion, actualRequest.getExclusion());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.monitoring.v3.OrganizationName in project gapic-generator-java 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()));
}
Aggregations