A console-based Java 21 application that performs basic CRUD operations on documents stored in Google Firestore using Firebase Admin SDK. The project includesa full test suite to ensure maintainability and reliability.
- DatabaseConnector (interface): Defines a generic contract for database operations.
- FirebaseConnector (class): Handles the initialization of the Firebase App using a service account JSON key.
- FirestoreCRUD (class): Contains static methods for:
getRecord– retrieve a documentsetRecord– create or overwrite a documentupdateRecord– partially update a documentdeleteRecord– delete a document
- Main (class): Provides a CLI-based menu for user interaction.
- Java 21
- Maven
- Firebase Account with Firestore enabled
- Firebase service account JSON key
- Place your Firebase service account key in the resources directory to database_key.json file.
- Build the project using Maven:
mvn clean packageRun the application from the terminal:
java -jar target/FireBaseCRUD.jarThe CLI provides the following options:
- Create a new document
- Show a document by ID
- Delete a document by ID
- Update a document by ID
- Exit the program
Each operation requires a collection name and document ID. Create/Update operations also require the following fields: make, model, color, rims.
The project includes a comprehensive test suite to validate application logic and integration.
Used for unit and integration testing.
Used to mock Firestore operations, allowing isolated testing without connecting to the real database.
Enables behavior-driven development by writing feature files that describe expected functionality in plain English.
Tests can be run using:
mvn testThis project is licensed under the MIT License.