use of com.example.firestore.snippets.model.City in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippets method addSimpleDocumentAsEntity.
/**
* Add a document to a collection as a custom object.
*
* @return entity added
*/
City addSimpleDocumentAsEntity() throws Exception {
// [START fs_add_simple_doc_as_entity]
City city = new City("Los Angeles", "CA", "USA", false, 3900000L);
ApiFuture<WriteResult> future = db.collection("cities").document("LA").set(city);
// block on response if required
System.out.println("Update time : " + future.get().getUpdateTime());
return city;
}
use of com.example.firestore.snippets.model.City in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testAddDataAsEntity.
@Test
public void testAddDataAsEntity() throws Exception {
City city = manageDataSnippets.addSimpleDocumentAsEntity();
DocumentReference docRef = db.collection("cities").document("LA");
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.example.firestore.snippets.model.City in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testUpdateUsingMap.
@Test
public void testUpdateUsingMap() throws Exception {
manageDataSnippets.updateUsingMap();
DocumentReference docRef = db.collection("cities").document("DC");
City city = new City("Washington D.C.");
city.setCapital(true);
city.setCountry("USA");
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.example.firestore.snippets.model.City in project java-docs-samples by GoogleCloudPlatform.
the class ManageDataSnippetsIT method testAddDocAfterAutoGenId.
@Test
public void testAddDocAfterAutoGenId() throws Exception {
String autoId = manageDataSnippets.addDocumentDataAfterAutoGeneratingId();
City city = new City();
DocumentReference docRef = db.collection("cities").document(autoId);
assertTrue(Objects.equals(city, getDocumentDataAsCity(docRef)));
}
use of com.example.firestore.snippets.model.City in project java-docs-samples by GoogleCloudPlatform.
the class RetrieveDataSnippetsIT method testRetrieveAsEntity.
@Test
public void testRetrieveAsEntity() throws Exception {
City city = retrieveDataSnippets.getDocumentAsEntity();
assertEquals(city.getName(), "Beijing");
assertEquals(city.getCountry(), "China");
assertEquals(city.getCapital(), true);
assertEquals((long) city.getPopulation(), 21500000L);
}
Aggregations