======================== CODE SNIPPETS ======================== TITLE: FCM Invalid Registration Token Error Response (HTTP 400 Bad Request - Concise) DESCRIPTION: This snippet presents a more concise variation of the `INVALID_ARGUMENT` error response for an invalid Firebase Cloud Messaging (FCM) registration token. Similar to the previous example, it includes the `code`, `status`, `errorCode`, and `fieldViolations`, but omits the top-level `message` field within the `error` object, relying on `fieldViolations` for the specific error description. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/src/test/resources/fcm_batch_failure.txt#_snippet_2 LANGUAGE: JSON CODE: ``` { "error": { "code": 400, "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError", "errorCode": "INVALID_ARGUMENT" }, { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "message.token", "description": "The registration token is not a valid FCM registration token" } ] } ] } } ``` ---------------------------------------- TITLE: Successful FCM Message Send Response (HTTP 200 OK) DESCRIPTION: This snippet shows the expected JSON response for a successful Firebase Cloud Messaging (FCM) message send operation. The response includes the `name` of the sent message, which can be used for tracking or further operations within the Firebase ecosystem. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/src/test/resources/fcm_batch_failure.txt#_snippet_0 LANGUAGE: JSON CODE: ``` { "name": "projects/test-project/messages/1" } ``` ---------------------------------------- TITLE: FCM Invalid Registration Token Error Response (HTTP 400 Bad Request - Detailed) DESCRIPTION: This snippet illustrates a detailed error response when an invalid Firebase Cloud Messaging (FCM) registration token is provided. The `error` object contains a `code` of 400, `status` as `INVALID_ARGUMENT`, and a top-level `message` explaining the issue. The `details` array provides more specific information, including the `errorCode` and `fieldViolations` pointing to the problematic field. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/src/test/resources/fcm_batch_failure.txt#_snippet_1 LANGUAGE: JSON CODE: ``` { "error": { "code": 400, "message": "The registration token is not a valid FCM registration token", "status": "INVALID_ARGUMENT", "details": [ { "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError", "errorCode": "INVALID_ARGUMENT" }, { "@type": "type.googleapis.com/google.rpc.BadRequest", "fieldViolations": [ { "field": "message.token", "description": "The registration token is not a valid FCM registration token" } ] } ] } } ``` ---------------------------------------- TITLE: Generate Full API Documentation for All Packages DESCRIPTION: This command utilizes the Maven Javadoc plugin to generate complete API documentation for all packages present in the codebase. The generated documentation will be stored in the `target/site/apidocs` directory. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/CONTRIBUTING.md#_snippet_4 LANGUAGE: Shell CODE: ``` mvn javadoc:javadoc ``` ---------------------------------------- TITLE: Generate Public API Documentation Using Devsite Profile and Doclava DESCRIPTION: This command triggers the `devsite-apidocs` Maven profile, which employs the Maven Javadoc plugin in conjunction with Doclava. Doclava honors `@hide` tags in the source code, ensuring that only public APIs are documented. It also allows specifying a directory for Clearsilver templates. The output documentation will be placed in the `target/apidocs` directory. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/CONTRIBUTING.md#_snippet_5 LANGUAGE: Shell CODE: ``` mvn site -Ddevsite.template=path/to/templates/directory/ ``` ---------------------------------------- TITLE: Execute Maven Unit Tests DESCRIPTION: This command runs all unit tests configured for the project using Maven's `test` goal. It's useful for quickly verifying test results without triggering a full build, especially when tests are housed in the `src/test` directory and are based on frameworks like Junit4. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/CONTRIBUTING.md#_snippet_1 LANGUAGE: Shell CODE: ``` mvn test ``` ---------------------------------------- TITLE: Configure Firebase Project for Integration Tests DESCRIPTION: Detailed steps to configure a Firebase project and Google Cloud services for `firebase-admin-java` integration tests. This includes enabling Authentication, Firestore, Realtime Database, Storage, IAM API, Tenant Management, and assigning the Firebase Authentication Admin role to the service account. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/CONTRIBUTING.md#_snippet_2 LANGUAGE: APIDOC CODE: ``` Firebase Project Setup: 1. Obtain Credentials: - Service Account Certificate: Download JSON from Settings > Service Accounts. Save as `integration_cert.json`. - Web API Key: Found in Settings > General after enabling Auth. Save as `integration_apikey.txt`. 2. Enable Authentication: - Console Path: Build > Authentication > Get Started. - Sign-in Methods: Add Email/Password, enable Email/Password and Email link. 3. Enable Firestore: - Console Path: Build > Firestore Database > Create database. - Mode: Production or Test mode. 4. Enable Realtime Database: - Console Path: Build > Realtime Database > Create Database. - Mode: Locked or Test mode. - Create Second Reference: Data tab > kebab menu > Create Database. Use Project ID as reference. 5. Enable Storage: - Console Path: Build > Storage > Get started. - Mode: Production or Test mode. 6. Enable IAM API (Google Cloud Console): - Console Path: Google Cloud console > APIs & Services > ENABLE APIS AND SERVICES. - Search & Enable: Identity and Access Management (IAM) API. 7. Enable Tenant Management (Google Cloud Console): - Console Path: Google Cloud console | Identity Platform. - Action: Enable if not already, then enable multi-tenancy. 8. Assign Firebase Authentication Admin Role: - Console Path: Google Cloud console | IAM & admin. - Action: Find service account, Edit permissions, ADD ANOTHER ROLE, choose Firebase Authentication Admin, SAVE. ``` ---------------------------------------- TITLE: Run Maven Checkstyle Linter DESCRIPTION: This command executes the Maven Checkstyle plugin to validate source code format and enforce Java programming best practices. It allows developers to check for style violations without running the entire build pipeline, ensuring code quality and consistency. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/CONTRIBUTING.md#_snippet_0 LANGUAGE: Maven CODE: ``` mvn validate ``` ---------------------------------------- TITLE: Execute Firebase Admin Java Integration Tests with Maven DESCRIPTION: These Maven commands invoke the integration test suite for the Firebase Admin Java project. The first command runs both unit and integration tests, while the second specifically executes only integration tests by skipping unit tests. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/CONTRIBUTING.md#_snippet_3 LANGUAGE: Maven CODE: ``` mvn verify ``` LANGUAGE: Maven CODE: ``` mvn verify -DskipUTs ``` ---------------------------------------- TITLE: Configure Firebase Admin Java SDK Dependency DESCRIPTION: Instructions for adding the Firebase Admin Java SDK as a dependency in a Java project's build configuration. This snippet provides the Group ID and Artifact ID necessary for build tools like Maven or Gradle to pull the SDK into your project, enabling access to Firebase services from server-side applications. SOURCE: https://github.com/firebase/firebase-admin-java/blob/master/README.md#_snippet_0 LANGUAGE: XML CODE: ``` com.google.firebase firebase-admin X.Y.Z ```