use of com.google.pubsub.v1.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method listSchemasTest2.
@Test
public void listSchemasTest2() throws Exception {
Schema responsesElement = Schema.newBuilder().build();
ListSchemasResponse expectedResponse = ListSchemasResponse.newBuilder().setNextPageToken("").addAllSchemas(Arrays.asList(responsesElement)).build();
mockSchemaService.addResponse(expectedResponse);
String parent = "parent-995424086";
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, actualRequest.getParent());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.pubsub.v1.Schema 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.pubsub.v1.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method getSchemaTest.
@Test
public void getSchemaTest() throws Exception {
Schema expectedResponse = Schema.newBuilder().setName(SchemaName.of("[PROJECT]", "[SCHEMA]").toString()).setDefinition("definition-1014418093").build();
mockSchemaService.addResponse(expectedResponse);
SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]");
Schema actualResponse = client.getSchema(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockSchemaService.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetSchemaRequest actualRequest = ((GetSchemaRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.pubsub.v1.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method deleteSchemaExceptionTest.
@Test
public void deleteSchemaExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSchemaService.addException(exception);
try {
SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]");
client.deleteSchema(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.pubsub.v1.Schema in project java-pubsub by googleapis.
the class SchemaServiceClientTest method getSchemaExceptionTest.
@Test
public void getSchemaExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockSchemaService.addException(exception);
try {
SchemaName name = SchemaName.of("[PROJECT]", "[SCHEMA]");
client.getSchema(name);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
Aggregations