Search in sources :

Example 1 with GetFieldRequest

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

the class FirestoreAdminClientTest method getFieldTest.

@Test
public void getFieldTest() throws Exception {
    Field expectedResponse = Field.newBuilder().setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()).setIndexConfig(Field.IndexConfig.newBuilder().build()).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    FieldName name = FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]");
    Field actualResponse = client.getField(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetFieldRequest actualRequest = ((GetFieldRequest) actualRequests.get(0));
    Assert.assertEquals(name.toString(), actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Field(com.google.firestore.admin.v1.Field) AbstractMessage(com.google.protobuf.AbstractMessage) GetFieldRequest(com.google.firestore.admin.v1.GetFieldRequest) FieldName(com.google.firestore.admin.v1.FieldName) Test(org.junit.Test)

Example 2 with GetFieldRequest

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

the class FirestoreAdminClientTest method getFieldTest2.

@Test
public void getFieldTest2() throws Exception {
    Field expectedResponse = Field.newBuilder().setName(FieldName.of("[PROJECT]", "[DATABASE]", "[COLLECTION]", "[FIELD]").toString()).setIndexConfig(Field.IndexConfig.newBuilder().build()).build();
    mockFirestoreAdmin.addResponse(expectedResponse);
    String name = "name3373707";
    Field actualResponse = client.getField(name);
    Assert.assertEquals(expectedResponse, actualResponse);
    List<AbstractMessage> actualRequests = mockFirestoreAdmin.getRequests();
    Assert.assertEquals(1, actualRequests.size());
    GetFieldRequest actualRequest = ((GetFieldRequest) actualRequests.get(0));
    Assert.assertEquals(name, actualRequest.getName());
    Assert.assertTrue(channelProvider.isHeaderSent(ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), GaxGrpcProperties.getDefaultApiClientHeaderPattern()));
}
Also used : Field(com.google.firestore.admin.v1.Field) AbstractMessage(com.google.protobuf.AbstractMessage) GetFieldRequest(com.google.firestore.admin.v1.GetFieldRequest) Test(org.junit.Test)

Aggregations

Field (com.google.firestore.admin.v1.Field)2 GetFieldRequest (com.google.firestore.admin.v1.GetFieldRequest)2 AbstractMessage (com.google.protobuf.AbstractMessage)2 Test (org.junit.Test)2 FieldName (com.google.firestore.admin.v1.FieldName)1