diff --git a/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java b/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java index 424d8345..1d131eb8 100644 --- a/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java +++ b/checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java @@ -15,7 +15,6 @@ package dev.cel.checker; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; import dev.cel.expr.Constant; @@ -23,6 +22,7 @@ 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 +45,7 @@ public void celIdentBuilder_success() { assertThat(stringIdent.name()).isEqualTo("ident"); assertThat(stringIdent.type()).isEqualTo(SimpleType.STRING); assertThat(stringIdent.doc()).isEqualTo("doc"); - assertThat(stringIdent.constant()).hasValue(CelConstant.ofValue("str")); + Truth8.assertThat(stringIdent.constant()).hasValue(CelConstant.ofValue("str")); } @Test @@ -58,7 +58,7 @@ public void celIdentBuilder_clearConstant() { builder.clearConstant(); - assertThat(builder.build().constant()).isEmpty(); + Truth8.assertThat(builder.build().constant()).isEmpty(); } @Test @@ -68,7 +68,7 @@ public void newIdentDeclaration_success() { assertThat(intIdent.name()).isEqualTo("ident"); assertThat(intIdent.type()).isEqualTo(SimpleType.INT); assertThat(intIdent.doc()).isEmpty(); - assertThat(intIdent.constant()).isEmpty(); + Truth8.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 a2a9f88e..79269e47 100644 --- a/checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java +++ b/checker/src/test/java/dev/cel/checker/ProtoTypeMaskTypeProviderTest.java @@ -17,11 +17,11 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.collect.ImmutableSet.toImmutableSet; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.assertThrows; 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 +64,7 @@ public void lookupFieldNames_undeclaredMessageType() { CelTypeProvider celTypeProvider = new ProtoMessageTypeProvider(); ProtoTypeMaskTypeProvider protoTypeMaskProvider = new ProtoTypeMaskTypeProvider(celTypeProvider, ImmutableList.of()); - assertThat(protoTypeMaskProvider.findType(ATTRIBUTE_CONTEXT_TYPE)).isEmpty(); + Truth8.assertThat(protoTypeMaskProvider.findType(ATTRIBUTE_CONTEXT_TYPE)).isEmpty(); } @Test @@ -206,7 +206,7 @@ public void lookupFieldType() { .addPaths("request.auth.*") .build()))); ProtoMessageType ctxType = assertTypeFound(protoTypeMaskProvider, ATTRIBUTE_CONTEXT_TYPE); - assertThat(ctxType.findField("resource")).isPresent(); + Truth8.assertThat(ctxType.findField("resource")).isPresent(); assertTypeHasFieldWithType(ctxType, "resource", RESOURCE_TYPE); assertTypeHasFieldWithType(ctxType, "request", REQUEST_TYPE); @@ -238,7 +238,7 @@ public void lookupFieldType_notExposedField() { "google.rpc.context.AttributeContext", FieldMask.newBuilder().addPaths("resource.name").build()))); ProtoMessageType resourceType = assertTypeFound(protoTypeMaskProvider, RESOURCE_TYPE); - assertThat(resourceType.findField("type")).isEmpty(); + Truth8.assertThat(resourceType.findField("type")).isEmpty(); } @Test @@ -252,12 +252,12 @@ public void lookupType_notExposed() { ProtoTypeMask.of( "google.rpc.context.AttributeContext", FieldMask.newBuilder().addPaths("resource.name").build()))); - assertThat(protoTypeMaskProvider.findType(REQUEST_TYPE)).isPresent(); + Truth8.assertThat(protoTypeMaskProvider.findType(REQUEST_TYPE)).isPresent(); } private ProtoMessageType assertTypeFound(CelTypeProvider celTypeProvider, String typeName) { Optional foundType = celTypeProvider.findType(typeName); - assertThat(foundType).isPresent(); + Truth8.assertThat(foundType).isPresent(); CelType celType = foundType.get(); assertThat(celType).isInstanceOf(ProtoMessageType.class); return (ProtoMessageType) celType; @@ -271,7 +271,7 @@ private void assertTypeHasFields(ProtoMessageType protoType, ImmutableSet result = inferencer.unify(mapInst, mapParamFresh); - assertThat(result).isPresent(); + Truth8.assertThat(result).isPresent(); assertThat(result.get().substitutions()) .containsExactly( mapParamFresh.keyType().name(), @@ -86,8 +86,8 @@ public void unify_success_parameterizedMapReversedArgs() { MapType mapInst = MapType.create(SimpleType.STRING, ListType.create(TypeParamType.create("V"))); MapType mapParamFresh = (MapType) mapParam.withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(mapParamFresh, mapInst); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(mapInst); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(mapInst); assertThat(result.get().substitutions()) .containsExactly( mapParamFresh.keyType().name(), @@ -103,12 +103,12 @@ public void unify_success_jsonEqualsDoubleOneByOne() { TypeParamType equalsArg = TypeParamType.create("T"); CelType equalsArgFresh = equalsArg.withFreshTypeParamVariables(typeVarGenerator); Optional firstArg = inferencer.unify(JsonType.JSON, equalsArgFresh); - assertThat(firstArg).isPresent(); - assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(firstArg).isPresent(); + Truth8.assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); inferencer.recordSubstitutions(firstArg.get().substitutions()); Optional secondArg = inferencer.unify(SimpleType.DOUBLE, equalsArgFresh); - assertThat(secondArg).isPresent(); - assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(secondArg).isPresent(); + Truth8.assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); inferencer.recordSubstitutions(secondArg.get().substitutions()); assertThat(inferencer.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -118,12 +118,12 @@ public void unify_success_jsonEqualsDoubleOneByOneDifferentInferencer() { TypeParamType equalsArg = TypeParamType.create("T"); CelType equalsArgFresh = equalsArg.withFreshTypeParamVariables(typeVarGenerator); Optional firstArg = inferencer.unify(JsonType.JSON, equalsArgFresh); - assertThat(firstArg).isPresent(); - assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(firstArg).isPresent(); + Truth8.assertThat(firstArg.get().unifiedType()).hasValue(JsonType.JSON); TypeInferencer inferencer2 = new TypeInferencer(UNION_TYPES, firstArg.get().substitutions()); Optional secondArg = inferencer2.unify(SimpleType.DOUBLE, equalsArgFresh); - assertThat(secondArg).isPresent(); - assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(secondArg).isPresent(); + Truth8.assertThat(secondArg.get().unifiedType()).hasValue(JsonType.JSON); inferencer2.recordSubstitutions(secondArg.get().substitutions()); assertThat(inferencer2.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -131,15 +131,15 @@ public void unify_success_jsonEqualsDoubleOneByOneDifferentInferencer() { @Test public void unify_success_jsonToDouble() { Optional result = inferencer.unify(JsonType.JSON, SimpleType.DOUBLE); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); } @Test public void unify_success_doubleToJson() { Optional result = inferencer.unify(SimpleType.DOUBLE, JsonType.JSON); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); } @Test @@ -147,14 +147,14 @@ public void unify_false_nestedTypeParamReference() { TypeParamType typeParamArg = TypeParamType.create("T"); ListType listType = ListType.create(typeParamArg); Optional result = inferencer.unify(typeParamArg, listType); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test public void unify_success_dynOrErrorYieldsError() { Optional result = inferencer.unify(SimpleType.DYN, SimpleType.ERROR); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(SimpleType.ERROR); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(SimpleType.ERROR); } @Test @@ -162,8 +162,8 @@ public void unify_success_doubleNullToNullableDoubleWithTypeParam() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(NullableType.create(SimpleType.DOUBLE)); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(NullableType.create(SimpleType.DOUBLE)); } @Test @@ -171,8 +171,8 @@ public void unify_success_doubleNullToNullableDoubleWithConcreteType() { CelType outputType = NullableType.create(SimpleType.DOUBLE); Optional result = inferencer.unify(ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(outputType); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(outputType); } @Test @@ -182,8 +182,8 @@ public void unify_success_doubleNullStringToJson() { inferencer.unify( ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE, SimpleType.STRING), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(JsonType.JSON); } @Test @@ -194,8 +194,8 @@ public void unify_success_doubleNullStringToDyn() { inferencer.unify( ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE, SimpleType.STRING), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(SimpleType.DYN); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(SimpleType.DYN); } @Test @@ -206,7 +206,7 @@ public void unify_false_doubleNullStringNoJsonNoTopType() { inferencer.unify( ImmutableList.of(SimpleType.DOUBLE, SimpleType.NULL_TYPE, SimpleType.STRING), outputType); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -216,8 +216,8 @@ public void unify_success_abstractTypeListToJsonParam() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); } @Test @@ -229,8 +229,8 @@ public void unify_success_abstractTypeMapToMapJsonParam() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()) + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()) .hasValue(OpaqueType.create("set", MapType.create(SimpleType.STRING, JsonType.JSON))); } @@ -242,8 +242,8 @@ public void unify_success_abstractTypeMapToJsonParam() { CelType outputType = TypeParamType.create("0").withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", JsonType.JSON)); } @Test @@ -258,8 +258,9 @@ public void unify_success_opaqueTypeMapToDynParam() { // to enter into the type resolution. Optional result = inferencer.unify(ImmutableList.of(setListDouble, setString), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", SimpleType.DYN)); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()) + .hasValue(OpaqueType.create("set", SimpleType.DYN)); } @Test @@ -269,8 +270,9 @@ public void unify_success_jsonIntSetsToDynSet() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(ImmutableList.of(setJson, setInt), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(OpaqueType.create("set", SimpleType.DYN)); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()) + .hasValue(OpaqueType.create("set", SimpleType.DYN)); } @Test @@ -281,35 +283,35 @@ public void unify_success_nullableStruct() { CelType outputType = TypeParamType.create("O").withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(ImmutableList.of(nullableStructType, structType), outputType); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(nullableStructType); + Truth8.assertThat(result).isPresent(); + Truth8.assertThat(result.get().unifiedType()).hasValue(nullableStructType); } @Test public void unify_false_differentKinds() { OpaqueType vectorType = OpaqueType.create("vector", SimpleType.STRING); - assertThat(inferencer.unify(JsonType.JSON, vectorType)).isEmpty(); + Truth8.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); - assertThat(inferencer.unify(setType, vectorType)).isEmpty(); + Truth8.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); - assertThat(inferencer.unify(setType, vectorType)).isEmpty(); + Truth8.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); - assertThat(inferencer.unify(setType, vectorType)).isEmpty(); + Truth8.assertThat(inferencer.unify(setType, vectorType)).isEmpty(); } @Test @@ -321,7 +323,7 @@ public void isAssignable_success_jsonSelect() { inferencer.isAssignable( ImmutableList.of(mapInst, SimpleType.STRING), ImmutableList.of(mapParamFresh, mapParamFresh.keyType())); - assertThat(result).isPresent(); + Truth8.assertThat(result).isPresent(); assertThat(result.get()) .containsExactly( mapParamFresh.keyType().name(), @@ -340,7 +342,7 @@ public void isAssignable_success_jsonEqualsDoubleAsList() { inferencer.isAssignable( ImmutableList.of(JsonType.JSON, SimpleType.DOUBLE), ImmutableList.of(equalsArgFresh, equalsArgFresh)); - assertThat(result).isPresent(); + Truth8.assertThat(result).isPresent(); inferencer.recordSubstitutions(result.get()); assertThat(inferencer.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -353,7 +355,7 @@ public void isAssignable_success_doubleEqualsJsonAsList() { inferencer.isAssignable( ImmutableList.of(SimpleType.DOUBLE, JsonType.JSON), ImmutableList.of(equalsArgFresh, equalsArgFresh)); - assertThat(result).isPresent(); + Truth8.assertThat(result).isPresent(); inferencer.recordSubstitutions(result.get()); assertThat(inferencer.specialize(equalsArgFresh)).isEqualTo(JsonType.JSON); } @@ -366,7 +368,7 @@ public void isAssignable_false_doubleEqualsString() { inferencer.isAssignable( ImmutableList.of(SimpleType.DOUBLE, SimpleType.STRING), ImmutableList.of(equalsArgFresh, equalsArgFresh)); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -375,7 +377,7 @@ public void isAssignable_false_sameTypeDifferentParameterCounts() { OpaqueType setType2 = OpaqueType.create("set", SimpleType.STRING, SimpleType.INT); Optional> result = inferencer.isAssignable(setType.parameters(), setType2.parameters()); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -387,8 +389,8 @@ public void finalize_success_typeFinalize() { CelType typeOfTypeWithFreshVars = typeOfType.withFreshTypeParamVariables(typeVarGenerator); Optional result = inferencer.unify(typeOfStructType, typeOfTypeWithFreshVars); - assertThat(result).isPresent(); - assertThat(result.get().unifiedType()).hasValue(typeOfStructType); + Truth8.assertThat(result).isPresent(); + Truth8.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 03e1a561..960ba664 100644 --- a/common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java +++ b/common/src/test/java/dev/cel/common/CelAbstractSyntaxTreeTest.java @@ -15,7 +15,6 @@ package dev.cel.common; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat; import dev.cel.expr.CheckedExpr; @@ -27,6 +26,7 @@ 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 +107,9 @@ public void getResultType_isStaticWhenCheckedExpr() { @Test public void findEnumValue_findsConstantInCheckedExpr() { CelAbstractSyntaxTree ast = CHECKED_ENUM_AST; - assertThat(ast.findEnumValue(1)).isEmpty(); - assertThat(ast.findEnumValue(2)).hasValue(CelConstant.ofValue(2)); - assertThat(ast.findEnumValue(3)).isEmpty(); + Truth8.assertThat(ast.findEnumValue(1)).isEmpty(); + Truth8.assertThat(ast.findEnumValue(2)).hasValue(CelConstant.ofValue(2)); + Truth8.assertThat(ast.findEnumValue(3)).isEmpty(); } @Test @@ -118,17 +118,17 @@ public void findEnumValue_doesNotFindConstantInParsedExpr() { CelAbstractSyntaxTree.newParsedAst( CHECKED_ENUM_AST.getExpr(), CHECKED_ENUM_AST.getSource()); - assertThat(ast.findEnumValue(1)).isEmpty(); - assertThat(ast.findEnumValue(2)).isEmpty(); - assertThat(ast.findEnumValue(3)).isEmpty(); + Truth8.assertThat(ast.findEnumValue(1)).isEmpty(); + Truth8.assertThat(ast.findEnumValue(2)).isEmpty(); + Truth8.assertThat(ast.findEnumValue(3)).isEmpty(); } @Test public void findOverloadIDs_findsOverloadsInCheckedExpr() { CelAbstractSyntaxTree ast = CHECKED_ENUM_AST; - assertThat(ast.findOverloadIDs(1)).isEmpty(); - assertThat(ast.findOverloadIDs(2)).isEmpty(); - assertThat(ast.findOverloadIDs(3)).hasValue(ImmutableList.of("not_equals")); + Truth8.assertThat(ast.findOverloadIDs(1)).isEmpty(); + Truth8.assertThat(ast.findOverloadIDs(2)).isEmpty(); + Truth8.assertThat(ast.findOverloadIDs(3)).hasValue(ImmutableList.of("not_equals")); } @Test @@ -137,9 +137,9 @@ public void findOverloadIDs_doesNotFindsOverloadsInParsedExpr() { CelAbstractSyntaxTree.newParsedAst( CHECKED_ENUM_AST.getExpr(), CHECKED_ENUM_AST.getSource()); - assertThat(ast.findOverloadIDs(1)).isEmpty(); - assertThat(ast.findOverloadIDs(2)).isEmpty(); - assertThat(ast.findOverloadIDs(3)).isEmpty(); + Truth8.assertThat(ast.findOverloadIDs(1)).isEmpty(); + Truth8.assertThat(ast.findOverloadIDs(2)).isEmpty(); + Truth8.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 5fc14fa0..e7b2aaf0 100644 --- a/common/src/test/java/dev/cel/common/CelSourceTest.java +++ b/common/src/test/java/dev/cel/common/CelSourceTest.java @@ -15,10 +15,10 @@ package dev.cel.common; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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.internal.BasicCodePointArray; import dev.cel.common.internal.CodePointStream; import dev.cel.common.internal.Latin1CodePointArray; @@ -44,13 +44,13 @@ public final class CelSourceTest { @Test public void getLocationOffset_correctStartingLocation() throws Exception { CelSource source = CelSource.newBuilder(LATIN_1_EXPR).build(); - assertThat(source.getLocationOffset(CelSourceLocation.of(1, 0))).hasValue(0); + Truth8.assertThat(source.getLocationOffset(CelSourceLocation.of(1, 0))).hasValue(0); } @Test public void getOffsetLocation_correctStartingLocation() throws Exception { CelSource source = CelSource.newBuilder(LATIN_1_EXPR).build(); - assertThat(source.getOffsetLocation(0)).hasValue(CelSourceLocation.of(1, 0)); + Truth8.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 ce8df4d7..5443266b 100644 --- a/common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java +++ b/common/src/test/java/dev/cel/common/ast/CelExprVisitorTest.java @@ -15,11 +15,11 @@ package dev.cel.common.ast; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.assertThrows; 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 +346,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); - assertThat(visitedReference.identifier()) + Truth8.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 0eb73e4c..79395c55 100644 --- a/common/src/test/java/dev/cel/common/ast/CelReferenceTest.java +++ b/common/src/test/java/dev/cel/common/ast/CelReferenceTest.java @@ -15,10 +15,10 @@ package dev.cel.common.ast; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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 +32,7 @@ public void constructCelReference_withEmptyArguments() { assertThat(reference.name()).isEqualTo("refName"); assertThat(reference.overloadIds()).isEmpty(); - assertThat(reference.value()).isEmpty(); + Truth8.assertThat(reference.value()).isEmpty(); } @Test @@ -42,7 +42,7 @@ public void constructCelReference_withOverloadIds() { assertThat(reference.name()).isEqualTo("refName"); assertThat(reference.overloadIds()).containsExactly("a", "b", "c"); - assertThat(reference.value()).isEmpty(); + Truth8.assertThat(reference.value()).isEmpty(); } @Test @@ -52,7 +52,7 @@ public void constructCelReference_withValue() { assertThat(reference.name()).isEqualTo("refName"); assertThat(reference.overloadIds()).isEmpty(); - assertThat(reference.value()).hasValue(CelConstant.ofValue(10)); + Truth8.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 07f33fc8..d232ac24 100644 --- a/common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java +++ b/common/src/test/java/dev/cel/common/internal/CombinedDescriptorPoolTest.java @@ -15,9 +15,9 @@ package dev.cel.common.internal; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.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,10 +43,11 @@ public void findDescriptor_descriptorReturnedFromBothPool() { CombinedDescriptorPool.create( ImmutableList.of(DefaultDescriptorPool.INSTANCE, dynamicDescriptorPool)); - assertThat(combinedDescriptorPool.findDescriptor(Value.getDescriptor().getFullName())) + Truth8.assertThat(combinedDescriptorPool.findDescriptor(Value.getDescriptor().getFullName())) .hasValue( Value.getDescriptor()); // Retrieved from default descriptor pool (well-known-type) - assertThat(combinedDescriptorPool.findDescriptor(TestAllTypes.getDescriptor().getFullName())) + Truth8.assertThat( + combinedDescriptorPool.findDescriptor(TestAllTypes.getDescriptor().getFullName())) .hasValue(TestAllTypes.getDescriptor()); // Retrieved from the dynamic descriptor pool. } @@ -60,7 +61,7 @@ public void findDescriptor_returnsEmpty() { CombinedDescriptorPool.create( ImmutableList.of(DefaultDescriptorPool.INSTANCE, descriptorPool)); - assertThat(combinedDescriptorPool.findDescriptor("bogus")).isEmpty(); + Truth8.assertThat(combinedDescriptorPool.findDescriptor("bogus")).isEmpty(); } @Test @@ -77,7 +78,7 @@ public void findExtensionDescriptor_success() { combinedDescriptorPool.findExtensionDescriptor( Proto2Message.getDescriptor(), "dev.cel.testing.testdata.proto2.test_all_types_ext"); - assertThat(fieldDescriptor).isPresent(); + Truth8.assertThat(fieldDescriptor).isPresent(); assertThat(fieldDescriptor.get().isExtension()).isTrue(); assertThat(fieldDescriptor.get().getFullName()) .isEqualTo("dev.cel.testing.testdata.proto2.test_all_types_ext"); @@ -93,7 +94,7 @@ public void findExtensionDescriptor_returnsEmpty() { CombinedDescriptorPool.create( ImmutableList.of(DefaultDescriptorPool.INSTANCE, dynamicDescriptorPool)); - assertThat( + Truth8.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 175adb12..0f24aafd 100644 --- a/common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java +++ b/common/src/test/java/dev/cel/common/internal/DefaultInstanceMessageFactoryTest.java @@ -16,10 +16,10 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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 +95,7 @@ public void getPrototype_success(@TestParameter PrototypeDescriptorTestCase test Optional defaultMessage = DefaultInstanceMessageFactory.getInstance().getPrototype(descriptor); - assertThat(defaultMessage).hasValue(testCase.defaultInstance); + Truth8.assertThat(defaultMessage).hasValue(testCase.defaultInstance); } @Test @@ -107,8 +107,8 @@ public void getPrototype_cached_success(@TestParameter PrototypeDescriptorTestCa Optional defaultMessage2 = DefaultInstanceMessageFactory.getInstance().getPrototype(descriptor); - assertThat(defaultMessage).hasValue(testCase.defaultInstance); - assertThat(defaultMessage2).hasValue(testCase.defaultInstance); + Truth8.assertThat(defaultMessage).hasValue(testCase.defaultInstance); + Truth8.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 593817d1..8d75652e 100644 --- a/common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java +++ b/common/src/test/java/dev/cel/common/internal/DefaultMessageFactoryTest.java @@ -15,13 +15,13 @@ package dev.cel.common.internal; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static java.nio.charset.StandardCharsets.UTF_8; import com.google.common.base.Ascii; 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 +70,7 @@ public void newBuilder_withDescriptor_producesNewMessageBuilder() { public void newBuilder_unknownMessage_returnsEmpty() { DefaultMessageFactory messageFactory = DefaultMessageFactory.INSTANCE; - assertThat(messageFactory.newBuilder("unknown_message")).isEmpty(); + Truth8.assertThat(messageFactory.newBuilder("unknown_message")).isEmpty(); } @Test @@ -85,7 +85,7 @@ public void newBuilder_unequalDescriptorForSameMessage_returnsDynamicMessage() t DefaultMessageFactory messageFactory = DefaultMessageFactory.create(DefaultDescriptorPool.create(celDescriptors)); - assertThat(messageFactory.newBuilder("google.api.expr.Value")).isPresent(); + Truth8.assertThat(messageFactory.newBuilder("google.api.expr.Value")).isPresent(); assertThat(messageFactory.newBuilder("google.api.expr.Value").get()) .isInstanceOf(DynamicMessage.Builder.class); } @@ -114,6 +114,6 @@ public void combinedMessageFactoryTest() { assertThat(messageFactory.newBuilder("test").get().build()) .isEqualTo(TestAllTypes.getDefaultInstance()); - assertThat(messageFactory.newBuilder("bogus")).isEmpty(); + Truth8.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 2b769071..0bdfed17 100644 --- a/common/src/test/java/dev/cel/common/internal/ErrorsTest.java +++ b/common/src/test/java/dev/cel/common/internal/ErrorsTest.java @@ -15,8 +15,8 @@ package dev.cel.common.internal; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; +import com.google.common.truth.Truth8; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.JUnit4; @@ -61,9 +61,9 @@ public void getPositionLocation() { @Test public void getSnippet() { Errors errors = new Errors("test", "hello\nworld\n"); - assertThat(errors.getSnippet(1)).hasValue("hello"); - assertThat(errors.getSnippet(2)).hasValue("world"); - assertThat(errors.getSnippet(3)).hasValue(""); - assertThat(errors.getSnippet(4)).isEmpty(); + 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(); } } 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 83795b55..118bd393 100644 --- a/common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java +++ b/common/src/test/java/dev/cel/common/internal/ProtoAdapterTest.java @@ -15,11 +15,11 @@ package dev.cel.common.internal; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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,7 +162,8 @@ public static List data() { public void adaptValueToProto_bidirectionalConversion() { DynamicProto dynamicProto = DynamicProto.create(DefaultMessageFactory.INSTANCE); ProtoAdapter protoAdapter = new ProtoAdapter(dynamicProto, options.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto(value, proto.getDescriptorForType().getFullName())) + Truth8.assertThat( + protoAdapter.adaptValueToProto(value, proto.getDescriptorForType().getFullName())) .hasValue(proto); assertThat(protoAdapter.adaptProtoToValue(proto)).isEqualTo(value); } @@ -181,7 +182,7 @@ public void adaptAnyValue_hermeticTypes_bidirectionalConversion() { ? Optional.of(Expr.newBuilder()) : Optional.empty()), LEGACY.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto(expr, Any.getDescriptor().getFullName())) + Truth8.assertThat(protoAdapter.adaptValueToProto(expr, Any.getDescriptor().getFullName())) .hasValue(Any.pack(expr)); assertThat(protoAdapter.adaptProtoToValue(Any.pack(expr))).isEqualTo(expr); } @@ -192,7 +193,7 @@ public static class AsymmetricConversionTest { @Test public void adaptValueToProto_asymmetricNullConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto(null, Any.getDescriptor().getFullName())) + Truth8.assertThat(protoAdapter.adaptValueToProto(null, Any.getDescriptor().getFullName())) .hasValue(Any.pack(Value.newBuilder().setNullValue(NullValue.NULL_VALUE).build())); assertThat( protoAdapter.adaptProtoToValue( @@ -203,7 +204,7 @@ public void adaptValueToProto_asymmetricNullConversion() { @Test public void adaptValueToProto_asymmetricFloatConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto(1.5F, Any.getDescriptor().getFullName())) + Truth8.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); } @@ -211,7 +212,8 @@ public void adaptValueToProto_asymmetricFloatConversion() { @Test public void adaptValueToProto_asymmetricDoubleFloatConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto(1.5D, FloatValue.getDescriptor().getFullName())) + Truth8.assertThat( + protoAdapter.adaptValueToProto(1.5D, FloatValue.getDescriptor().getFullName())) .hasValue(FloatValue.of(1.5F)); assertThat(protoAdapter.adaptProtoToValue(FloatValue.of(1.5F))).isEqualTo(1.5D); } @@ -219,27 +221,28 @@ public void adaptValueToProto_asymmetricDoubleFloatConversion() { @Test public void adaptValueToProto_asymmetricFloatDoubleConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto(1.5F, DoubleValue.getDescriptor().getFullName())) + Truth8.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()); - assertThat( + Truth8.assertThat( protoAdapter.adaptValueToProto( UnsignedLong.valueOf(1L), Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setNumberValue(1).build()); - assertThat( + Truth8.assertThat( protoAdapter.adaptValueToProto( UnsignedLong.fromLongBits(-1L), Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setStringValue(Long.toUnsignedString(-1L)).build()); - assertThat(protoAdapter.adaptValueToProto(1L, Value.getDescriptor().getFullName())) + Truth8.assertThat(protoAdapter.adaptValueToProto(1L, Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setNumberValue(1).build()); - assertThat( + Truth8.assertThat( protoAdapter.adaptValueToProto(Long.MAX_VALUE, Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setStringValue(Long.toString(Long.MAX_VALUE)).build()); - assertThat( + Truth8.assertThat( protoAdapter.adaptValueToProto( ByteString.copyFromUtf8("foo"), Value.getDescriptor().getFullName())) .hasValue(Value.newBuilder().setStringValue("Zm9v").build()); @@ -248,7 +251,7 @@ public void adaptValueToProto_asymmetricJsonConversion() { @Test public void adaptValueToProto_unsupportedJsonConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat( + Truth8.assertThat( protoAdapter.adaptValueToProto( ImmutableMap.of(1, 1), Any.getDescriptor().getFullName())) .isEmpty(); @@ -257,7 +260,7 @@ public void adaptValueToProto_unsupportedJsonConversion() { @Test public void adaptValueToProto_unsupportedJsonListConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat( + Truth8.assertThat( protoAdapter.adaptValueToProto( ImmutableMap.of(1, 1), ListValue.getDescriptor().getFullName())) .isEmpty(); @@ -266,7 +269,7 @@ public void adaptValueToProto_unsupportedJsonListConversion() { @Test public void adaptValueToProto_unsupportedConversion() { ProtoAdapter protoAdapter = new ProtoAdapter(DYNAMIC_PROTO, LEGACY.enableUnsignedLongs()); - assertThat(protoAdapter.adaptValueToProto("Hello", Expr.getDescriptor().getFullName())) + Truth8.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 e4d29309..2c595f0d 100644 --- a/common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java +++ b/common/src/test/java/dev/cel/common/navigation/CelNavigableAstTest.java @@ -15,8 +15,8 @@ package dev.cel.common.navigation; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.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 +39,7 @@ public void construct_success() throws Exception { assertThat(navigableAst.getAst()).isEqualTo(ast); assertThat(navigableAst.getRoot().expr()) .isEqualTo(CelExpr.ofConstantExpr(1, CelConstant.ofValue("Hello World"))); - assertThat(navigableAst.getRoot().parent()).isEmpty(); + Truth8.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 303fef42..b76da7a2 100644 --- a/common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java +++ b/common/src/test/java/dev/cel/common/navigation/CelNavigableExprTest.java @@ -15,8 +15,8 @@ package dev.cel.common.navigation; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.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 +34,7 @@ public void construct_withoutParent_success() { assertThat(navigableExpr.expr()).isEqualTo(constExpr); assertThat(navigableExpr.depth()).isEqualTo(2); - assertThat(navigableExpr.parent()).isEmpty(); + Truth8.assertThat(navigableExpr.parent()).isEmpty(); } @Test @@ -47,9 +47,9 @@ public void construct_withParent_success() { assertThat(parentExpr.expr()).isEqualTo(identExpr); assertThat(parentExpr.depth()).isEqualTo(1); - assertThat(parentExpr.parent()).isEmpty(); + Truth8.assertThat(parentExpr.parent()).isEmpty(); assertThat(navigableExpr.expr()).isEqualTo(constExpr); assertThat(navigableExpr.depth()).isEqualTo(2); - assertThat(navigableExpr.parent()).hasValue(parentExpr); + Truth8.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 a496a133..9aeefa6a 100644 --- a/common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java +++ b/common/src/test/java/dev/cel/common/navigation/CelNavigableExprVisitorTest.java @@ -16,13 +16,13 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static dev.cel.common.CelFunctionDecl.newFunctionDeclaration; import static dev.cel.common.CelOverloadDecl.newMemberOverload; import static org.junit.Assert.assertThrows; 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 +273,7 @@ public void stringFormatCall_filterList_success() throws Exception { assertThat(allConstants).hasSize(1); CelNavigableExpr listExpr = allConstants.get(0); assertThat(listExpr.getKind()).isEqualTo(Kind.CREATE_LIST); - assertThat(listExpr.parent()).isPresent(); + Truth8.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 +676,7 @@ public void comprehension_allNodes_parentsPopulated() throws Exception { CelExpr.ofComprehension( 13, "i", iterRange, "__result__", accuInit, loopCondition, loopStep, result); assertThat(allNodes).hasSize(11); - assertThat(allNodes.get(0).parent()).isEmpty(); // comprehension + Truth8.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 7efc2362..cb6f03d3 100644 --- a/common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java +++ b/common/src/test/java/dev/cel/common/types/ProtoMessageTypeProviderTest.java @@ -16,10 +16,10 @@ import static com.google.common.collect.ImmutableList.toImmutableList; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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 +49,7 @@ public void types_emptyTypeSet() { @Test public void findType_emptyTypeSet() { - assertThat(emptyProvider.findType("any")).isEmpty(); + Truth8.assertThat(emptyProvider.findType("any")).isEmpty(); } @Test @@ -67,78 +67,82 @@ public void types_allGlobalAndNestedDeclarations() { public void findType_globalEnumWithAllNamesAndNumbers() { Optional celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.GlobalEnum"); - assertThat(celType).isPresent(); + Truth8.assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(EnumType.class); EnumType enumType = (EnumType) celType.get(); assertThat(enumType.name()).isEqualTo("dev.cel.testing.testdata.proto3.GlobalEnum"); - assertThat(enumType.findNameByNumber(0)).hasValue("GOO"); - assertThat(enumType.findNameByNumber(1)).hasValue("GAR"); - assertThat(enumType.findNameByNumber(2)).hasValue("GAZ"); - assertThat(enumType.findNameByNumber(3)).isEmpty(); + 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(); } @Test public void findType_nestedEnumWithAllNamesAndNumbers() { Optional celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum"); - assertThat(celType).isPresent(); + Truth8.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"); - assertThat(enumType.findNumberByName("FOO")).hasValue(0); - assertThat(enumType.findNumberByName("BAR")).hasValue(1); - assertThat(enumType.findNumberByName("BAZ")).hasValue(2); - assertThat(enumType.findNumberByName("MISSING")).isEmpty(); + 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(); } @Test public void findType_globalMessageTypeNoExtensions() { Optional celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.NestedTestAllTypes"); - assertThat(celType).isPresent(); + Truth8.assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto3.NestedTestAllTypes"); - assertThat(protoType.findField("payload")).isPresent(); - assertThat(protoType.findField("child")).isPresent(); - assertThat(protoType.findField("missing")).isEmpty(); + Truth8.assertThat(protoType.findField("payload")).isPresent(); + Truth8.assertThat(protoType.findField("child")).isPresent(); + Truth8.assertThat(protoType.findField("missing")).isEmpty(); assertThat(protoType.fields()).hasSize(2); - assertThat(protoType.findExtension("dev.cel.testing.testdata.proto3.any")).isEmpty(); + Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto3.any")).isEmpty(); } @Test public void findType_globalMessageWithExtensions() { Optional celType = proto2Provider.findType("dev.cel.testing.testdata.proto2.Proto2Message"); - assertThat(celType).isPresent(); + Truth8.assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto2.Proto2Message"); - 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.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.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")) + Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.nested_ext")) .isPresent(); - assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) + Truth8.assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.int32_ext")) .isPresent(); - assertThat( + 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( protoType.findExtension("dev.cel.testing.testdata.proto2.repeated_string_holder_ext")) .isPresent(); - assertThat(protoType.findExtension("dev.cel.testing.testdata.proto2.Proto2Message.int32_ext")) + Truth8.assertThat( + protoType.findExtension("dev.cel.testing.testdata.proto2.Proto2Message.int32_ext")) .isEmpty(); Optional holderType = proto2Provider.findType("dev.cel.testing.testdata.proto2.StringHolder"); - assertThat(holderType).isPresent(); + Truth8.assertThat(holderType).isPresent(); ProtoMessageType stringHolderType = (ProtoMessageType) holderType.get(); - assertThat(stringHolderType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) + Truth8.assertThat( + stringHolderType.findExtension("dev.cel.testing.testdata.proto2.nested_enum_ext")) .isEmpty(); } @@ -146,24 +150,24 @@ public void findType_globalMessageWithExtensions() { public void findType_scopedMessageWithExtensions() { Optional celType = proto2Provider.findType("dev.cel.testing.testdata.proto2.Proto2Message"); - assertThat(celType).isPresent(); + Truth8.assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); - assertThat( + Truth8.assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.message_scoped_nested_ext")) .isPresent(); - assertThat( + Truth8.assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.int64_ext")) .isPresent(); - assertThat( + Truth8.assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.string_ext")) .isPresent(); - assertThat( + Truth8.assertThat( protoType.findExtension( "dev.cel.testing.testdata.proto2.Proto2ExtensionScopedMessage.nested_message_inside_ext")) .isPresent(); @@ -173,11 +177,11 @@ public void findType_scopedMessageWithExtensions() { public void findType_withRepeatedEnumField() { Optional celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes"); - assertThat(celType).isPresent(); + Truth8.assertThat(celType).isPresent(); assertThat(celType.get()).isInstanceOf(ProtoMessageType.class); ProtoMessageType protoType = (ProtoMessageType) celType.get(); assertThat(protoType.name()).isEqualTo("dev.cel.testing.testdata.proto3.TestAllTypes"); - assertThat(protoType.findField("repeated_nested_enum")).isPresent(); + Truth8.assertThat(protoType.findField("repeated_nested_enum")).isPresent(); CelType fieldType = protoType.findField("repeated_nested_enum").get().type(); assertThat(fieldType.kind()).isEqualTo(CelKind.LIST); @@ -187,7 +191,8 @@ public void findType_withRepeatedEnumField() { .isEqualTo("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum"); assertThat(elemType.kind()).isEqualTo(CelKind.INT); assertThat(elemType).isInstanceOf(EnumType.class); - assertThat(proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum")) + Truth8.assertThat( + proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes.NestedEnum")) .hasValue(elemType); } @@ -197,7 +202,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"); - assertThat(protoType.findField("single_nested_message").map(f -> f.type().name())) + Truth8.assertThat(protoType.findField("single_nested_message").map(f -> f.type().name())) .hasValue("dev.cel.testing.testdata.proto3.TestAllTypes.NestedMessage"); } @@ -223,33 +228,35 @@ public void findType_withWellKnownTypes() { Optional celType = proto3Provider.findType("dev.cel.testing.testdata.proto3.TestAllTypes"); ProtoMessageType protoType = (ProtoMessageType) celType.get(); - assertThat(protoType.findField("single_any").map(f -> f.type())).hasValue(SimpleType.ANY); - assertThat(protoType.findField("single_duration").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_any").map(f -> f.type())) + .hasValue(SimpleType.ANY); + Truth8.assertThat(protoType.findField("single_duration").map(f -> f.type())) .hasValue(SimpleType.DURATION); - assertThat(protoType.findField("single_timestamp").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_timestamp").map(f -> f.type())) .hasValue(SimpleType.TIMESTAMP); - assertThat(protoType.findField("single_value").map(f -> f.type())).hasValue(SimpleType.DYN); - assertThat(protoType.findField("single_list_value").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_value").map(f -> f.type())) + .hasValue(SimpleType.DYN); + Truth8.assertThat(protoType.findField("single_list_value").map(f -> f.type())) .hasValue(ListType.create(SimpleType.DYN)); - assertThat(protoType.findField("single_struct").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_struct").map(f -> f.type())) .hasValue(MapType.create(SimpleType.STRING, SimpleType.DYN)); - assertThat(protoType.findField("single_bool_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_bool_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.BOOL)); - assertThat(protoType.findField("single_bytes_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_bytes_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.BYTES)); - assertThat(protoType.findField("single_int32_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_int32_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.INT)); - assertThat(protoType.findField("single_int64_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_int64_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.INT)); - assertThat(protoType.findField("single_double_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_double_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.DOUBLE)); - assertThat(protoType.findField("single_float_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_float_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.DOUBLE)); - assertThat(protoType.findField("single_string_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_string_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.STRING)); - assertThat(protoType.findField("single_uint32_wrapper").map(f -> f.type())) + Truth8.assertThat(protoType.findField("single_uint32_wrapper").map(f -> f.type())) .hasValue(NullableType.create(SimpleType.UINT)); - assertThat(protoType.findField("single_uint64_wrapper").map(f -> f.type())) + Truth8.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 5790be41..5e0c3a83 100644 --- a/common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java +++ b/common/src/test/java/dev/cel/common/types/ProtoMessageTypeTest.java @@ -15,10 +15,10 @@ package dev.cel.common.types; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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 +53,7 @@ public void setUp() { @Test public void findField() { for (String fieldName : FIELD_MAP.keySet()) { - assertThat(testMessage.findField(fieldName)) + Truth8.assertThat(testMessage.findField(fieldName)) .hasValue(StructType.Field.of(fieldName, FIELD_MAP.get(fieldName))); } } @@ -61,8 +61,8 @@ public void findField() { @Test public void withVisibleFields() { ProtoMessageType maskedMessage = testMessage.withVisibleFields(ImmutableSet.of("bool_value")); - assertThat(maskedMessage.findField("int_value")).isEmpty(); - assertThat(maskedMessage.findField("bool_value")).isPresent(); + Truth8.assertThat(maskedMessage.findField("int_value")).isEmpty(); + Truth8.assertThat(maskedMessage.findField("bool_value")).isPresent(); assertThat(maskedMessage.fields()).hasSize(1); assertThat(testMessage.fields()).hasSize(4); } @@ -70,7 +70,7 @@ public void withVisibleFields() { @Test public void findExtension() { for (String extName : EXTENSION_MAP.keySet()) { - assertThat(testMessage.findExtension(extName)) + Truth8.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 95351310..c42b6522 100644 --- a/common/src/test/java/dev/cel/common/values/OptionalValueTest.java +++ b/common/src/test/java/dev/cel/common/values/OptionalValueTest.java @@ -15,10 +15,10 @@ package dev.cel.common.values; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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 +133,7 @@ public void findField_struct_success(String field, boolean expectedResult) { @Test public void findField_onEmptyOptional() { - assertThat(OptionalValue.EMPTY.find(StringValue.create("bogus"))).isEmpty(); + Truth8.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 9b0f5b8e..c1e518a9 100644 --- a/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java +++ b/common/src/test/java/dev/cel/common/values/ProtoMessageValueTest.java @@ -15,12 +15,12 @@ package dev.cel.common.values; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.assertThrows; 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 +97,9 @@ public void findField_fieldIsSet_fieldExists() { ProtoMessageValue.create( testAllTypes, DefaultDescriptorPool.INSTANCE, PROTO_CEL_VALUE_CONVERTER); - assertThat(protoMessageValue.find(StringValue.create("single_bool"))).isPresent(); - assertThat(protoMessageValue.find(StringValue.create("single_int64"))).isPresent(); - assertThat(protoMessageValue.find(StringValue.create("repeated_int64"))).isPresent(); + 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(); } @Test @@ -110,9 +110,9 @@ public void findField_fieldIsUnset_fieldDoesNotExist() { DefaultDescriptorPool.INSTANCE, PROTO_CEL_VALUE_CONVERTER); - assertThat(protoMessageValue.find(StringValue.create("single_int32"))).isEmpty(); - assertThat(protoMessageValue.find(StringValue.create("single_uint64"))).isEmpty(); - assertThat(protoMessageValue.find(StringValue.create("repeated_int32"))).isEmpty(); + 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(); } @Test @@ -151,7 +151,7 @@ public void findField_extensionField_success() { ProtoMessageValue protoMessageValue = ProtoMessageValue.create(proto2Message, descriptorPool, protoCelValueConverter); - assertThat( + Truth8.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 1b367dbd..2f837669 100644 --- a/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java +++ b/extensions/src/test/java/dev/cel/extensions/CelOptionalLibraryTest.java @@ -15,12 +15,12 @@ package dev.cel.extensions; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; import static org.junit.Assert.assertThrows; 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 +144,7 @@ public void optionalType_adaptsIntegerToLong_success() throws Exception { Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("a", Optional.of(5))); - assertThat(result).hasValue(5L); + Truth8.assertThat(result).hasValue(5L); } @Test @@ -155,7 +155,7 @@ public void optionalType_adaptsFloatToLong_success() throws Exception { Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("a", Optional.of(5.5f))); - assertThat(result).hasValue(5.5d); + Truth8.assertThat(result).hasValue(5.5d); } @Test @@ -504,7 +504,7 @@ public void optionalFieldSelection_onMap_returnsOptionalValue() throws Exception Optional result = (Optional) cel.createProgram(ast).eval(); - assertThat(result).hasValue(2L); + Truth8.assertThat(result).hasValue(2L); } @Test @@ -520,7 +520,7 @@ public void optionalFieldSelection_onProtoMessage_returnsOptionalEmpty() throws (Optional) cel.createProgram(ast).eval(ImmutableMap.of("msg", TestAllTypes.getDefaultInstance())); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -537,7 +537,7 @@ public void optionalFieldSelection_onProtoMessage_returnsOptionalValue() throws cel.createProgram(ast) .eval(ImmutableMap.of("msg", TestAllTypes.newBuilder().setSingleInt32(5).build())); - assertThat(result).hasValue(5L); + Truth8.assertThat(result).hasValue(5L); } @Test @@ -568,7 +568,7 @@ public void optionalFieldSelection_onProtoMessage_chainedSuccess() throws Except "dashed-index", TestAllTypes.newBuilder().setSingleInt32(5).build())))); - assertThat(result).hasValue(5L); + Truth8.assertThat(result).hasValue(5L); } @Test @@ -1236,7 +1236,7 @@ public void optionalMapMacro_receiverIsEmpty_returnsOptionalEmpty() throws Excep Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.empty())); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -1251,7 +1251,7 @@ public void optionalMapMacro_receiverHasValue_returnsOptionalValue() throws Exce Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(42L))); - assertThat(result).hasValue(43L); + Truth8.assertThat(result).hasValue(43L); } @Test @@ -1281,7 +1281,7 @@ public void optionalFlatMapMacro_receiverIsEmpty_returnsOptionalEmpty() throws E Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.empty())); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -1296,7 +1296,7 @@ public void optionalFlatMapMacro_receiverHasValue_returnsOptionalValue() throws Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(42L))); - assertThat(result).hasValue(43L); + Truth8.assertThat(result).hasValue(43L); } @Test @@ -1313,7 +1313,7 @@ public void optionalFlatMapMacro_withOptionalOfNonZeroValue_optionalEmptyWhenVal Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(1L))); - assertThat(result).isEmpty(); + Truth8.assertThat(result).isEmpty(); } @Test @@ -1330,7 +1330,7 @@ public void optionalFlatMapMacro_withOptionalOfNonZeroValue_optionalValueWhenVal Optional result = (Optional) cel.createProgram(ast).eval(ImmutableMap.of("x", Optional.of(1L))); - assertThat(result).hasValue(2L); + Truth8.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 68ac5e66..7898239f 100644 --- a/parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java +++ b/parser/src/test/java/dev/cel/parser/CelMacroExprFactoryTest.java @@ -15,9 +15,9 @@ package dev.cel.parser; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.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 +578,7 @@ public void newGlobalCall_returnsGlobalCall() { CelExpr expr = exprFactory.newGlobalCall("foo", argument); assertThat(expr.id()).isEqualTo(2L); assertThat(expr.exprKind().getKind()).isEqualTo(Kind.CALL); - assertThat(expr.call().target()).isEmpty(); + Truth8.assertThat(expr.call().target()).isEmpty(); assertThat(expr.call().function()).isEqualTo("foo"); assertThat(expr.call().args()).containsExactly(argument); } @@ -591,7 +591,7 @@ public void newReceiverCall_returnsReceiverCall() { CelExpr expr = exprFactory.newReceiverCall("foo", target, argument); assertThat(expr.id()).isEqualTo(3L); assertThat(expr.exprKind().getKind()).isEqualTo(Kind.CALL); - assertThat(expr.call().target()).hasValue(target); + Truth8.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 97bb8573..28794249 100644 --- a/parser/src/test/java/dev/cel/parser/CelParserImplTest.java +++ b/parser/src/test/java/dev/cel/parser/CelParserImplTest.java @@ -15,9 +15,9 @@ package dev.cel.parser; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.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,15 +42,20 @@ public void build_withMacros_containsAllMacros() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.STANDARD_MACROS).build(); - 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")) + 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")) .hasValue(CelStandardMacro.EXISTS_ONE.getDefinition()); - assertThat(parser.findMacro("map:2:true")).hasValue(CelStandardMacro.MAP.getDefinition()); - assertThat(parser.findMacro("map:3:true")) + Truth8.assertThat(parser.findMacro("map:2:true")) + .hasValue(CelStandardMacro.MAP.getDefinition()); + Truth8.assertThat(parser.findMacro("map:3:true")) .hasValue(CelStandardMacro.MAP_FILTER.getDefinition()); - assertThat(parser.findMacro("filter:2:true")).hasValue(CelStandardMacro.FILTER.getDefinition()); + Truth8.assertThat(parser.findMacro("filter:2:true")) + .hasValue(CelStandardMacro.FILTER.getDefinition()); } @Test @@ -58,15 +63,20 @@ public void build_withStandardMacros_containsAllMacros() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.STANDARD_MACROS).build(); - 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")) + 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")) .hasValue(CelStandardMacro.EXISTS_ONE.getDefinition()); - assertThat(parser.findMacro("map:2:true")).hasValue(CelStandardMacro.MAP.getDefinition()); - assertThat(parser.findMacro("map:3:true")) + Truth8.assertThat(parser.findMacro("map:2:true")) + .hasValue(CelStandardMacro.MAP.getDefinition()); + Truth8.assertThat(parser.findMacro("map:3:true")) .hasValue(CelStandardMacro.MAP_FILTER.getDefinition()); - assertThat(parser.findMacro("filter:2:true")).hasValue(CelStandardMacro.FILTER.getDefinition()); + Truth8.assertThat(parser.findMacro("filter:2:true")) + .hasValue(CelStandardMacro.FILTER.getDefinition()); } @Test @@ -81,30 +91,37 @@ public void build_withStandardMacrosAndCustomMacros_containsAllMacros() { .addMacros(customMacro) .build(); - 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")) + 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")) .hasValue(CelStandardMacro.EXISTS_ONE.getDefinition()); - assertThat(parser.findMacro("map:2:true")).hasValue(CelStandardMacro.MAP.getDefinition()); - assertThat(parser.findMacro("map:3:true")) + Truth8.assertThat(parser.findMacro("map:2:true")) + .hasValue(CelStandardMacro.MAP.getDefinition()); + Truth8.assertThat(parser.findMacro("map:3:true")) .hasValue(CelStandardMacro.MAP_FILTER.getDefinition()); - assertThat(parser.findMacro("filter:2:true")).hasValue(CelStandardMacro.FILTER.getDefinition()); - assertThat(parser.findMacro("customMacro:1:true")).hasValue(customMacro); + Truth8.assertThat(parser.findMacro("filter:2:true")) + .hasValue(CelStandardMacro.FILTER.getDefinition()); + Truth8.assertThat(parser.findMacro("customMacro:1:true")).hasValue(customMacro); } @Test public void build_withMacro_containsMacro() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().setStandardMacros(CelStandardMacro.HAS).build(); - assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); + Truth8.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(); - assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); + Truth8.assertThat(parser.findMacro("has:1:false")) + .hasValue(CelStandardMacro.HAS.getDefinition()); } @Test @@ -116,8 +133,9 @@ public void build_withStandardMacro_secondCallReplaces() { .setStandardMacros(CelStandardMacro.HAS) .build(); - assertThat(parser.findMacro("has:1:false")).hasValue(CelStandardMacro.HAS.getDefinition()); - assertThat(parser.findMacro("all:2:true")).isEmpty(); + Truth8.assertThat(parser.findMacro("has:1:false")) + .hasValue(CelStandardMacro.HAS.getDefinition()); + Truth8.assertThat(parser.findMacro("all:2:true")).isEmpty(); } @Test @@ -137,7 +155,7 @@ public void build_standardMacroKeyConflictsWithCustomMacro_throws() { @Test public void build_containsNoMacros() { CelParserImpl parser = (CelParserImpl) CelParserImpl.newBuilder().build(); - assertThat(parser.findMacro("has:1:false")).isEmpty(); + Truth8.assertThat(parser.findMacro("has:1:false")).isEmpty(); } @Test @@ -157,7 +175,7 @@ public void setParserOptions(CelParserBuilder parserBuilder) { }) .build(); - assertThat(parser.findMacro("dummyMacro:*:true")).isPresent(); + Truth8.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 a48fcc8d..8d0c35d9 100644 --- a/runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java +++ b/runtime/src/test/java/dev/cel/runtime/UnknownContextTest.java @@ -15,10 +15,10 @@ package dev.cel.runtime; import static com.google.common.truth.Truth.assertThat; -import static com.google.common.truth.Truth8.assertThat; 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,7 +33,8 @@ public void create_variableResolverOnly() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - assertThat(attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("test"))).isEmpty(); + Truth8.assertThat(attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("test"))) + .isEmpty(); assertThat(context.variableResolver().resolve("test")).isEqualTo("test_value"); } @@ -48,16 +49,16 @@ public void create_attributeResolverResolvesUnknown() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - assertThat( + Truth8.assertThat( attributeResolver.resolve( CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))); - assertThat( + Truth8.assertThat( attributeResolver.resolve( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))) .isEmpty(); - assertThat( + Truth8.assertThat( attributeResolver.resolve( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2.field1"))) .hasValue( @@ -76,17 +77,17 @@ public void create_attributeResolverIdentifiesPartials() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2.field1"))) .hasValue( @@ -105,17 +106,17 @@ public void withResolvedAttributes_attributeResolverReturnsValue() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier1"))); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))) .hasValue( CelUnknownSet.create(CelAttribute.fromQualifiedIdentifier("qualified.Identifier2"))); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier2.field1"))) .hasValue( @@ -135,7 +136,7 @@ public void withResolvedAttributes_attributeResolverResolves() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - assertThat( + Truth8.assertThat( attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("qualified.Identifier"))) .hasValue("value1"); } @@ -156,14 +157,14 @@ public void withResolvedAttributes_attributeResolverPartialsShadowed() { CelAttributeResolver attributeResolver = context.createAttributeResolver(); - assertThat( + Truth8.assertThat( attributeResolver.resolve(CelAttribute.fromQualifiedIdentifier("qualified.Identifier"))) .hasValue("value1"); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier.field1"))) .isEmpty(); - assertThat( + Truth8.assertThat( attributeResolver.maybePartialUnknown( CelAttribute.fromQualifiedIdentifier("qualified.Identifier.field2"))) .isEmpty();