use of com.google.firestore.admin.v1.GetIndexRequest in project java-datastore by googleapis.
the class DatastoreAdminClientTest method getIndexExceptionTest.
@Test
public void getIndexExceptionTest() throws Exception {
StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT);
mockDatastoreAdmin.addException(exception);
try {
GetIndexRequest request = GetIndexRequest.newBuilder().setProjectId("projectId-894832108").setIndexId("indexId1943291277").build();
client.getIndex(request);
Assert.fail("No exception raised");
} catch (InvalidArgumentException e) {
// Expected exception.
}
}
use of com.google.firestore.admin.v1.GetIndexRequest in project java-datastore by googleapis.
the class DatastoreAdminClientTest method getIndexTest.
@Test
public void getIndexTest() throws Exception {
Index expectedResponse = Index.newBuilder().setProjectId("projectId-894832108").setIndexId("indexId1943291277").setKind("kind3292052").addAllProperties(new ArrayList<Index.IndexedProperty>()).build();
mockDatastoreAdmin.addResponse(expectedResponse);
GetIndexRequest request = GetIndexRequest.newBuilder().setProjectId("projectId-894832108").setIndexId("indexId1943291277").build();
Index actualResponse = client.getIndex(request);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockDatastoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId());
Assert.assertEquals(request.getIndexId(), actualRequest.getIndexId());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.GetIndexRequest in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getIndexTest2.
@Test
public void getIndexTest2() throws Exception {
Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
mockFirestoreAdmin.addResponse(expectedResponse);
String name = "name3373707";
Index actualResponse = client.getIndex(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
Assert.assertEquals(name, actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.GetIndexRequest in project java-firestore by googleapis.
the class FirestoreAdminClientTest method getIndexTest.
@Test
public void getIndexTest() throws Exception {
Index expectedResponse = Index.newBuilder().setName(IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]").toString()).addAllFields(new ArrayList<Index.IndexField>()).build();
mockFirestoreAdmin.addResponse(expectedResponse);
IndexName name = IndexName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[INDEX]");
Index actualResponse = client.getIndex(name);
Assert.assertEquals(expectedResponse, actualResponse);
List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
Assert.assertEquals(1, actualRequests.size());
GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0));
Assert.assertEquals(name.toString(), actualRequest.getName());
Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
use of com.google.firestore.admin.v1.GetIndexRequest in project grpc-gcp-java by GoogleCloudPlatform.
the class GetIndex method getIndexCall.
public void getIndexCall() {
System.out.println("\n :: Getting an Index :: \n");
FirestoreAdminBlockingStub blockingStub = new GRPCFirebaseAdminClientFactory().createFirebaseAdminClient().getBlockingStub();
Scanner sc = new Scanner(System.in);
System.out.print("Enter Index Name: ");
String indexName = "projects/firestoretestclient/databases/(default)/indexes/" + sc.next();
GetIndexRequest getIndexRequest = GetIndexRequest.newBuilder().setName(indexName).build();
Index index;
try {
index = blockingStub.getIndex(getIndexRequest);
} catch (Exception e) {
System.out.println("Error during call: " + e.getMessage() + e.getCause());
return;
}
DrawIndex di = new DrawIndex();
di.drawIndex(index);
Menu menu = new Menu();
menu.draw();
}
Aggregations