Search in sources :

Example 66 with Schema

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()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) ByteString(com.google.protobuf.ByteString) Test(org.junit.Test)

Example 67 with Schema

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()));
}
Also used : ListSchemasRequest(com.google.pubsub.v1.ListSchemasRequest) ListSchemasPagedResponse(com.google.cloud.pubsub.v1.SchemaServiceClient.ListSchemasPagedResponse) AbstractMessage(com.google.protobuf.AbstractMessage) ProjectName(com.google.pubsub.v1.ProjectName) Schema(com.google.pubsub.v1.Schema) ListSchemasResponse(com.google.pubsub.v1.ListSchemasResponse) Test(org.junit.Test)

Example 68 with Schema

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()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) Schema(com.google.pubsub.v1.Schema) GetSchemaRequest(com.google.pubsub.v1.GetSchemaRequest) SchemaName(com.google.pubsub.v1.SchemaName) Test(org.junit.Test)

Example 69 with Schema

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.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) SchemaName(com.google.pubsub.v1.SchemaName) Test(org.junit.Test)

Example 70 with Schema

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.
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) SchemaName(com.google.pubsub.v1.SchemaName) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)65 Schema (com.google.pubsub.v1.Schema)38 Schema (org.molgenis.emx2.Schema)38 ByteString (com.google.protobuf.ByteString)19 SchemaServiceClient (com.google.cloud.pubsub.v1.SchemaServiceClient)18 AbstractMessage (com.google.protobuf.AbstractMessage)18 QName (javax.xml.namespace.QName)16 SchemaName (com.google.pubsub.v1.SchemaName)15 File (java.io.File)15 Schema (org.geosdi.geoplatform.xml.xsd.v2001.Schema)15 ProjectName (com.google.pubsub.v1.ProjectName)14 IOException (java.io.IOException)14 URL (java.net.URL)14 LayerSchemaDTO (org.geosdi.geoplatform.connector.wfs.response.LayerSchemaDTO)14 StringWriter (java.io.StringWriter)13 Schema (org.oasisopen.odata.csdl.v4.Schema)13 InvalidArgumentException (com.google.api.gax.rpc.InvalidArgumentException)12 StatusRuntimeException (io.grpc.StatusRuntimeException)12 Schema (com.reprezen.kaizen.oasparser.model3.Schema)11 JAXBElement (javax.xml.bind.JAXBElement)10