Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -58,7 +57,7 @@ public void celIdentBuilder_clearConstant() {

builder.clearConstant();

Truth8.assertThat(builder.build().constant()).isEmpty();
assertThat(builder.build().constant()).isEmpty();
}

@Test
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand All @@ -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);
}
}
Loading