Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dataconnect: some small new APIs and major testing refactor #6424

Merged

Conversation

dconeybe
Copy link
Contributor

@dconeybe dconeybe commented Nov 1, 2024

This PR is a large refactor of the Firebase Data Connect unit and integration tests. This refactor started with the goal of replacing "Truth" (https://github.com/google/truth) with the more Kotlin-idiomatic "kotest" assertion library. Also, many tests were updated to use kotest "property-based testing" (https://kotest.io/docs/proptest/property-based-testing.html) to improve test coverage.

During the test refactor, some advanced public APIs were noticed to absent, and were added as part of this PR. These include:

  • OperationRef, QueryRef, and MutationRef gain methods copy(), withVariablesSerializer(), and withDataDeserializer()
  • GeneratedConnector gains methods copy(), operations(), queries(), and mutations().
  • GeneratedOperation, GeneratedQuery, and GeneratedMutation gain methods copy(), withVariablesSerializer(), and withDataDeserializer()
  • GeneratedConnector, GeneratedOperation, GeneratedQuery, and GeneratedMutation change the semantics of equals() and hashCode() to be based on logical equality rather than referential equality; that is, the property values and runtime type are used to determine equality rather than simply using the === operator.

These changes are breaking and are incompatible with the Firebase Data Connect emulator code generation prior to v1.6.0. Using an older version of the Firebase Data Connect emulator code generation will results in Kotlin compiler errors like this:

FooConnector.kt:23:34 One type argument expected for interface GeneratedConnector<T : GeneratedConnector<T>>
FooConnector.kt:24:3 'dataConnect' overrides nothing
FooConnector.kt:24:3 Visibility must be specified in explicit API mode
FooConnector.kt:879:11 Class 'FooQueryImpl' is not abstract and does not implement abstract member public abstract fun copy(connector: FooConnector = ...,
FooConnector.kt:1059:11 Class 'FooMutationImpl' is not abstract and does not implement abstract member public abstract fun copy(connector: FooConnector = ...,
FooQuery.kt:40:7 Type argument is not within its bounds: should be subtype of 'GeneratedConnector<FooConnector>'
FooMutation.kt:40:7 Type argument is not within its bounds: should be subtype of 'GeneratedConnector<FooConnector>'

If you experience compiler error like these, please either downgrade to Firebase Data Connect emulator code generation prior to version 1.6.0 or upgrade your Firebase Data Connect Android SDK to version 16.0.0-beta03 or later.`

Copy link
Contributor

github-actions bot commented Nov 1, 2024

Release note changes

The following release notes were modified. Please ensure they look correct.

Release Notes
firebase-dataconnect
### {{data_connect_short}} version 16.0.0-beta03 {: #data-connect_v16-0-0-beta03}

* {{changed}} Requires Data Connect emulator version 1.6.1 or later for code generation.

* {{feature}} QueryRef and MutationRef gain methods copy(), withDataDeserializer(),
  and withVariablesSerializer().
  (GitHub [#6424](//github.com/firebase/firebase-android-sdk/issues/6424){: .external})

* {{feature}} GeneratedConnector gains methods copy(), operations(), queries(),
  and mutations().
  (GitHub [#6424](//github.com/firebase/firebase-android-sdk/issues/6424){: .external})

* {{feature}} GeneratedQuery and GeneratedMutation gain methods copy(),
  withVariablesSerializer(), and withDataDeserializer().
  (GitHub [#6424](//github.com/firebase/firebase-android-sdk/issues/6424){: .external})

* {{feature}} GeneratedConnector, GeneratedQuery, and GeneratedMutation now
  must implement equals() to be a _logical_ comparsion, rather than just
  checking for _referencial_ equality using the `===` operator.
  (GitHub [#6424](//github.com/firebase/firebase-android-sdk/issues/6424){: .external})

* {{feature}} FirebaseDataConnectExperimental annotation added, and some
  APIs have been annotated with it, requiring applications that make use of
  these experimental APIs to opt-in using
  `@OptIn(FirebaseDataConnectExperimental::class)` to suppress warnings or
  errors related to using these experimental APIs.
  (GitHub [#6424](//github.com/firebase/firebase-android-sdk/issues/6424){: .external})

Copy link
Contributor

github-actions bot commented Nov 1, 2024

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_responses.sh should be updated to clone the latest version of the responses: v5.1

@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-dataconnect:
error: Added method com.google.firebase.dataconnect.MutationRef.copy(String,Variables,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>,com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType,kotlinx.serialization.modules.SerializersModule,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.MutationRef.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.MutationRef.withVariablesSerializer(NewVariables,kotlinx.serialization.SerializationStrategy<? super NewVariables>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.OperationRef.copy(String,Variables,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>,com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType,kotlinx.serialization.modules.SerializersModule,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.OperationRef.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.OperationRef.withVariablesSerializer(NewVariables,kotlinx.serialization.SerializationStrategy<? super NewVariables>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.QueryRef.copy(String,Variables,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>,com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType,kotlinx.serialization.modules.SerializersModule,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.QueryRef.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.QueryRef.withVariablesSerializer(NewVariables,kotlinx.serialization.SerializationStrategy<? super NewVariables>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.copy(com.google.firebase.dataconnect.FirebaseDataConnect) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.mutations() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.operations() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.queries() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedMutation.copy(Connector,String,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedMutation.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedMutation.withVariablesSerializer(kotlinx.serialization.SerializationStrategy<? super NewVariables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.copy(Connector,String,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.equals(Object) [AddedAbstractMethod]
error: Method com.google.firebase.dataconnect.generated.GeneratedOperation.getConnector has changed return type from Connector (extends com.google.firebase.dataconnect.generated.GeneratedConnector) to Connector (extends com.google.firebase.dataconnect.generated.GeneratedConnector) [ChangedType]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.hashCode() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.withVariablesSerializer(kotlinx.serialization.SerializationStrategy<? super NewVariables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedQuery.copy(Connector,String,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedQuery.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedQuery.withVariablesSerializer(kotlinx.serialization.SerializationStrategy<? super NewVariables>) [AddedAbstractMethod]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

1 similar comment
@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-dataconnect:
error: Added method com.google.firebase.dataconnect.MutationRef.copy(String,Variables,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>,com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType,kotlinx.serialization.modules.SerializersModule,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.MutationRef.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.MutationRef.withVariablesSerializer(NewVariables,kotlinx.serialization.SerializationStrategy<? super NewVariables>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.OperationRef.copy(String,Variables,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>,com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType,kotlinx.serialization.modules.SerializersModule,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.OperationRef.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.OperationRef.withVariablesSerializer(NewVariables,kotlinx.serialization.SerializationStrategy<? super NewVariables>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.QueryRef.copy(String,Variables,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>,com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType,kotlinx.serialization.modules.SerializersModule,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.QueryRef.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.QueryRef.withVariablesSerializer(NewVariables,kotlinx.serialization.SerializationStrategy<? super NewVariables>,kotlinx.serialization.modules.SerializersModule) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.copy(com.google.firebase.dataconnect.FirebaseDataConnect) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.mutations() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.operations() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedConnector.queries() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedMutation.copy(Connector,String,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedMutation.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedMutation.withVariablesSerializer(kotlinx.serialization.SerializationStrategy<? super NewVariables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.copy(Connector,String,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.equals(Object) [AddedAbstractMethod]
error: Method com.google.firebase.dataconnect.generated.GeneratedOperation.getConnector has changed return type from Connector (extends com.google.firebase.dataconnect.generated.GeneratedConnector) to Connector (extends com.google.firebase.dataconnect.generated.GeneratedConnector) [ChangedType]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.hashCode() [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedOperation.withVariablesSerializer(kotlinx.serialization.SerializationStrategy<? super NewVariables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedQuery.copy(Connector,String,kotlinx.serialization.DeserializationStrategy<? extends Data>,kotlinx.serialization.SerializationStrategy<? super Variables>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedQuery.withDataDeserializer(kotlinx.serialization.DeserializationStrategy<? extends NewData>) [AddedAbstractMethod]
error: Added method com.google.firebase.dataconnect.generated.GeneratedQuery.withVariablesSerializer(kotlinx.serialization.SerializationStrategy<? super NewVariables>) [AddedAbstractMethod]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

Copy link
Contributor

github-actions bot commented Nov 1, 2024

Test Results

   54 files  + 34     54 suites  +34   1m 57s ⏱️ + 1m 42s
  515 tests +402    514 ✅ +401  1 💤 +1  0 ❌ ±0 
1 030 runs  +804  1 028 ✅ +802  2 💤 +2  0 ❌ ±0 

Results for commit 49264ac. ± Comparison against base commit b9013d5.

This pull request removes 113 and adds 515 tests. Note that renamed tests count towards both.
com.google.firebase.vertexai.GenerativeModelTesting ‑ exception thrown when using invalid location
com.google.firebase.vertexai.GenerativeModelTesting ‑ system calling in request
com.google.firebase.vertexai.SchemaTests ‑ basic schema declaration
com.google.firebase.vertexai.SchemaTests ‑ full schema declaration
com.google.firebase.vertexai.StreamingSnapshotTests ‑ citation parsed correctly
com.google.firebase.vertexai.StreamingSnapshotTests ‑ empty content
com.google.firebase.vertexai.StreamingSnapshotTests ‑ http errors
com.google.firebase.vertexai.StreamingSnapshotTests ‑ image rejected
com.google.firebase.vertexai.StreamingSnapshotTests ‑ invalid api key
com.google.firebase.vertexai.StreamingSnapshotTests ‑ invalid json
…
com.google.firebase.dataconnect.AnyValueSerializerUnitTest ‑ descriptor should have expected values
com.google.firebase.dataconnect.AnyValueSerializerUnitTest ‑ deserialize() should throw UnsupportedOperationException
com.google.firebase.dataconnect.AnyValueSerializerUnitTest ‑ serialize() should throw UnsupportedOperationException
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(Boolean) creates an object with the expected value
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(Double) creates an object with the expected value (edge cases)
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(Double) creates an object with the expected value (normal cases)
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(List) creates an object with the expected value (edge cases)
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(List) creates an object with the expected value (normal cases)
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(Map) creates an object with the expected value (edge cases)
com.google.firebase.dataconnect.AnyValueUnitTest ‑ constructor(Map) creates an object with the expected value (normal cases)
…

♻️ This comment has been updated with latest results.

@dconeybe dconeybe enabled auto-merge (squash) November 5, 2024 20:42
@google-oss-bot
Copy link
Contributor

The public api surface has changed for the subproject firebase-dataconnect:
error: Added class com.google.firebase.dataconnect.FirebaseDataConnectExperimental [AddedClass]

Please update the api.txt files for the subprojects being affected by this change by running ./gradlew ${subproject}:generateApiTxtFile. Also perform a major/minor bump accordingly.

@dconeybe dconeybe merged commit 312d14a into main Nov 5, 2024
35 of 36 checks passed
@dconeybe dconeybe deleted the dconeybe/dataconnect/TestModernizationAndSomeNewFeatures branch November 5, 2024 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants