Search in sources :

Example 6 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method createIndexTest2.

@Test
public void createIndexTest2() throws Exception {
    Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
    Operation resultOperation = Operation.newBuilder().setName("createIndexTest").setDone(true).setResponse(Any.pack(expectedResponse)).build();
    mockFirestoreAdmin.addResponse(resultOperation);
    String parent = "parent-995424086";
    Index index = Index.newBuilder().build();
    Index actualResponse = client.createIndexAsync(parent, index).get();
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertEquals(index, actualRequest.getIndex());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : AbstractMessage(com.google.protobuf.AbstractMessage) ArrayList(java.util.ArrayList) Index(com.google.firestore.admin.v1.Index) Operation(com.google.longrunning.Operation) CreateIndexRequest(com.google.firestore.admin.v1.CreateIndexRequest) Test(org.junit.Test)

Example 7 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method createIndexExceptionTest2.

@Test
public void createIndexExceptionTest2() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockFirestoreAdmin.addException(exception);
    try {
        String parent = "parent-995424086";
        Index index = Index.newBuilder().build();
        client.createIndexAsync(parent, index).get();
        Assert.fail("No exception raised");
    } catch (ExecutionException e) {
        Assert.assertEquals(InvalidArgumentException.class, e.getCause().getClass());
        InvalidArgumentException apiException = ((InvalidArgumentException) e.getCause());
        Assert.assertEquals(StatusCode.Code.INVALID_ARGUMENT, apiException.getStatusCode().getCode());
    }
}
Also used : InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Index(com.google.firestore.admin.v1.Index) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test)

Example 8 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method getIndexExceptionTest.

@Test
public void getIndexExceptionTest() throws Exception {
    StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
    mockFirestoreAdmin.addException(exception);
    try {
        IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
        client.getIndex(name);
        Assert.fail("No exception raised");
    } catch (InvalidArgumentException e) {
    // Expected exception.
    }
}
Also used : IndexName(com.google.firestore.admin.v1.IndexName) InvalidArgumentException(com.google.api.gax.rpc.InvalidArgumentException) StatusRuntimeException(io.grpc.StatusRuntimeException) Test(org.junit.Test)

Example 9 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest.

@Test
public void listIndexesTest() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    CollectionGroupName parent = CollectionGroupName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]");
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent.toString(), actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) CollectionGroupName(com.google.firestore.admin.v1.CollectionGroupName) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Example 10 with Index

use of com.google.firestore.admin.v1.Index in project java-firestore by googleapis.

the class FirestoreAdminClientTest method listIndexesTest2.

@Test
public void listIndexesTest2() throws Exception {
    Index responsesElement = Index.newBuilder().build();
    ListIndexesResponse expectedResponse = ListIndexesResponse.newBuilder().setNextPageToken("").addAllIndexes(Arrays.asList(responsesElement)).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    String parent = "parent-995424086";
    ListIndexesPagedResponse pagedListResponse = client.listIndexes(parent);
    List<Index> resources = Lists.newArrayList(pagedListResponse.iterateAll());
    Assert.assertEquals(1, resources.size());
    Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0));
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0));
    Assert.assertEquals(parent, actualRequest.getParent());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : ListIndexesResponse(com.google.firestore.admin.v1.ListIndexesResponse) AbstractMessage(com.google.protobuf.AbstractMessage) Index(com.google.firestore.admin.v1.Index) ListIndexesRequest(com.google.firestore.admin.v1.ListIndexesRequest) ListIndexesPagedResponse(com.google.cloud.firestore.v1.FirestoreAdminClient.ListIndexesPagedResponse) Test(org.junit.Test)

Aggregations

Index (ucar.ma2.Index)30 Array (ucar.ma2.Array)20 ArrayList (java.util.ArrayList)17 Test (org.junit.Test)15 AbstractMessage (com.google.protobuf.AbstractMessage)11 Attribute (ucar.nc2.Attribute)11 WritableRaster (java.awt.image.WritableRaster)10 IOException (java.io.IOException)10 ArrayFloat (ucar.ma2.ArrayFloat)10 Index (com.google.firestore.admin.v1.Index)9 Dimension (ucar.nc2.Dimension)9 NetcdfFileWriteable (ucar.nc2.NetcdfFileWriteable)8 Variable (ucar.nc2.Variable)8 ArrayDouble (ucar.ma2.ArrayDouble)7 NetcdfFile (ucar.nc2.NetcdfFile)7 SampleModel (java.awt.image.SampleModel)5 Index (com.google.datastore.admin.v1.Index)4 IndexName (com.google.firestore.admin.v1.IndexName)4 Operation (com.google.longrunning.Operation)4 File (java.io.File)4