From 8f51c976db53931e9fd3230a885ace815bf18ae4 Mon Sep 17 00:00:00 2001 From: cpovirk <cpovirk@google.com> Date: Tue, 6 Feb 2024 13:03:52 -0800 Subject: [PATCH] Migrate usages of `Truth8.assertThat` to equivalent usages of `Truth.assertThat`. The `Truth8` methods will be deprecated (or hidden) in the future. Callers should move to `Truth`. Some (but not all) of the CLs in this batch require Truth [1.4.0](https://github.com/google/truth/releases/tag/v1.4.0). I submitted a CL earlier today to (I hope) perform that upgrade for your project. PiperOrigin-RevId: 604739382 --- .../dev/cel/checker/CelIdentDeclTest.java | 7 +- .../ProtoTypeMaskTypeProviderTest.java | 13 +- .../dev/cel/checker/TypeInferencerTest.java | 103 ++++++++-------- .../cel/common/CelAbstractSyntaxTreeTest.java | 25 ++-- .../java/dev/cel/common/CelSourceTest.java | 5 +- .../cel/common/ast/CelExprVisitorTest.java | 3 +- .../dev/cel/common/ast/CelReferenceTest.java | 7 +- .../internal/CombinedDescriptorPoolTest.java | 12 +- .../DefaultInstanceMessageFactoryTest.java | 7 +- .../internal/DefaultMessageFactoryTest.java | 7 +- .../dev/cel/common/internal/ErrorsTest.java | 9 +- .../cel/common/internal/ProtoAdapterTest.java | 32 +++-- .../navigation/CelNavigableAstTest.java | 3 +- .../navigation/CelNavigableExprTest.java | 7 +- .../CelNavigableExprVisitorTest.java | 5 +- .../types/ProtoMessageTypeProviderTest.java | 116 ++++++++---------- .../common/types/ProtoMessageTypeTest.java | 9 +- .../cel/common/values/OptionalValueTest.java | 3 +- .../common/values/ProtoMessageValueTest.java | 15 ++- .../extensions/CelOptionalLibraryTest.java | 25 ++-- .../cel/parser/CelMacroExprFactoryTest.java | 5 +- .../dev/cel/parser/CelParserImplTest.java | 75 +++++------ .../dev/cel/runtime/UnknownContextTest.java | 30 +++-- 23 files changed, 234 insertions(+), 289 deletions(-) diff --git a/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java b/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java index 1d131eb8..6dd221ae 100644 --- a/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java +++ b/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java @@ -22,7 +22,6 @@ import dev.cel.expr.Decl.IdentDecl; import dev.cel.expr.Type; import dev.cel.expr.Type.PrimitiveType; -import com.google.common.truth.Truth8; import dev.cel.common.ast.CelConstant; import dev.cel.common.types.SimpleType; import org.junit.Test; @@ -45,7 +44,7 @@ public void celIdentBuilder_success() { assertThat(stringIdent.name()).isEqualTo("ident"); assertThat(stringIdent.type()).isEqualTo(SimpleType.STRING); assertThat(stringIdent.doc()).isEqualTo("doc"); - Truth8.assertThat(stringIdent.constant()).hasValue(CelConstant.ofValue("str")); + assertThat(stringIdent.constant()).hasValue(CelConstant.ofValue("str")); } @Test @@ -58,7 +57,7 @@ public void celIdentBuilder_clearConstant() { builder.clearConstant(); - Truth8.assertThat(builder.build().constant()).isEmpty(); + assertThat(builder.build().constant()).isEmpty(); } @Test @@ -68,7 +67,7 @@ public void newIdentDeclaration_success() { assertThat(intIdent.name()).isEqualTo("ident"); assertThat(intIdent.type()).isEqualTo(SimpleType.INT); assertThat(intIdent.doc()).isEmpty(); - Truth8.assertThat(intIdent.constant()).isEmpty(); + assertThat(intIdent.constant()).isEmpty(); } @Test diff --git a/checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java b/checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java index 79269e47..31d0fb22 100644 --- a/checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java +++ b/checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java @@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.truth.Truth8; import com.google.protobuf.FieldMask; import com.google.rpc.context.AttributeContext; import dev.cel.common.types.CelType; @@ -64,7 +63,7 @@ public void lookupFieldNames_undeclaredMessageType() { CelTypeProvider celTypeProvider = new ProtoMessageTypeProvider(); ProtoTypeMaskTypeProvider protoTypeMaskProvider = new ProtoTypeMaskTypeProvider(celTypeProvider, ImmutableList.of()); - Truth8.assertThat(protoTypeMaskProvider.findType(ATTRIBUTE_CONTEXT_TYPE)).isEmpty(); + assertThat(protoTypeMaskProvider.findType(ATTRIBUTE_CONTEXT_TYPE)).isEmpty(); } @Test @@ -206,7 +205,7 @@ public void lookupFieldType() { .addPaths("request.auth.*") .build()))); ProtoMessageType ctxType = assertTypeFound(protoTypeMaskProvider, ATTRIBUTE_CONTEXT_TYPE); - Truth8.assertThat(ctxType.findField("resource")).isPresent(); + assertThat(ctxType.findField("resource")).isPresent(); assertTypeHasFieldWithType(ctxType, "resource", RESOURCE_TYPE); assertTypeHasFieldWithType(ctxType, "request", REQUEST_TYPE); @@ -238,7 +237,7 @@ public void lookupFieldType_notExposedField() { "google.rpc.context.AttributeContext", FieldMask.newBuilder().addPaths("resource.name").build()))); ProtoMessageType resourceType = assertTypeFound(protoTypeMaskProvider, RESOURCE_TYPE); - Truth8.assertThat(resourceType.findField("type")).isEmpty(); + assertThat(resourceType.findField("type")).isEmpty(); } @Test @@ -252,12 +251,12 @@ public void lookupType_notExposed() { ProtoTypeMask.of( "google.rpc.context.AttributeContext", FieldMask.newBuilder().addPaths("resource.name").build()))); - Truth8.assertThat(protoTypeMaskProvider.findType(REQUEST_TYPE)).isPresent(); + assertThat(protoTypeMaskProvider.findType(REQUEST_TYPE)).isPresent(); } private ProtoMessageType assertTypeFound(CelTypeProvider celTypeProvider, String typeName) { Optional<CelType> foundType = celTypeProvider.findType(typeName); - Truth8.assertThat(foundType).isPresent(); + assertThat(foundType).isPresent(); CelType celType = foundType.get(); assertThat(celType).isInstanceOf(ProtoMessageType.class); return (ProtoMessageType) celType; @@ -271,7 +270,7 @@ private void assertTypeHasFields(ProtoMessageType protoType, ImmutableSet<String private void assertTypeHasFieldWithType( ProtoMessageType protoType, String fieldName, String typeName) { - Truth8.assertThat(protoType.findField(fieldName)).isPresent(); + assertThat(protoType.findField(fieldName)).isPresent(); assertThat(protoType.findField(fieldName).get().type().name()).isEqualTo(typeName); } } diff --git a/checker/src/test/java/dev/cel/checker/TypeInferencerTest.java b/checker/src/test/java/dev/cel/checker/TypeInferencerTest.java index 37ba5073..ee167def 100644 --- a/checker/src/test/java/dev/cel/checker/TypeInferencerTest.java +++ b/checker/src/test/java/dev/cel/checker/TypeInferencerTest.java @@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.truth.Truth8; import dev.cel.checker.TypeInferencer.UnificationResult; import dev.cel.common.types.CelType; import dev.cel.common.types.JsonType; @@ -69,7 +68,7 @@ public void unify_success_parameterizedMap() { MapType mapInst = MapType.create(SimpleType.STRING, ListType.create(TypeParamType.create("V"))); MapType mapParamFresh = (MapType) mapParam.withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(mapInst, mapParamFresh); - Truth8.assertThat(result).isPresent(); + assertThat(result).isPresent(); assertThat(result.get().substitutions()) .containsExactly( mapParamFresh.keyType().name(), @@ -86,8 +85,8 @@ public void unify_success_parameterizedMapReversedArgs() { MapType mapInst = MapType.create(SimpleType.STRING, ListType.create(TypeParamType.create("V"))); MapType mapParamFresh = (MapType) mapParam.withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(mapParamFresh, mapInst); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(mapInst); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(mapInst); assertThat(result.get().substitutions()) .containsExactly( mapParamFresh.keyType().name(), @@ -103,12 +102,12 @@ public void unify_success_jsonEqualsDoubleOneByOne() { TypeParamType equalsArg = TypeParamType.create("T"); CelType equalsArgFresh = equalsArg.withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> firstArg = inferencer.unify(JsonType.JSON, equalsArgFresh); - Truth8.assertThat(firstArg).isPresent(); - Truth8.assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(firstArg).isPresent(); + assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); inferencer.recordSubstitutions(firstArg.get().substitutions()); Optional<UnificationResult> secondArg = inferencer.unify(SimpleType.DOUBLE, equalsArgFresh); - Truth8.assertThat(secondArg).isPresent(); - Truth8.assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(secondArg).isPresent(); + assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); inferencer.recordSubstitutions(secondArg.get().substitutions()); assertThat(inferencer.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -118,12 +117,12 @@ public void unify_success_jsonEqualsDoubleOneByOneDifferentInferencer() { TypeParamType equalsArg = TypeParamType.create("T"); CelType equalsArgFresh = equalsArg.withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> firstArg = inferencer.unify(JsonType.JSON, equalsArgFresh); - Truth8.assertThat(firstArg).isPresent(); - Truth8.assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(firstArg).isPresent(); + assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); TypeInferencer inferencer2 = new TypeInferencer(UNION_TYPES, firstArg.get().substitutions()); Optional<UnificationResult> secondArg = inferencer2.unify(SimpleType.DOUBLE, equalsArgFresh); - Truth8.assertThat(secondArg).isPresent(); - Truth8.assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(secondArg).isPresent(); + assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); inferencer2.recordSubstitutions(secondArg.get().substitutions()); assertThat(inferencer2.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -131,15 +130,15 @@ public void unify_success_jsonEqualsDoubleOneByOneDifferentInferencer() { @Test public void unify_success_jsonToDouble() { Optional<UnificationResult> result = inferencer.unify(JsonType.JSON, SimpleType.DOUBLE); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); } @Test public void unify_success_doubleToJson() { Optional<UnificationResult> result = inferencer.unify(SimpleType.DOUBLE, JsonType.JSON); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); } @Test @@ -147,14 +146,14 @@ public void unify_false_nestedTypeParamReference() { TypeParamType typeParamArg = TypeParamType.create("T"); ListType listType = ListType.create(typeParamArg); Optional<UnificationResult> result = inferencer.unify(typeParamArg, listType); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test public void unify_success_dynOrErrorYieldsError() { Optional<UnificationResult> result = inferencer.unify(SimpleType.DYN, SimpleType.ERROR); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(SimpleType.ERROR); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(SimpleType.ERROR); } @Test @@ -162,8 +161,8 @@ public void unify_success_doubleNullToNullableDoubleWithTypeParam() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(NullableType.create(SimpleType.DOUBLE)); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(NullableType.create(SimpleType.DOUBLE)); } @Test @@ -171,8 +170,8 @@ public void unify_success_doubleNullToNullableDoubleWithConcreteType() { CelType outputType = NullableType.create(SimpleType.DOUBLE); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(outputType); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(outputType); } @Test @@ -182,8 +181,8 @@ public void unify_success_doubleNullStringToJson() { inferencer.unify( ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE, SimpleType.STRING), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); } @Test @@ -194,8 +193,8 @@ public void unify_success_doubleNullStringToDyn() { inferencer.unify( ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE, SimpleType.STRING), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(SimpleType.DYN); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(SimpleType.DYN); } @Test @@ -206,7 +205,7 @@ public void unify_false_doubleNullStringNoJsonNoTopType() { inferencer.unify( ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE, SimpleType.STRING), outputType); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -216,8 +215,8 @@ public void unify_success_abstractTypeListToJsonParam() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); } @Test @@ -229,8 +228,8 @@ public void unify_success_abstractTypeMapToMapJsonParam() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()) + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()) .hasValue(OpaqueType.create("set", MapType.create(SimpleType.STRING, JsonType.JSON))); } @@ -242,8 +241,8 @@ public void unify_success_abstractTypeMapToJsonParam() { CelType outputType = TypeParamType.create("0").withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); } @Test @@ -258,9 +257,8 @@ public void unify_success_opaqueTypeMapToDynParam() { // to enter into the type resolution. Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()) - .hasValue(OpaqueType.create("set", SimpleType.DYN)); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", SimpleType.DYN)); } @Test @@ -270,9 +268,8 @@ public void unify_success_jsonIntSetsToDynSet() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(setJson, setInt), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()) - .hasValue(OpaqueType.create("set", SimpleType.DYN)); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", SimpleType.DYN)); } @Test @@ -283,35 +280,35 @@ public void unify_success_nullableStruct() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(ImmutableList.of(nullableStructType, structType), outputType); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(nullableStructType); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(nullableStructType); } @Test public void unify_false_differentKinds() { OpaqueType vectorType = OpaqueType.create("vector", SimpleType.STRING); - Truth8.assertThat(inferencer.unify(JsonType.JSON, vectorType)).isEmpty(); + assertThat(inferencer.unify(JsonType.JSON, vectorType)).isEmpty(); } @Test public void unify_false_sameKindDifferentTypeName() { OpaqueType setType = OpaqueType.create("set", SimpleType.STRING); OpaqueType vectorType = OpaqueType.create("vector", SimpleType.STRING); - Truth8.assertThat(inferencer.unify(setType, vectorType)).isEmpty(); + assertThat(inferencer.unify(setType, vectorType)).isEmpty(); } @Test public void unify_false_sameTypeDifferentParameterTypes() { OpaqueType setType = OpaqueType.create("set", SimpleType.INT); OpaqueType vectorType = OpaqueType.create("set", SimpleType.STRING); - Truth8.assertThat(inferencer.unify(setType, vectorType)).isEmpty(); + assertThat(inferencer.unify(setType, vectorType)).isEmpty(); } @Test public void unify_false_sameTypeDifferentParameterCounts() { OpaqueType setType = OpaqueType.create("set", SimpleType.INT); OpaqueType vectorType = OpaqueType.create("set", SimpleType.INT, SimpleType.INT); - Truth8.assertThat(inferencer.unify(setType, vectorType)).isEmpty(); + assertThat(inferencer.unify(setType, vectorType)).isEmpty(); } @Test @@ -323,7 +320,7 @@ public void isAssignable_success_jsonSelect() { inferencer.isAssignable( ImmutableList.of(mapInst, SimpleType.STRING), ImmutableList.of(mapParamFresh, mapParamFresh.keyType())); - Truth8.assertThat(result).isPresent(); + assertThat(result).isPresent(); assertThat(result.get()) .containsExactly( mapParamFresh.keyType().name(), @@ -342,7 +339,7 @@ public void isAssignable_success_jsonEqualsDoubleAsList() { inferencer.isAssignable( ImmutableList.of(JsonType.JSON, SimpleType.DOUBLE), ImmutableList.of(equalsArgFresh, equalsArgFresh)); - Truth8.assertThat(result).isPresent(); + assertThat(result).isPresent(); inferencer.recordSubstitutions(result.get()); assertThat(inferencer.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -355,7 +352,7 @@ public void isAssignable_success_doubleEqualsJsonAsList() { inferencer.isAssignable( ImmutableList.of(SimpleType.DOUBLE, JsonType.JSON), ImmutableList.of(equalsArgFresh, equalsArgFresh)); - Truth8.assertThat(result).isPresent(); + assertThat(result).isPresent(); inferencer.recordSubstitutions(result.get()); assertThat(inferencer.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -368,7 +365,7 @@ public void isAssignable_false_doubleEqualsString() { inferencer.isAssignable( ImmutableList.of(SimpleType.DOUBLE, SimpleType.STRING), ImmutableList.of(equalsArgFresh, equalsArgFresh)); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -377,7 +374,7 @@ public void isAssignable_false_sameTypeDifferentParameterCounts() { OpaqueType setType2 = OpaqueType.create("set", SimpleType.STRING, SimpleType.INT); Optional<ImmutableMap<String, CelType>> result = inferencer.isAssignable(setType.parameters(), setType2.parameters()); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -389,8 +386,8 @@ public void finalize_success_typeFinalize() { CelType typeOfTypeWithFreshVars = typeOfType.withFreshTypeParamVariables(typeVarGenerator); Optional<UnificationResult> result = inferencer.unify(typeOfStructType, typeOfTypeWithFreshVars); - Truth8.assertThat(result).isPresent(); - Truth8.assertThat(result.get().unifiedType()).hasValue(typeOfStructType); + assertThat(result).isPresent(); + assertThat(result.get().unifiedType()).hasValue(typeOfStructType); inferencer.recordSubstitutions(result.get().substitutions()); assertThat(inferencer.finalize(typeOfTypeWithFreshVars, SimpleType.DYN)) .isEqualTo(typeOfStructType); diff --git a/common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java b/common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java index 960ba664..78c16c16 100644 --- a/common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java +++ b/common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java @@ -26,7 +26,6 @@ import dev.cel.expr.SourceInfo; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.truth.Truth8; import dev.cel.common.ast.CelConstant; import dev.cel.common.ast.CelExpr; import dev.cel.common.types.CelTypes; @@ -107,9 +106,9 @@ public void getResultType_isStaticWhenCheckedExpr() { @Test public void findEnumValue_findsConstantInCheckedExpr() { CelAbstractSyntaxTree ast = CHECKED_ENUM_AST; - Truth8.assertThat(ast.findEnumValue(1)).isEmpty(); - Truth8.assertThat(ast.findEnumValue(2)).hasValue(CelConstant.ofValue(2)); - Truth8.assertThat(ast.findEnumValue(3)).isEmpty(); + assertThat(ast.findEnumValue(1)).isEmpty(); + assertThat(ast.findEnumValue(2)).hasValue(CelConstant.ofValue(2)); + assertThat(ast.findEnumValue(3)).isEmpty(); } @Test @@ -118,17 +117,17 @@ public void findEnumValue_doesNotFindConstantInParsedExpr() { CelAbstractSyntaxTree.newParsedAst( CHECKED_ENUM_AST.getExpr(), CHECKED_ENUM_AST.getSource()); - Truth8.assertThat(ast.findEnumValue(1)).isEmpty(); - Truth8.assertThat(ast.findEnumValue(2)).isEmpty(); - Truth8.assertThat(ast.findEnumValue(3)).isEmpty(); + assertThat(ast.findEnumValue(1)).isEmpty(); + assertThat(ast.findEnumValue(2)).isEmpty(); + assertThat(ast.findEnumValue(3)).isEmpty(); } @Test public void findOverloadIDs_findsOverloadsInCheckedExpr() { CelAbstractSyntaxTree ast = CHECKED_ENUM_AST; - Truth8.assertThat(ast.findOverloadIDs(1)).isEmpty(); - Truth8.assertThat(ast.findOverloadIDs(2)).isEmpty(); - Truth8.assertThat(ast.findOverloadIDs(3)).hasValue(ImmutableList.of("not_equals")); + assertThat(ast.findOverloadIDs(1)).isEmpty(); + assertThat(ast.findOverloadIDs(2)).isEmpty(); + assertThat(ast.findOverloadIDs(3)).hasValue(ImmutableList.of("not_equals")); } @Test @@ -137,9 +136,9 @@ public void findOverloadIDs_doesNotFindsOverloadsInParsedExpr() { CelAbstractSyntaxTree.newParsedAst( CHECKED_ENUM_AST.getExpr(), CHECKED_ENUM_AST.getSource()); - Truth8.assertThat(ast.findOverloadIDs(1)).isEmpty(); - Truth8.assertThat(ast.findOverloadIDs(2)).isEmpty(); - Truth8.assertThat(ast.findOverloadIDs(3)).isEmpty(); + assertThat(ast.findOverloadIDs(1)).isEmpty(); + assertThat(ast.findOverloadIDs(2)).isEmpty(); + assertThat(ast.findOverloadIDs(3)).isEmpty(); } @Test diff --git a/common/src/test/java/dev/cel/common/CelSourceTest.java b/common/src/test/java/dev/cel/common/CelSourceTest.java index e77db1da..74e350a3 100644 --- a/common/src/test/java/dev/cel/common/CelSourceTest.java +++ b/common/src/test/java/dev/cel/common/CelSourceTest.java @@ -18,7 +18,6 @@ import static org.antlr.v4.runtime.IntStream.UNKNOWN_SOURCE_NAME; import static org.junit.Assert.assertThrows; -import com.google.common.truth.Truth8; import dev.cel.common.CelSource.Extension; import dev.cel.common.CelSource.Extension.Component; import dev.cel.common.CelSource.Extension.Version; @@ -47,13 +46,13 @@ public final class CelSourceTest { @Test public void getLocationOffset_correctStartingLocation() throws Exception { CelSource source = CelSource.newBuilder(LATIN_1_EXPR).build(); - Truth8.assertThat(source.getLocationOffset(CelSourceLocation.of(1, 0))).hasValue(0); + assertThat(source.getLocationOffset(CelSourceLocation.of(1, 0))).hasValue(0); } @Test public void getOffsetLocation_correctStartingLocation() throws Exception { CelSource source = CelSource.newBuilder(LATIN_1_EXPR).build(); - Truth8.assertThat(source.getOffsetLocation(0)).hasValue(CelSourceLocation.of(1, 0)); + assertThat(source.getOffsetLocation(0)).hasValue(CelSourceLocation.of(1, 0)); } @Test diff --git a/common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java b/common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java index 5443266b..1926eb31 100644 --- a/common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java +++ b/common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java @@ -19,7 +19,6 @@ import com.google.auto.value.AutoValue; import com.google.common.collect.ImmutableList; -import com.google.common.truth.Truth8; import dev.cel.common.CelAbstractSyntaxTree; import dev.cel.common.ast.CelExpr.CelCall; import dev.cel.common.ast.CelExpr.CelComprehension; @@ -346,7 +345,7 @@ public void visitComprehension() throws Exception { .isEqualTo(Operator.LOGICAL_AND.getFunction()); assertThat(comprehension.loopStep().call().args()).hasSize(2); assertThat(visitedReference.createList().get().elements()).isEqualTo(iterRangeElements); - Truth8.assertThat(visitedReference.identifier()) + assertThat(visitedReference.identifier()) .hasValue(CelIdent.newBuilder().setName("__result__").build()); assertThat(visitedReference.arguments()).hasSize(10); } diff --git a/common/src/test/java/dev/cel/common/ast/CelReferenceTest.java b/common/src/test/java/dev/cel/common/ast/CelReferenceTest.java index 79395c55..dbe6613b 100644 --- a/common/src/test/java/dev/cel/common/ast/CelReferenceTest.java +++ b/common/src/test/java/dev/cel/common/ast/CelReferenceTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableList; -import com.google.common.truth.Truth8; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -32,7 +31,7 @@ public void constructCelReference_withEmptyArguments() { assertThat(reference.name()).isEqualTo("refName"); assertThat(reference.overloadIds()).isEmpty(); - Truth8.assertThat(reference.value()).isEmpty(); + assertThat(reference.value()).isEmpty(); } @Test @@ -42,7 +41,7 @@ public void constructCelReference_withOverloadIds() { assertThat(reference.name()).isEqualTo("refName"); assertThat(reference.overloadIds()).containsExactly("a", "b", "c"); - Truth8.assertThat(reference.value()).isEmpty(); + assertThat(reference.value()).isEmpty(); } @Test @@ -52,7 +51,7 @@ public void constructCelReference_withValue() { assertThat(reference.name()).isEqualTo("refName"); assertThat(reference.overloadIds()).isEmpty(); - Truth8.assertThat(reference.value()).hasValue(CelConstant.ofValue(10)); + assertThat(reference.value()).hasValue(CelConstant.ofValue(10)); } @Test diff --git a/common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java b/common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java index d232ac24..a56bb2ed 100644 --- a/common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java +++ b/common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java @@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.collect.ImmutableList; -import com.google.common.truth.Truth8; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.ExtensionRegistry; import com.google.protobuf.Value; @@ -43,11 +42,10 @@ public void findDescriptor_descriptorReturnedFromBothPool() { CombinedDescriptorPool.create( ImmutableList.of(DefaultDescriptorPool.INSTANCE, dynamicDescriptorPool)); - Truth8.assertThat(combinedDescriptorPool.findDescriptor(Value.getDescriptor().getFullName())) + assertThat(combinedDescriptorPool.findDescriptor(Value.getDescriptor().getFullName())) .hasValue( Value.getDescriptor()); // Retrieved from default descriptor pool (well-known-type) - Truth8.assertThat( - combinedDescriptorPool.findDescriptor(TestAllTypes.getDescriptor().getFullName())) + assertThat(combinedDescriptorPool.findDescriptor(TestAllTypes.getDescriptor().getFullName())) .hasValue(TestAllTypes.getDescriptor()); // Retrieved from the dynamic descriptor pool. } @@ -61,7 +59,7 @@ public void findDescriptor_returnsEmpty() { CombinedDescriptorPool.create( ImmutableList.of(DefaultDescriptorPool.INSTANCE, descriptorPool)); - Truth8.assertThat(combinedDescriptorPool.findDescriptor("bogus")).isEmpty(); + assertThat(combinedDescriptorPool.findDescriptor("bogus")).isEmpty(); } @Test @@ -78,7 +76,7 @@ public void findExtensionDescriptor_success() { combinedDescriptorPool.findExtensionDescriptor( Proto2Message.getDescriptor(), "dev.cel.testing.testdata.proto2.test_all_types_ext"); - Truth8.assertThat(fieldDescriptor).isPresent(); + assertThat(fieldDescriptor).isPresent(); assertThat(fieldDescriptor.get().isExtension()).isTrue(); assertThat(fieldDescriptor.get().getFullName()) .isEqualTo("dev.cel.testing.testdata.proto2.test_all_types_ext"); @@ -94,7 +92,7 @@ public void findExtensionDescriptor_returnsEmpty() { CombinedDescriptorPool.create( ImmutableList.of(DefaultDescriptorPool.INSTANCE, dynamicDescriptorPool)); - Truth8.assertThat( + assertThat( combinedDescriptorPool.findExtensionDescriptor(TestAllTypes.getDescriptor(), "bogus")) .isEmpty(); } diff --git a/common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java b/common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java index 0f24aafd..a167190f 100644 --- a/common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java +++ b/common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java @@ -19,7 +19,6 @@ import static java.util.Arrays.stream; import com.google.common.collect.ImmutableList; -import com.google.common.truth.Truth8; import com.google.common.util.concurrent.MoreExecutors; import com.google.protobuf.Descriptors.Descriptor; import com.google.protobuf.Message; @@ -95,7 +94,7 @@ public void getPrototype_success(@TestParameter PrototypeDescriptorTestCase test Optional<Message> defaultMessage = DefaultInstanceMessageFactory.getInstance().getPrototype(descriptor); - Truth8.assertThat(defaultMessage).hasValue(testCase.defaultInstance); + assertThat(defaultMessage).hasValue(testCase.defaultInstance); } @Test @@ -107,8 +106,8 @@ public void getPrototype_cached_success(@TestParameter PrototypeDescriptorTestCa Optional<Message> defaultMessage2 = DefaultInstanceMessageFactory.getInstance().getPrototype(descriptor); - Truth8.assertThat(defaultMessage).hasValue(testCase.defaultInstance); - Truth8.assertThat(defaultMessage2).hasValue(testCase.defaultInstance); + assertThat(defaultMessage).hasValue(testCase.defaultInstance); + assertThat(defaultMessage2).hasValue(testCase.defaultInstance); } @Test diff --git a/common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java b/common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java index 8d75652e..aef6140b 100644 --- a/common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java +++ b/common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java @@ -21,7 +21,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.google.common.io.Resources; -import com.google.common.truth.Truth8; import com.google.protobuf.DescriptorProtos.FileDescriptorSet; import com.google.protobuf.Descriptors.FileDescriptor; import com.google.protobuf.DynamicMessage; @@ -70,7 +69,7 @@ public void newBuilder_withDescriptor_producesNewMessageBuilder() { public void newBuilder_unknownMessage_returnsEmpty() { DefaultMessageFactory messageFactory = DefaultMessageFactory.INSTANCE; - Truth8.assertThat(messageFactory.newBuilder("unknown_message")).isEmpty(); + assertThat(messageFactory.newBuilder("unknown_message")).isEmpty(); } @Test @@ -85,7 +84,7 @@ public void newBuilder_unequalDescriptorForSameMessage_returnsDynamicMessage() t DefaultMessageFactory messageFactory = DefaultMessageFactory.create(DefaultDescriptorPool.create(celDescriptors)); - Truth8.assertThat(messageFactory.newBuilder("google.api.expr.Value")).isPresent(); + assertThat(messageFactory.newBuilder("google.api.expr.Value")).isPresent(); assertThat(messageFactory.newBuilder("google.api.expr.Value").get()) .isInstanceOf(DynamicMessage.Builder.class); } @@ -114,6 +113,6 @@ public void combinedMessageFactoryTest() { assertThat(messageFactory.newBuilder("test").get().build()) .isEqualTo(TestAllTypes.getDefaultInstance()); - Truth8.assertThat(messageFactory.newBuilder("bogus")).isEmpty(); + assertThat(messageFactory.newBuilder("bogus")).isEmpty(); } } diff --git a/common/src/test/java/dev/cel/common/internal/ErrorsTest.java b/common/src/test/java/dev/cel/common/internal/ErrorsTest.java index 0bdfed17..ad46f773 100644 --- a/common/src/test/java/dev/cel/common/internal/ErrorsTest.java +++ b/common/src/test/java/dev/cel/common/internal/ErrorsTest.java @@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; -import com.google.common.truth.Truth8; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -61,9 +60,9 @@ public void getPositionLocation() { @Test public void getSnippet() { Errors errors = new Errors("test", "hello\nworld\n"); - Truth8.assertThat(errors.getSnippet(1)).hasValue("hello"); - Truth8.assertThat(errors.getSnippet(2)).hasValue("world"); - Truth8.assertThat(errors.getSnippet(3)).hasValue(""); - Truth8.assertThat(errors.getSnippet(4)).isEmpty(); + assertThat(errors.getSnippet(1)).hasValue("hello"); + assertThat(errors.getSnippet(2)).hasValue("world"); + assertThat(errors.getSnippet(3)).hasValue(""); + assertThat(errors.getSnippet(4)).isEmpty(); } } diff --git a/common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java b/common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java index 118bd393..151f79f4 100644 --- a/common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java +++ b/common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java @@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.UnsignedLong; -import com.google.common.truth.Truth8; import com.google.protobuf.Any; import com.google.protobuf.BoolValue; import com.google.protobuf.ByteString; @@ -162,8 +161,7 @@ public static List<Object[]> data() { public void adaptValueToProto_bidirectionalConversion() { DynamicProto dynamicProto = DynamicProto.create(DefaultMessageFactory.INSTANCE); ProtoAdapter protoAdapter = new ProtoAdapter(dynamicProto, options.enableUnsignedLongs()); - Truth8.assertThat( - protoAdapter.adaptValueToProto(value, proto.getDescriptorForType().getFullName())) + assertThat(protoAdapter.adaptValueToProto(value, proto.getDescriptorForType().getFullName())) .hasValue(proto); assertThat(protoAdapter.adaptProtoToValue(proto)).isEqualTo(value); } @@ -182,7 +180,7 @@ public void adaptAnyValue_hermeticTypes_bidirectionalConversion() { ? Optional.of(Expr.newBuilder()) : Optional.empty()), LEGACY.enableUnsignedLongs()); - Truth8.assertThat(protoAdapter.adaptValueToProto(expr, Any.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto(expr, Any.getDescriptor().getFullName())) .hasValue(Any.pack(expr)); assertThat(protoAdapter.adaptProtoToValue(Any.pack(expr))).isEqualTo(expr); } @@ -193,7 +191,7 @@ public static class AsymmetricConversionTest { @Test public void adaptValueToProto_asymmetricNullConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat(protoAdapter.adaptValueToProto(null, Any.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto(null, Any.getDescriptor().getFullName())) .hasValue(Any.pack(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build())); assertThat( protoAdapter.adaptProtoToValue( @@ -204,7 +202,7 @@ public void adaptValueToProto_asymmetricNullConversion() { @Test public void adaptValueToProto_asymmetricFloatConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat(protoAdapter.adaptValueToProto(1.5F, Any.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto(1.5F, Any.getDescriptor().getFullName())) .hasValue(Any.pack(FloatValue.of(1.5F))); assertThat(protoAdapter.adaptProtoToValue(Any.pack(FloatValue.of(1.5F)))).isEqualTo(1.5D); } @@ -212,8 +210,7 @@ public void adaptValueToProto_asymmetricFloatConversion() { @Test public void adaptValueToProto_asymmetricDoubleFloatConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat( - protoAdapter.adaptValueToProto(1.5D, FloatValue.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto(1.5D, FloatValue.getDescriptor().getFullName())) .hasValue(FloatValue.of(1.5F)); assertThat(protoAdapter.adaptProtoToValue(FloatValue.of(1.5F))).isEqualTo(1.5D); } @@ -221,28 +218,27 @@ public void adaptValueToProto_asymmetricDoubleFloatConversion() { @Test public void adaptValueToProto_asymmetricFloatDoubleConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat( - protoAdapter.adaptValueToProto(1.5F, DoubleValue.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto(1.5F, DoubleValue.getDescriptor().getFullName())) .hasValue(DoubleValue.of(1.5D)); } @Test public void adaptValueToProto_asymmetricJsonConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, CURRENT.enableUnsignedLongs()); - Truth8.assertThat( + assertThat( protoAdapter.adaptValueToProto( UnsignedLong.valueOf(1L), Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setNumberValue(1).build()); - Truth8.assertThat( + assertThat( protoAdapter.adaptValueToProto( UnsignedLong.fromLongBits(-1L), Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setStringValue(Long.toUnsignedString(-1L)).build()); - Truth8.assertThat(protoAdapter.adaptValueToProto(1L, Value.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto(1L, Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setNumberValue(1).build()); - Truth8.assertThat( + assertThat( protoAdapter.adaptValueToProto(Long.MAX_VALUE, Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setStringValue(Long.toString(Long.MAX_VALUE)).build()); - Truth8.assertThat( + assertThat( protoAdapter.adaptValueToProto( ByteString.copyFromUtf8("foo"), Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setStringValue("Zm9v").build()); @@ -251,7 +247,7 @@ public void adaptValueToProto_asymmetricJsonConversion() { @Test public void adaptValueToProto_unsupportedJsonConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat( + assertThat( protoAdapter.adaptValueToProto( ImmutableMap.of(1, 1), Any.getDescriptor().getFullName())) .isEmpty(); @@ -260,7 +256,7 @@ public void adaptValueToProto_unsupportedJsonConversion() { @Test public void adaptValueToProto_unsupportedJsonListConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat( + assertThat( protoAdapter.adaptValueToProto( ImmutableMap.of(1, 1), ListValue.getDescriptor().getFullName())) .isEmpty(); @@ -269,7 +265,7 @@ public void adaptValueToProto_unsupportedJsonListConversion() { @Test public void adaptValueToProto_unsupportedConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - Truth8.assertThat(protoAdapter.adaptValueToProto("Hello", Expr.getDescriptor().getFullName())) + assertThat(protoAdapter.adaptValueToProto("Hello", Expr.getDescriptor().getFullName())) .isEmpty(); } diff --git a/common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java b/common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java index 2c595f0d..40f77281 100644 --- a/common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java +++ b/common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java @@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; -import com.google.common.truth.Truth8; import dev.cel.common.CelAbstractSyntaxTree; import dev.cel.common.ast.CelConstant; import dev.cel.common.ast.CelExpr; @@ -39,7 +38,7 @@ public void construct_success() throws Exception { assertThat(navigableAst.getAst()).isEqualTo(ast); assertThat(navigableAst.getRoot().expr()) .isEqualTo(CelExpr.ofConstantExpr(1, CelConstant.ofValue("Hello World"))); - Truth8.assertThat(navigableAst.getRoot().parent()).isEmpty(); + assertThat(navigableAst.getRoot().parent()).isEmpty(); assertThat(navigableAst.getRoot().depth()).isEqualTo(0); } } diff --git a/common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java b/common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java index b76da7a2..261524df 100644 --- a/common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java +++ b/common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java @@ -16,7 +16,6 @@ import static com.google.common.truth.Truth.assertThat; -import com.google.common.truth.Truth8; import dev.cel.common.ast.CelConstant; import dev.cel.common.ast.CelExpr; import org.junit.Test; @@ -34,7 +33,7 @@ public void construct_withoutParent_success() { assertThat(navigableExpr.expr()).isEqualTo(constExpr); assertThat(navigableExpr.depth()).isEqualTo(2); - Truth8.assertThat(navigableExpr.parent()).isEmpty(); + assertThat(navigableExpr.parent()).isEmpty(); } @Test @@ -47,9 +46,9 @@ public void construct_withParent_success() { assertThat(parentExpr.expr()).isEqualTo(identExpr); assertThat(parentExpr.depth()).isEqualTo(1); - Truth8.assertThat(parentExpr.parent()).isEmpty(); + assertThat(parentExpr.parent()).isEmpty(); assertThat(navigableExpr.expr()).isEqualTo(constExpr); assertThat(navigableExpr.depth()).isEqualTo(2); - Truth8.assertThat(navigableExpr.parent()).hasValue(parentExpr); + assertThat(navigableExpr.parent()).hasValue(parentExpr); } } diff --git a/common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java b/common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java index 9aeefa6a..f3739ca5 100644 --- a/common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java +++ b/common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java @@ -22,7 +22,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.primitives.UnsignedLong; -import com.google.common.truth.Truth8; import com.google.testing.junit.testparameterinjector.TestParameterInjector; import com.google.testing.junit.testparameterinjector.TestParameters; import dev.cel.common.CelAbstractSyntaxTree; @@ -273,7 +272,7 @@ public void stringFormatCall_filterList_success() throws Exception { assertThat(allConstants).hasSize(1); CelNavigableExpr listExpr = allConstants.get(0); assertThat(listExpr.getKind()).isEqualTo(Kind.CREATE_LIST); - Truth8.assertThat(listExpr.parent()).isPresent(); + assertThat(listExpr.parent()).isPresent(); CelNavigableExpr stringFormatExpr = listExpr.parent().get(); assertThat(stringFormatExpr.getKind()).isEqualTo(Kind.CALL); CelCall call = listExpr.parent().get().expr().exprKind().call(); @@ -676,7 +675,7 @@ public void comprehension_allNodes_parentsPopulated() throws Exception { CelExpr.ofComprehension( 13, "i", iterRange, "__result__", accuInit, loopCondition, loopStep, result); assertThat(allNodes).hasSize(11); - Truth8.assertThat(allNodes.get(0).parent()).isEmpty(); // comprehension + assertThat(allNodes.get(0).parent()).isEmpty(); // comprehension assertThat(allNodes.get(1).parent().get().expr()).isEqualTo(comprehension); // iter_range assertThat(allNodes.get(2).parent().get().expr()) .isEqualTo(iterRange); // const_expr within iter_range diff --git a/common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java b/common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java index cb6f03d3..f07a67b7 100644 --- a/common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java +++ b/common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java @@ -19,7 +19,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; -import com.google.common.truth.Truth8; import dev.cel.common.types.CelTypeProvider.CombinedCelTypeProvider; import dev.cel.testing.testdata.proto2.MessagesProto2; import dev.cel.testing.testdata.proto2.MessagesProto2Extensions; @@ -49,7 +48,7 @@ public void types_emptyTypeSet() { @Test public void findType_emptyTypeSet() { - Truth8.assertThat(emptyProvider.findType("any")).isEmpty(); + assertThat(emptyProvider.findType("any")).isEmpty(); } @Test @@ -67,82 +66,78 @@ public void types_allGlobalAndNestedDeclarations() { public void findType_globalEnumWithAllNamesAndNumbers() { Optional<CelType> celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.GlobalEnum"); - Truth8.assertThat(celType).isPresent(); + assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(EnumType.class); EnumType enumType = (EnumType) celType.get(); assertThat(enumType.name()).isEqualTo("dev.cel.testing.testdata.proto3.GlobalEnum"); - Truth8.assertThat(enumType.findNameByNumber(0)).hasValue("GOO"); - Truth8.assertThat(enumType.findNameByNumber(1)).hasValue("GAR"); - Truth8.assertThat(enumType.findNameByNumber(2)).hasValue("GAZ"); - Truth8.assertThat(enumType.findNameByNumber(3)).isEmpty(); + assertThat(enumType.findNameByNumber(0)).hasValue("GOO"); + assertThat(enumType.findNameByNumber(1)).hasValue("GAR"); + assertThat(enumType.findNameByNumber(2)).hasValue("GAZ"); + assertThat(enumType.findNameByNumber(3)).isEmpty(); } @Test public void findType_nestedEnumWithAllNamesAndNumbers() { Optional<CelType> celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum"); - Truth8.assertThat(celType).isPresent(); + assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(EnumType.class); EnumType enumType = (EnumType) celType.get(); assertThat(enumType.name()) .isEqualTo("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum"); - Truth8.assertThat(enumType.findNumberByName("FOO")).hasValue(0); - Truth8.assertThat(enumType.findNumberByName("BAR")).hasValue(1); - Truth8.assertThat(enumType.findNumberByName("BAZ")).hasValue(2); - Truth8.assertThat(enumType.findNumberByName("MISSING")).isEmpty(); + assertThat(enumType.findNumberByName("FOO")).hasValue(0); + assertThat(enumType.findNumberByName("BAR")).hasValue(1); + assertThat(enumType.findNumberByName("BAZ")).hasValue(2); + assertThat(enumType.findNumberByName("MISSING")).isEmpty(); } @Test public void findType_globalMessageTypeNoExtensions() { Optional<CelType> celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.NestedTestAllTypes"); - Truth8.assertThat(celType).isPresent(); + assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto3.NestedTestAllTypes"); - Truth8.assertThat(protoType.findField("payload")).isPresent(); - Truth8.assertThat(protoType.findField("child")).isPresent(); - Truth8.assertThat(protoType.findField("missing")).isEmpty(); + assertThat(protoType.findField("payload")).isPresent(); + assertThat(protoType.findField("child")).isPresent(); + assertThat(protoType.findField("missing")).isEmpty(); assertThat(protoType.fields()).hasSize(2); - Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto3.any")).isEmpty(); + assertThat(protoType.findExtension("dev.cel.testing.testdata.proto3.any")).isEmpty(); } @Test public void findType_globalMessageWithExtensions() { Optional<CelType> celType = proto2Provider.findType("dev.cel.testing.testdata.proto2.Proto2Message"); - Truth8.assertThat(celType).isPresent(); + assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto2.Proto2Message"); - Truth8.assertThat(protoType.findField("single_int32")).isPresent(); - Truth8.assertThat(protoType.findField("single_enum")).isPresent(); - Truth8.assertThat(protoType.findField("single_nested_test_all_types")).isPresent(); - Truth8.assertThat(protoType.findField("nestedgroup")).isPresent(); - Truth8.assertThat(protoType.findField("nested_ext")).isEmpty(); + assertThat(protoType.findField("single_int32")).isPresent(); + assertThat(protoType.findField("single_enum")).isPresent(); + assertThat(protoType.findField("single_nested_test_all_types")).isPresent(); + assertThat(protoType.findField("nestedgroup")).isPresent(); + assertThat(protoType.findField("nested_ext")).isEmpty(); - Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.nested_ext")) + assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.nested_ext")).isPresent(); + assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.int32_ext")).isPresent(); + assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.test_all_types_ext")) .isPresent(); - Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.int32_ext")) + assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) .isPresent(); - Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.test_all_types_ext")) - .isPresent(); - Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) - .isPresent(); - Truth8.assertThat( + assertThat( protoType.findExtension("dev.cel.testing.testdata.proto2.repeated_string_holder_ext")) .isPresent(); - Truth8.assertThat( - protoType.findExtension("dev.cel.testing.testdata.proto2.Proto2Message.int32_ext")) + assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.Proto2Message.int32_ext")) .isEmpty(); Optional<CelType> holderType = proto2Provider.findType("dev.cel.testing.testdata.proto2.StringHolder"); - Truth8.assertThat(holderType).isPresent(); + assertThat(holderType).isPresent(); ProtoMessageType stringHolderType = (ProtoMessageType) holderType.get(); - Truth8.assertThat( - stringHolderType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) + assertThat(stringHolderType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) .isEmpty(); } @@ -150,24 +145,24 @@ public void findType_globalMessageWithExtensions() { public void findType_scopedMessageWithExtensions() { Optional<CelType> celType = proto2Provider.findType("dev.cel.testing.testdata.proto2.Proto2Message"); - Truth8.assertThat(celType).isPresent(); + assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); - Truth8.assertThat( + assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext")) .isPresent(); - Truth8.assertThat( + assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.int64_ext")) .isPresent(); - Truth8.assertThat( + assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.string_ext")) .isPresent(); - Truth8.assertThat( + assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.nested_message_inside_ext")) .isPresent(); @@ -177,11 +172,11 @@ public void findType_scopedMessageWithExtensions() { public void findType_withRepeatedEnumField() { Optional<CelType> celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes"); - Truth8.assertThat(celType).isPresent(); + assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto3.TestAllTypes"); - Truth8.assertThat(protoType.findField("repeated_nested_enum")).isPresent(); + assertThat(protoType.findField("repeated_nested_enum")).isPresent(); CelType fieldType = protoType.findField("repeated_nested_enum").get().type(); assertThat(fieldType.kind()).isEqualTo(CelKind.LIST); @@ -191,8 +186,7 @@ public void findType_withRepeatedEnumField() { .isEqualTo("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum"); assertThat(elemType.kind()).isEqualTo(CelKind.INT); assertThat(elemType).isInstanceOf(EnumType.class); - Truth8.assertThat( - proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum")) + assertThat(proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum")) .hasValue(elemType); } @@ -202,7 +196,7 @@ public void findType_withOneofField() { proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes"); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto3.TestAllTypes"); - Truth8.assertThat(protoType.findField("single_nested_message").map(f -> f.type().name())) + assertThat(protoType.findField("single_nested_message").map(f -> f.type().name())) .hasValue("dev.cel.testing.testdata.proto3.TestAllTypes.NestedMessage"); } @@ -228,35 +222,33 @@ public void findType_withWellKnownTypes() { Optional<CelType> celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes"); ProtoMessageType protoType = (ProtoMessageType) celType.get(); - Truth8.assertThat(protoType.findField("single_any").map(f -> f.type())) - .hasValue(SimpleType.ANY); - Truth8.assertThat(protoType.findField("single_duration").map(f -> f.type())) + assertThat(protoType.findField("single_any").map(f -> f.type())).hasValue(SimpleType.ANY); + assertThat(protoType.findField("single_duration").map(f -> f.type())) .hasValue(SimpleType.DURATION); - Truth8.assertThat(protoType.findField("single_timestamp").map(f -> f.type())) + assertThat(protoType.findField("single_timestamp").map(f -> f.type())) .hasValue(SimpleType.TIMESTAMP); - Truth8.assertThat(protoType.findField("single_value").map(f -> f.type())) - .hasValue(SimpleType.DYN); - Truth8.assertThat(protoType.findField("single_list_value").map(f -> f.type())) + assertThat(protoType.findField("single_value").map(f -> f.type())).hasValue(SimpleType.DYN); + assertThat(protoType.findField("single_list_value").map(f -> f.type())) .hasValue(ListType.create(SimpleType.DYN)); - Truth8.assertThat(protoType.findField("single_struct").map(f -> f.type())) + assertThat(protoType.findField("single_struct").map(f -> f.type())) .hasValue(MapType.create(SimpleType.STRING, SimpleType.DYN)); - Truth8.assertThat(protoType.findField("single_bool_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_bool_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.BOOL)); - Truth8.assertThat(protoType.findField("single_bytes_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_bytes_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.BYTES)); - Truth8.assertThat(protoType.findField("single_int32_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_int32_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.INT)); - Truth8.assertThat(protoType.findField("single_int64_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_int64_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.INT)); - Truth8.assertThat(protoType.findField("single_double_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_double_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.DOUBLE)); - Truth8.assertThat(protoType.findField("single_float_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_float_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.DOUBLE)); - Truth8.assertThat(protoType.findField("single_string_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_string_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.STRING)); - Truth8.assertThat(protoType.findField("single_uint32_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_uint32_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.UINT)); - Truth8.assertThat(protoType.findField("single_uint64_wrapper").map(f -> f.type())) + assertThat(protoType.findField("single_uint64_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.UINT)); } diff --git a/common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java b/common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java index 5e0c3a83..3feab06f 100644 --- a/common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java +++ b/common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java @@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.google.common.truth.Truth8; import java.util.Optional; import org.junit.Before; import org.junit.Test; @@ -53,7 +52,7 @@ public void setUp() { @Test public void findField() { for (String fieldName : FIELD_MAP.keySet()) { - Truth8.assertThat(testMessage.findField(fieldName)) + assertThat(testMessage.findField(fieldName)) .hasValue(StructType.Field.of(fieldName, FIELD_MAP.get(fieldName))); } } @@ -61,8 +60,8 @@ public void findField() { @Test public void withVisibleFields() { ProtoMessageType maskedMessage = testMessage.withVisibleFields(ImmutableSet.of("bool_value")); - Truth8.assertThat(maskedMessage.findField("int_value")).isEmpty(); - Truth8.assertThat(maskedMessage.findField("bool_value")).isPresent(); + assertThat(maskedMessage.findField("int_value")).isEmpty(); + assertThat(maskedMessage.findField("bool_value")).isPresent(); assertThat(maskedMessage.fields()).hasSize(1); assertThat(testMessage.fields()).hasSize(4); } @@ -70,7 +69,7 @@ public void withVisibleFields() { @Test public void findExtension() { for (String extName : EXTENSION_MAP.keySet()) { - Truth8.assertThat(testMessage.findExtension(extName)) + assertThat(testMessage.findExtension(extName)) .hasValue( ProtoMessageType.Extension.of(extName, EXTENSION_MAP.get(extName), testMessage)); } diff --git a/common/src/test/java/dev/cel/common/values/OptionalValueTest.java b/common/src/test/java/dev/cel/common/values/OptionalValueTest.java index c42b6522..6a991a6a 100644 --- a/common/src/test/java/dev/cel/common/values/OptionalValueTest.java +++ b/common/src/test/java/dev/cel/common/values/OptionalValueTest.java @@ -18,7 +18,6 @@ import static org.junit.Assert.assertThrows; import com.google.common.collect.ImmutableMap; -import com.google.common.truth.Truth8; import com.google.testing.junit.testparameterinjector.TestParameterInjector; import com.google.testing.junit.testparameterinjector.TestParameters; import dev.cel.common.types.CelType; @@ -133,7 +132,7 @@ public void findField_struct_success(String field, boolean expectedResult) { @Test public void findField_onEmptyOptional() { - Truth8.assertThat(OptionalValue.EMPTY.find(StringValue.create("bogus"))).isEmpty(); + assertThat(OptionalValue.EMPTY.find(StringValue.create("bogus"))).isEmpty(); } @Test diff --git a/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java b/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java index c1e518a9..32f89e7a 100644 --- a/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java +++ b/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.UnsignedLong; -import com.google.common.truth.Truth8; import com.google.protobuf.Any; import com.google.protobuf.ByteString; import com.google.protobuf.DynamicMessage; @@ -97,9 +96,9 @@ public void findField_fieldIsSet_fieldExists() { ProtoMessageValue.create( testAllTypes, DefaultDescriptorPool.INSTANCE, PROTO_CEL_VALUE_CONVERTER); - Truth8.assertThat(protoMessageValue.find(StringValue.create("single_bool"))).isPresent(); - Truth8.assertThat(protoMessageValue.find(StringValue.create("single_int64"))).isPresent(); - Truth8.assertThat(protoMessageValue.find(StringValue.create("repeated_int64"))).isPresent(); + assertThat(protoMessageValue.find(StringValue.create("single_bool"))).isPresent(); + assertThat(protoMessageValue.find(StringValue.create("single_int64"))).isPresent(); + assertThat(protoMessageValue.find(StringValue.create("repeated_int64"))).isPresent(); } @Test @@ -110,9 +109,9 @@ public void findField_fieldIsUnset_fieldDoesNotExist() { DefaultDescriptorPool.INSTANCE, PROTO_CEL_VALUE_CONVERTER); - Truth8.assertThat(protoMessageValue.find(StringValue.create("single_int32"))).isEmpty(); - Truth8.assertThat(protoMessageValue.find(StringValue.create("single_uint64"))).isEmpty(); - Truth8.assertThat(protoMessageValue.find(StringValue.create("repeated_int32"))).isEmpty(); + assertThat(protoMessageValue.find(StringValue.create("single_int32"))).isEmpty(); + assertThat(protoMessageValue.find(StringValue.create("single_uint64"))).isEmpty(); + assertThat(protoMessageValue.find(StringValue.create("repeated_int32"))).isEmpty(); } @Test @@ -151,7 +150,7 @@ public void findField_extensionField_success() { ProtoMessageValue protoMessageValue = ProtoMessageValue.create(proto2Message, descriptorPool, protoCelValueConverter); - Truth8.assertThat( + assertThat( protoMessageValue.find(StringValue.create("dev.cel.testing.testdata.proto2.int32_ext"))) .isPresent(); } diff --git a/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java b/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java index 2f837669..8cb7a11f 100644 --- a/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java +++ b/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java @@ -20,7 +20,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.primitives.UnsignedLong; -import com.google.common.truth.Truth8; import com.google.protobuf.ByteString; import com.google.protobuf.DoubleValue; import com.google.protobuf.NullValue; @@ -144,7 +143,7 @@ public void optionalType_adaptsIntegerToLong_success() throws Exception { Optional<Long> result = (Optional<Long>) cel.createProgram(ast).eval(ImmutableMap.of("a", Optional.of(5))); - Truth8.assertThat(result).hasValue(5L); + assertThat(result).hasValue(5L); } @Test @@ -155,7 +154,7 @@ public void optionalType_adaptsFloatToLong_success() throws Exception { Optional<Long> result = (Optional<Long>) cel.createProgram(ast).eval(ImmutableMap.of("a", Optional.of(5.5f))); - Truth8.assertThat(result).hasValue(5.5d); + assertThat(result).hasValue(5.5d); } @Test @@ -504,7 +503,7 @@ public void optionalFieldSelection_onMap_returnsOptionalValue() throws Exception Optional<Long> result = (Optional<Long>) cel.createProgram(ast).eval(); - Truth8.assertThat(result).hasValue(2L); + assertThat(result).hasValue(2L); } @Test @@ -520,7 +519,7 @@ public void optionalFieldSelection_onProtoMessage_returnsOptionalEmpty() throws (Optional<Long>) cel.createProgram(ast).eval(ImmutableMap.of("msg", TestAllTypes.getDefaultInstance())); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -537,7 +536,7 @@ public void optionalFieldSelection_onProtoMessage_returnsOptionalValue() throws cel.createProgram(ast) .eval(ImmutableMap.of("msg", TestAllTypes.newBuilder().setSingleInt32(5).build())); - Truth8.assertThat(result).hasValue(5L); + assertThat(result).hasValue(5L); } @Test @@ -568,7 +567,7 @@ public void optionalFieldSelection_onProtoMessage_chainedSuccess() throws Except "dashed-index", TestAllTypes.newBuilder().setSingleInt32(5).build())))); - Truth8.assertThat(result).hasValue(5L); + assertThat(result).hasValue(5L); } @Test @@ -1236,7 +1235,7 @@ public void optionalMapMacro_receiverIsEmpty_returnsOptionalEmpty() throws Excep Optional<?> result = (Optional<?>) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.empty())); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -1251,7 +1250,7 @@ public void optionalMapMacro_receiverHasValue_returnsOptionalValue() throws Exce Optional<?> result = (Optional<?>) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(42L))); - Truth8.assertThat(result).hasValue(43L); + assertThat(result).hasValue(43L); } @Test @@ -1281,7 +1280,7 @@ public void optionalFlatMapMacro_receiverIsEmpty_returnsOptionalEmpty() throws E Optional<?> result = (Optional<?>) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.empty())); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -1296,7 +1295,7 @@ public void optionalFlatMapMacro_receiverHasValue_returnsOptionalValue() throws Optional<?> result = (Optional<?>) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(42L))); - Truth8.assertThat(result).hasValue(43L); + assertThat(result).hasValue(43L); } @Test @@ -1313,7 +1312,7 @@ public void optionalFlatMapMacro_withOptionalOfNonZeroValue_optionalEmptyWhenVal Optional<?> result = (Optional<?>) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(1L))); - Truth8.assertThat(result).isEmpty(); + assertThat(result).isEmpty(); } @Test @@ -1330,7 +1329,7 @@ public void optionalFlatMapMacro_withOptionalOfNonZeroValue_optionalValueWhenVal Optional<?> result = (Optional<?>) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(1L))); - Truth8.assertThat(result).hasValue(2L); + assertThat(result).hasValue(2L); } @Test diff --git a/parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java b/parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java index 7898239f..0a66f26d 100644 --- a/parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java +++ b/parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java @@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat; import com.google.common.primitives.UnsignedLong; -import com.google.common.truth.Truth8; import com.google.protobuf.ByteString; import dev.cel.common.CelIssue; import dev.cel.common.CelSourceLocation; @@ -578,7 +577,7 @@ public void newGlobalCall_returnsGlobalCall() { CelExpr expr = exprFactory.newGlobalCall("foo", argument); assertThat(expr.id()).isEqualTo(2L); assertThat(expr.exprKind().getKind()).isEqualTo(Kind.CALL); - Truth8.assertThat(expr.call().target()).isEmpty(); + assertThat(expr.call().target()).isEmpty(); assertThat(expr.call().function()).isEqualTo("foo"); assertThat(expr.call().args()).containsExactly(argument); } @@ -591,7 +590,7 @@ public void newReceiverCall_returnsReceiverCall() { CelExpr expr = exprFactory.newReceiverCall("foo", target, argument); assertThat(expr.id()).isEqualTo(3L); assertThat(expr.exprKind().getKind()).isEqualTo(Kind.CALL); - Truth8.assertThat(expr.call().target()).hasValue(target); + assertThat(expr.call().target()).hasValue(target); assertThat(expr.call().function()).isEqualTo("foo"); assertThat(expr.call().args()).containsExactly(argument); } diff --git a/parser/src/test/java/dev/cel/parser/CelParserImplTest.java b/parser/src/test/java/dev/cel/parser/CelParserImplTest.java index 28794249..7c01c361 100644 --- a/parser/src/test/java/dev/cel/parser/CelParserImplTest.java +++ b/parser/src/test/java/dev/cel/parser/CelParserImplTest.java @@ -17,7 +17,6 @@ import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertThrows; -import com.google.common.truth.Truth8; import com.google.testing.junit.testparameterinjector.TestParameter; import com.google.testing.junit.testparameterinjector.TestParameterInjector; import com.google.testing.junit.testparameterinjector.TestParameters; @@ -42,20 +41,15 @@ public void build_withMacros_containsAllMacros() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.STANDARD_MACROS).build(); - Truth8.assertThat(parser.findMacro("has:1:false")) - .hasValue(CelStandardMacro.HAS.getDefinition()); - Truth8.assertThat(parser.findMacro("all:2:true")) - .hasValue(CelStandardMacro.ALL.getDefinition()); - Truth8.assertThat(parser.findMacro("exists:2:true")) - .hasValue(CelStandardMacro.EXISTS.getDefinition()); - Truth8.assertThat(parser.findMacro("exists_one:2:true")) + assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); + assertThat(parser.findMacro("all:2:true")).hasValue(CelStandardMacro.ALL.getDefinition()); + assertThat(parser.findMacro("exists:2:true")).hasValue(CelStandardMacro.EXISTS.getDefinition()); + assertThat(parser.findMacro("exists_one:2:true")) .hasValue(CelStandardMacro.EXISTS_ONE.getDefinition()); - Truth8.assertThat(parser.findMacro("map:2:true")) - .hasValue(CelStandardMacro.MAP.getDefinition()); - Truth8.assertThat(parser.findMacro("map:3:true")) + assertThat(parser.findMacro("map:2:true")).hasValue(CelStandardMacro.MAP.getDefinition()); + assertThat(parser.findMacro("map:3:true")) .hasValue(CelStandardMacro.MAP_FILTER.getDefinition()); - Truth8.assertThat(parser.findMacro("filter:2:true")) - .hasValue(CelStandardMacro.FILTER.getDefinition()); + assertThat(parser.findMacro("filter:2:true")).hasValue(CelStandardMacro.FILTER.getDefinition()); } @Test @@ -63,20 +57,15 @@ public void build_withStandardMacros_containsAllMacros() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.STANDARD_MACROS).build(); - Truth8.assertThat(parser.findMacro("has:1:false")) - .hasValue(CelStandardMacro.HAS.getDefinition()); - Truth8.assertThat(parser.findMacro("all:2:true")) - .hasValue(CelStandardMacro.ALL.getDefinition()); - Truth8.assertThat(parser.findMacro("exists:2:true")) - .hasValue(CelStandardMacro.EXISTS.getDefinition()); - Truth8.assertThat(parser.findMacro("exists_one:2:true")) + assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); + assertThat(parser.findMacro("all:2:true")).hasValue(CelStandardMacro.ALL.getDefinition()); + assertThat(parser.findMacro("exists:2:true")).hasValue(CelStandardMacro.EXISTS.getDefinition()); + assertThat(parser.findMacro("exists_one:2:true")) .hasValue(CelStandardMacro.EXISTS_ONE.getDefinition()); - Truth8.assertThat(parser.findMacro("map:2:true")) - .hasValue(CelStandardMacro.MAP.getDefinition()); - Truth8.assertThat(parser.findMacro("map:3:true")) + assertThat(parser.findMacro("map:2:true")).hasValue(CelStandardMacro.MAP.getDefinition()); + assertThat(parser.findMacro("map:3:true")) .hasValue(CelStandardMacro.MAP_FILTER.getDefinition()); - Truth8.assertThat(parser.findMacro("filter:2:true")) - .hasValue(CelStandardMacro.FILTER.getDefinition()); + assertThat(parser.findMacro("filter:2:true")).hasValue(CelStandardMacro.FILTER.getDefinition()); } @Test @@ -91,37 +80,30 @@ public void build_withStandardMacrosAndCustomMacros_containsAllMacros() { .addMacros(customMacro) .build(); - Truth8.assertThat(parser.findMacro("has:1:false")) - .hasValue(CelStandardMacro.HAS.getDefinition()); - Truth8.assertThat(parser.findMacro("all:2:true")) - .hasValue(CelStandardMacro.ALL.getDefinition()); - Truth8.assertThat(parser.findMacro("exists:2:true")) - .hasValue(CelStandardMacro.EXISTS.getDefinition()); - Truth8.assertThat(parser.findMacro("exists_one:2:true")) + assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); + assertThat(parser.findMacro("all:2:true")).hasValue(CelStandardMacro.ALL.getDefinition()); + assertThat(parser.findMacro("exists:2:true")).hasValue(CelStandardMacro.EXISTS.getDefinition()); + assertThat(parser.findMacro("exists_one:2:true")) .hasValue(CelStandardMacro.EXISTS_ONE.getDefinition()); - Truth8.assertThat(parser.findMacro("map:2:true")) - .hasValue(CelStandardMacro.MAP.getDefinition()); - Truth8.assertThat(parser.findMacro("map:3:true")) + assertThat(parser.findMacro("map:2:true")).hasValue(CelStandardMacro.MAP.getDefinition()); + assertThat(parser.findMacro("map:3:true")) .hasValue(CelStandardMacro.MAP_FILTER.getDefinition()); - Truth8.assertThat(parser.findMacro("filter:2:true")) - .hasValue(CelStandardMacro.FILTER.getDefinition()); - Truth8.assertThat(parser.findMacro("customMacro:1:true")).hasValue(customMacro); + assertThat(parser.findMacro("filter:2:true")).hasValue(CelStandardMacro.FILTER.getDefinition()); + assertThat(parser.findMacro("customMacro:1:true")).hasValue(customMacro); } @Test public void build_withMacro_containsMacro() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.HAS).build(); - Truth8.assertThat(parser.findMacro("has:1:false")) - .hasValue(CelStandardMacro.HAS.getDefinition()); + assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); } @Test public void build_withStandardMacro_containsMacro() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.HAS).build(); - Truth8.assertThat(parser.findMacro("has:1:false")) - .hasValue(CelStandardMacro.HAS.getDefinition()); + assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); } @Test @@ -133,9 +115,8 @@ public void build_withStandardMacro_secondCallReplaces() { .setStandardMacros(CelStandardMacro.HAS) .build(); - Truth8.assertThat(parser.findMacro("has:1:false")) - .hasValue(CelStandardMacro.HAS.getDefinition()); - Truth8.assertThat(parser.findMacro("all:2:true")).isEmpty(); + assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); + assertThat(parser.findMacro("all:2:true")).isEmpty(); } @Test @@ -155,7 +136,7 @@ public void build_standardMacroKeyConflictsWithCustomMacro_throws() { @Test public void build_containsNoMacros() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().build(); - Truth8.assertThat(parser.findMacro("has:1:false")).isEmpty(); + assertThat(parser.findMacro("has:1:false")).isEmpty(); } @Test @@ -175,7 +156,7 @@ public void setParserOptions(CelParserBuilder parserBuilder) { }) .build(); - Truth8.assertThat(parser.findMacro("dummyMacro:*:true")).isPresent(); + assertThat(parser.findMacro("dummyMacro:*:true")).isPresent(); } @Test diff --git a/runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java b/runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java index 8d0c35d9..428fa6b2 100644 --- a/runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java +++ b/runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java @@ -18,7 +18,6 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; -import com.google.common.truth.Truth8; import java.util.Optional; import org.junit.Test; import org.junit.runner.RunWith; @@ -33,8 +32,7 @@ public void create_variableResolverOnly() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - Truth8.assertThat(attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("test"))) - .isEmpty(); + assertThat(attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("test"))).isEmpty(); assertThat(context.variableResolver().resolve("test")).isEqualTo("test_value"); } @@ -49,16 +47,16 @@ public void create_attributeResolverResolvesUnknown() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - Truth8.assertThat( + assertThat( attributeResolver.resolve( CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))); - Truth8.assertThat( + assertThat( attributeResolver.resolve( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))) .isEmpty(); - Truth8.assertThat( + assertThat( attributeResolver.resolve( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2.field1"))) .hasValue( @@ -77,17 +75,17 @@ public void create_attributeResolverIdentifiesPartials() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2.field1"))) .hasValue( @@ -106,17 +104,17 @@ public void withResolvedAttributes_attributeResolverReturnsValue() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2.field1"))) .hasValue( @@ -136,7 +134,7 @@ public void withResolvedAttributes_attributeResolverResolves() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - Truth8.assertThat( + assertThat( attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("qualified.Identifier"))) .hasValue("value1"); } @@ -157,14 +155,14 @@ public void withResolvedAttributes_attributeResolverPartialsShadowed() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - Truth8.assertThat( + assertThat( attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("qualified.Identifier"))) .hasValue("value1"); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier.field1"))) .isEmpty(); - Truth8.assertThat( + assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier.field2"))) .isEmpty();