Skip to content

Commit

Permalink
No public description
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 602823902
  • Loading branch information
cpovirk authored and copybara-github committed Jan 30, 2024
1 parent 3a73459 commit 61b20df
Show file tree
Hide file tree
Showing 23 changed files with 289 additions and 257 deletions.
8 changes: 4 additions & 4 deletions checker/src/test/java/dev/cel/checker/CelIdentDeclTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
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;
import dev.cel.expr.Decl;
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 +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
Expand All @@ -58,7 +58,7 @@ public void celIdentBuilder_clearConstant() {

builder.clearConstant();

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

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

Expand Down Expand Up @@ -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
Expand All @@ -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<CelType> foundType = celTypeProvider.findType(typeName);
assertThat(foundType).isPresent();
Truth8.assertThat(foundType).isPresent();
CelType celType = foundType.get();
assertThat(celType).isInstanceOf(ProtoMessageType.class);
return (ProtoMessageType) celType;
Expand All @@ -271,7 +271,7 @@ private void assertTypeHasFields(ProtoMessageType protoType, ImmutableSet<String

private void assertTypeHasFieldWithType(
ProtoMessageType protoType, String fieldName, String typeName) {
assertThat(protoType.findField(fieldName)).isPresent();
Truth8.assertThat(protoType.findField(fieldName)).isPresent();
assertThat(protoType.findField(fieldName).get().type().name()).isEqualTo(typeName);
}
}
Loading

0 comments on commit 61b20df

Please sign in to comment.