use of com.google.containeranalysis.v1beta1.ProjectName in project java-pubsub by googleapis.
the class SchemaServiceClientTest method listSchemasTest.
@Test
public void listSchemasTest() throws Exception {
Schema responsesElement = Schema.newBuilder().build();
ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
mockSchemaService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
ListSchemasPagedResponse pagedListResponse = client.listSchemas(parent);
List<Schema> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSchemasList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSchemasRequest actualRequest = ((ListSchemasRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.containeranalysis.v1beta1.ProjectName in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsExceptionTest.
@Test
public void listSnapshotsExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSubscriber.addException(exception);
try {
ProjectName project = ProjectName.of("[PROJECT]");
client.listSnapshots(project);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.containeranalysis.v1beta1.ProjectName in project java-pubsub by googleapis.
the class SchemaServiceClientTest method createSchemaTest.
@Test
public void createSchemaTest() throws Exception {
Schema expectedResponse = Schema.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setDefinition("definition-1014418093").build();
mockSchemaService.addResponse(expectedResponse);
ProjectName parent = ProjectName.of("[PROJECT]");
Schema schema = Schema.newBuilder().build();
String schemaId = "schemaId-697673060";
Schema actualResponse = client.createSchema(parent, schema, schemaId);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
CreateSchemaRequest actualRequest = ((CreateSchemaRequest) actualRequests.get(0));
Assert.assertEquals(parent.toString(), actualRequest.getParent());
Assert.assertEquals(schema, actualRequest.getSchema());
Assert.assertEquals(schemaId, actualRequest.getSchemaId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.containeranalysis.v1beta1.ProjectName in project java-pubsub by googleapis.
the class NativeImagePubSubSample method listTopics.
static void listTopics(String projectId) throws IOException {
try (TopicAdminClient topicAdminClient = TopicAdminClient.create()) {
ProjectName projectName = ProjectName.of(projectId);
int count = 0;
for (Topic topic : topicAdminClient.listTopics(projectName).iterateAll()) {
count += 1;
}
System.out.println("Topic count under project: " + count);
}
}
use of com.google.containeranalysis.v1beta1.ProjectName in project java-pubsub by googleapis.
the class SubscriptionAdminClientTest method listSnapshotsTest.
@Test
public void listSnapshotsTest() throws Exception {
Snapshot responsesElement = Snapshot.newBuilder().build();
ListSnapshotsResponse expectedResponse = ListSnapshotsResponse.newBuilder().setNextPageToken("").addAllSnapshots(Arrays.asList(responsesElement)).build();
mockSubscriber.addResponse(expectedResponse);
ProjectName project = ProjectName.of("[PROJECT]");
ListSnapshotsPagedResponse pagedListResponse = client.listSnapshots(project);
List<Snapshot> resources = Lists.newArrayList(pagedListResponse.iterateAll());
Assert.assertEquals(1, resources.size());
Assert.assertEquals(expectedResponse.getSnapshotsList().get(0), resources.get(0));
List<AbstractMessage> actualRequests = mockSubscriber.getRequests();
Assert.assertEquals(1, actualRequests.size());
ListSnapshotsRequest actualRequest = ((ListSnapshotsRequest) actualRequests.get(0));
Assert.assertEquals(project.toString(), actualRequest.getProject());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Aggregations