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
Merged
21 changes: 20 additions & 1 deletion firebase-dataconnect/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Unreleased

* [changed] Requires Data Connect emulator version 1.6.1 or later for code generation.
* [feature] QueryRef and MutationRef gain methods copy(), withDataDeserializer(),
and withVariablesSerializer().
([#6424](https://github.com/firebase/firebase-android-sdk/pull/6424))
* [feature] GeneratedConnector gains methods copy(), operations(), queries(),
and mutations().
([#6424](https://github.com/firebase/firebase-android-sdk/pull/6424))
* [feature] GeneratedQuery and GeneratedMutation gain methods copy(),
withVariablesSerializer(), and withDataDeserializer().
([#6424](https://github.com/firebase/firebase-android-sdk/pull/6424))
* [feature] GeneratedConnector, GeneratedQuery, and GeneratedMutation now
must implement equals() to be a _logical_ comparsion, rather than just
checking for _referencial_ equality using the `===` operator.
([#6424](https://github.com/firebase/firebase-android-sdk/pull/6424))
* [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.
([#6424](https://github.com/firebase/firebase-android-sdk/pull/6424))

# 16.0.0-beta02
* [changed] Updated protobuf dependency to `3.25.5` to fix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@ package com.google.firebase.dataconnect.testutil

import androidx.test.ext.junit.runners.AndroidJUnit4
import com.google.firebase.dataconnect.ConnectorConfig
import com.google.firebase.util.nextAlphanumericString
import io.kotest.property.Arb
import io.kotest.property.RandomSource
import io.kotest.property.arbitrary.Codepoint
import io.kotest.property.arbitrary.alphanumeric
import io.kotest.property.arbitrary.arbitrary
import io.kotest.property.arbitrary.string
import kotlin.random.Random
import org.junit.Rule
import org.junit.rules.TestName
import org.junit.runner.RunWith
Expand Down Expand Up @@ -84,28 +82,3 @@ abstract class DataConnectIntegrationTestBase {
/** The name of the currently-running test, in the form "ClassName.MethodName". */
val DataConnectIntegrationTestBase.testName
get() = this::class.qualifiedName + "." + testNameRule.methodName

/**
* Generates and returns a string containing random alphanumeric characters, including the name of
* the currently-running test as returned from [testName].
*
* @param prefix A prefix to include in the returned string; if null (the default) then no prefix
* will be included.
* @param numRandomChars The number of random characters to include in the returned string; if null
* (the default) then a default number will be used. At the time of writing, the default number of
* characters is 20 (but this may change in the future).
* @return a string containing random characters and incorporating the other information identified
* above.
*/
fun DataConnectIntegrationTestBase.randomAlphanumericString(
prefix: String? = null,
numRandomChars: Int? = null
): String = buildString {
if (prefix != null) {
append(prefix)
append("_")
}
append(testName)
append("_")
append(Random.nextAlphanumericString(length = numRandomChars ?: 20))
}
35 changes: 31 additions & 4 deletions firebase-dataconnect/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ package com.google.firebase.dataconnect {
property @Nullable public abstract kotlinx.serialization.modules.SerializersModule variablesSerializersModule;
}

@kotlin.RequiresOptIn(level=kotlin.RequiresOptIn.Level.WARNING, message="This declaration is \"experimental\": its signature and/or semantics " + "may change in backwards-incompatible ways at any time without notice, " + "up to and including complete removal. " + "If you have a use case that relies on this declaration please open a " + "\"feature request\" issue at https://github.com/firebase/firebase-android-sdk " + "requesting this declaration\'s promotion from \"experimental\" to \"fully-supported\".") @kotlin.annotation.MustBeDocumented @kotlin.annotation.Retention(kotlin.annotation.AnnotationRetention.BINARY) public @interface FirebaseDataConnectExperimental {
}

public final class FirebaseDataConnectKt {
method @NonNull public static com.google.firebase.dataconnect.FirebaseDataConnect getInstance(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion, @NonNull com.google.firebase.FirebaseApp app, @NonNull com.google.firebase.dataconnect.ConnectorConfig config, @NonNull com.google.firebase.dataconnect.DataConnectSettings settings = com.google.firebase.dataconnect.DataConnectSettings());
method @NonNull public static com.google.firebase.dataconnect.FirebaseDataConnect getInstance(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect.Companion, @NonNull com.google.firebase.dataconnect.ConnectorConfig config, @NonNull com.google.firebase.dataconnect.DataConnectSettings settings = com.google.firebase.dataconnect.DataConnectSettings());
Expand All @@ -122,7 +125,10 @@ package com.google.firebase.dataconnect {
}

public interface MutationRef<Data, Variables> extends com.google.firebase.dataconnect.OperationRef<Data,Variables> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public com.google.firebase.dataconnect.MutationRef<Data,Variables> copy(@NonNull String operationName, @Nullable Variables variables, @NonNull kotlinx.serialization.DeserializationStrategy<? extends Data> dataDeserializer, @NonNull kotlinx.serialization.SerializationStrategy<? super Variables> variablesSerializer, @NonNull com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType callerSdkType, @Nullable kotlinx.serialization.modules.SerializersModule dataSerializersModule, @Nullable kotlinx.serialization.modules.SerializersModule variablesSerializersModule);
method @Nullable public suspend Object execute(@NonNull kotlin.coroutines.Continuation<? super com.google.firebase.dataconnect.MutationResult<Data,Variables>>);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewData> com.google.firebase.dataconnect.MutationRef<NewData,Variables> withDataDeserializer(@NonNull kotlinx.serialization.DeserializationStrategy<? extends NewData> dataDeserializer, @Nullable kotlinx.serialization.modules.SerializersModule dataSerializersModule);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewVariables> com.google.firebase.dataconnect.MutationRef<Data,NewVariables> withVariablesSerializer(@Nullable NewVariables variables, @NonNull kotlinx.serialization.SerializationStrategy<? super NewVariables> variablesSerializer, @Nullable kotlinx.serialization.modules.SerializersModule variablesSerializersModule);
}

public interface MutationResult<Data, Variables> extends com.google.firebase.dataconnect.OperationResult<Data,Variables> {
Expand All @@ -131,6 +137,7 @@ package com.google.firebase.dataconnect {
}

public interface OperationRef<Data, Variables> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public com.google.firebase.dataconnect.OperationRef<Data,Variables> copy(@NonNull String operationName = this.operationName, @Nullable Variables variables = this.variables, @NonNull kotlinx.serialization.DeserializationStrategy<? extends Data> dataDeserializer = this.dataDeserializer, @NonNull kotlinx.serialization.SerializationStrategy<? super Variables> variablesSerializer = this.variablesSerializer, @NonNull com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType callerSdkType = this.callerSdkType, @Nullable kotlinx.serialization.modules.SerializersModule dataSerializersModule = this.dataSerializersModule, @Nullable kotlinx.serialization.modules.SerializersModule variablesSerializersModule = this.variablesSerializersModule);
method public boolean equals(@Nullable Object other);
method @Nullable public suspend Object execute(@NonNull kotlin.coroutines.Continuation<? super com.google.firebase.dataconnect.OperationResult<Data,Variables>>);
method @NonNull public com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType getCallerSdkType();
Expand All @@ -143,6 +150,8 @@ package com.google.firebase.dataconnect {
method @Nullable public kotlinx.serialization.modules.SerializersModule getVariablesSerializersModule();
method public int hashCode();
method @NonNull public String toString();
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewData> com.google.firebase.dataconnect.OperationRef<NewData,Variables> withDataDeserializer(@NonNull kotlinx.serialization.DeserializationStrategy<? extends NewData> dataDeserializer, @Nullable kotlinx.serialization.modules.SerializersModule dataSerializersModule = this.dataSerializersModule);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewVariables> com.google.firebase.dataconnect.OperationRef<Data,NewVariables> withVariablesSerializer(@Nullable NewVariables variables, @NonNull kotlinx.serialization.SerializationStrategy<? super NewVariables> variablesSerializer, @Nullable kotlinx.serialization.modules.SerializersModule variablesSerializersModule = this.variablesSerializersModule);
property @NonNull public abstract com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType callerSdkType;
property @NonNull public abstract com.google.firebase.dataconnect.FirebaseDataConnect dataConnect;
property @NonNull public abstract kotlinx.serialization.DeserializationStrategy<Data> dataDeserializer;
Expand Down Expand Up @@ -191,8 +200,11 @@ package com.google.firebase.dataconnect {
}

public interface QueryRef<Data, Variables> extends com.google.firebase.dataconnect.OperationRef<Data,Variables> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public com.google.firebase.dataconnect.QueryRef<Data,Variables> copy(@NonNull String operationName, @Nullable Variables variables, @NonNull kotlinx.serialization.DeserializationStrategy<? extends Data> dataDeserializer, @NonNull kotlinx.serialization.SerializationStrategy<? super Variables> variablesSerializer, @NonNull com.google.firebase.dataconnect.FirebaseDataConnect.CallerSdkType callerSdkType, @Nullable kotlinx.serialization.modules.SerializersModule dataSerializersModule, @Nullable kotlinx.serialization.modules.SerializersModule variablesSerializersModule);
method @Nullable public suspend Object execute(@NonNull kotlin.coroutines.Continuation<? super com.google.firebase.dataconnect.QueryResult<Data,Variables>>);
method @NonNull public com.google.firebase.dataconnect.QuerySubscription<Data,Variables> subscribe();
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewData> com.google.firebase.dataconnect.QueryRef<NewData,Variables> withDataDeserializer(@NonNull kotlinx.serialization.DeserializationStrategy<? extends NewData> dataDeserializer, @Nullable kotlinx.serialization.modules.SerializersModule dataSerializersModule);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewVariables> com.google.firebase.dataconnect.QueryRef<Data,NewVariables> withVariablesSerializer(@Nullable NewVariables variables, @NonNull kotlinx.serialization.SerializationStrategy<? super NewVariables> variablesSerializer, @Nullable kotlinx.serialization.modules.SerializersModule variablesSerializersModule);
}

public interface QueryResult<Data, Variables> extends com.google.firebase.dataconnect.OperationResult<Data,Variables> {
Expand Down Expand Up @@ -224,33 +236,48 @@ package com.google.firebase.dataconnect {

package com.google.firebase.dataconnect.generated {

public interface GeneratedConnector {
public interface GeneratedConnector<T extends com.google.firebase.dataconnect.generated.GeneratedConnector<T>> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public T copy(@NonNull com.google.firebase.dataconnect.FirebaseDataConnect dataConnect = this.dataConnect);
method public boolean equals(@Nullable Object other);
method @NonNull public com.google.firebase.dataconnect.FirebaseDataConnect getDataConnect();
method public int hashCode();
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public java.util.List<com.google.firebase.dataconnect.generated.GeneratedMutation<T,?,?>> mutations();
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public java.util.List<com.google.firebase.dataconnect.generated.GeneratedOperation<T,?,?>> operations();
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public java.util.List<com.google.firebase.dataconnect.generated.GeneratedQuery<T,?,?>> queries();
method @NonNull public String toString();
property @NonNull public abstract com.google.firebase.dataconnect.FirebaseDataConnect dataConnect;
}

public interface GeneratedMutation<C extends com.google.firebase.dataconnect.generated.GeneratedConnector, Data, Variables> extends com.google.firebase.dataconnect.generated.GeneratedOperation<C,Data,Variables> {
public interface GeneratedMutation<Connector extends com.google.firebase.dataconnect.generated.GeneratedConnector<Connector>, Data, Variables> extends com.google.firebase.dataconnect.generated.GeneratedOperation<Connector,Data,Variables> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public com.google.firebase.dataconnect.generated.GeneratedMutation<Connector,Data,Variables> copy(@NonNull Connector connector, @NonNull String operationName, @NonNull kotlinx.serialization.DeserializationStrategy<? extends Data> dataDeserializer, @NonNull kotlinx.serialization.SerializationStrategy<? super Variables> variablesSerializer);
method @NonNull public default com.google.firebase.dataconnect.MutationRef<Data,Variables> ref(@Nullable Variables variables);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewData> com.google.firebase.dataconnect.generated.GeneratedMutation<Connector,NewData,Variables> withDataDeserializer(@NonNull kotlinx.serialization.DeserializationStrategy<? extends NewData> dataDeserializer);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewVariables> com.google.firebase.dataconnect.generated.GeneratedMutation<Connector,Data,NewVariables> withVariablesSerializer(@NonNull kotlinx.serialization.SerializationStrategy<? super NewVariables> variablesSerializer);
}

public interface GeneratedOperation<Connector extends com.google.firebase.dataconnect.generated.GeneratedConnector, Data, Variables> {
public interface GeneratedOperation<Connector extends com.google.firebase.dataconnect.generated.GeneratedConnector<Connector>, Data, Variables> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public com.google.firebase.dataconnect.generated.GeneratedOperation<Connector,Data,Variables> copy(@NonNull Connector connector = this.connector, @NonNull String operationName = this.operationName, @NonNull kotlinx.serialization.DeserializationStrategy<? extends Data> dataDeserializer = this.dataDeserializer, @NonNull kotlinx.serialization.SerializationStrategy<? super Variables> variablesSerializer = this.variablesSerializer);
method public boolean equals(@Nullable Object other);
method @NonNull public Connector getConnector();
method @NonNull public kotlinx.serialization.DeserializationStrategy<Data> getDataDeserializer();
method @NonNull public String getOperationName();
method @NonNull public kotlinx.serialization.SerializationStrategy<Variables> getVariablesSerializer();
method public int hashCode();
method @NonNull public default com.google.firebase.dataconnect.OperationRef<Data,Variables> ref(@Nullable Variables variables);
method @NonNull public String toString();
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewData> com.google.firebase.dataconnect.generated.GeneratedOperation<Connector,NewData,Variables> withDataDeserializer(@NonNull kotlinx.serialization.DeserializationStrategy<? extends NewData> dataDeserializer);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewVariables> com.google.firebase.dataconnect.generated.GeneratedOperation<Connector,Data,NewVariables> withVariablesSerializer(@NonNull kotlinx.serialization.SerializationStrategy<? super NewVariables> variablesSerializer);
property @NonNull public abstract Connector connector;
property @NonNull public abstract kotlinx.serialization.DeserializationStrategy<Data> dataDeserializer;
property @NonNull public abstract String operationName;
property @NonNull public abstract kotlinx.serialization.SerializationStrategy<Variables> variablesSerializer;
}

public interface GeneratedQuery<C extends com.google.firebase.dataconnect.generated.GeneratedConnector, Data, Variables> extends com.google.firebase.dataconnect.generated.GeneratedOperation<C,Data,Variables> {
public interface GeneratedQuery<Connector extends com.google.firebase.dataconnect.generated.GeneratedConnector<Connector>, Data, Variables> extends com.google.firebase.dataconnect.generated.GeneratedOperation<Connector,Data,Variables> {
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public com.google.firebase.dataconnect.generated.GeneratedQuery<Connector,Data,Variables> copy(@NonNull Connector connector, @NonNull String operationName, @NonNull kotlinx.serialization.DeserializationStrategy<? extends Data> dataDeserializer, @NonNull kotlinx.serialization.SerializationStrategy<? super Variables> variablesSerializer);
method @NonNull public default com.google.firebase.dataconnect.QueryRef<Data,Variables> ref(@Nullable Variables variables);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewData> com.google.firebase.dataconnect.generated.GeneratedQuery<Connector,NewData,Variables> withDataDeserializer(@NonNull kotlinx.serialization.DeserializationStrategy<? extends NewData> dataDeserializer);
method @NonNull @com.google.firebase.dataconnect.FirebaseDataConnectExperimental public <NewVariables> com.google.firebase.dataconnect.generated.GeneratedQuery<Connector,Data,NewVariables> withVariablesSerializer(@NonNull kotlinx.serialization.SerializationStrategy<? super NewVariables> variablesSerializer);
}

}
Expand Down
1 change: 0 additions & 1 deletion firebase-dataconnect/connectors/connectors.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ dependencies {
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.mockk)
testImplementation(libs.robolectric)
testImplementation(libs.truth)

androidTestImplementation(project(":firebase-dataconnect:androidTestutil"))
androidTestImplementation(project(":firebase-dataconnect:testutil"))
Expand Down
Loading
Loading