Skip to content

Commit 234edb9

Browse files
committed
ACC-2351 Add test for specific expression
1 parent f3867c7 commit 234edb9

File tree

1 file changed

+34
-11
lines changed

1 file changed

+34
-11
lines changed

opa-async-java-client/src/test/java/com/contentgrid/opa/client/OpaClientIntegrationTests.java

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
import com.contentgrid.opa.rego.ast.Query;
1515
import com.contentgrid.opa.rego.ast.Term;
1616
import com.contentgrid.opa.rego.ast.Term.Ref;
17+
import com.contentgrid.opa.rego.ast.Term.Text;
18+
import com.contentgrid.opa.rego.ast.Term.Var;
1719
import java.io.IOException;
1820
import java.io.UncheckedIOException;
1921
import java.nio.charset.StandardCharsets;
@@ -320,17 +322,38 @@ void abacExample() {
320322
.hasSize(2)
321323
.allSatisfy(expr -> {
322324
// each expression has 3 terms (the 'eq' operator, the attribute value and the input value)
323-
assertThat(expr.getTerms()).hasSize(3);
324-
assertThat(expr.getTerms()).anySatisfy(
325-
term -> {
326-
assertThat(term).isInstanceOfSatisfying(Ref.class, ref -> {
327-
assertThat(ref.getValue()).singleElement().satisfies(
328-
t -> assertThat(t).hasToString("eq")
329-
);
330-
});
331-
}
332-
);
333-
}));
325+
assertThat(expr.getTerms())
326+
.hasSize(3)
327+
.anySatisfy(
328+
term -> {
329+
assertThat(term).isInstanceOfSatisfying(Ref.class, ref -> {
330+
assertThat(ref.getValue()).singleElement().satisfies(
331+
t -> assertThat(t).hasToString("eq")
332+
);
333+
});
334+
}
335+
);
336+
})
337+
)
338+
.anySatisfy(query -> {
339+
assertThat(query).anySatisfy(
340+
expr -> assertThat(expr.getTerms())
341+
.isEqualTo(List.of(
342+
new Ref(List.of(new Var("eq"))),
343+
new Text("att1v1"),
344+
new Ref(List.of(
345+
new Var("input"),
346+
new Text("entity"),
347+
new Text("a")
348+
)
349+
)
350+
)
351+
352+
)
353+
);
354+
355+
})
356+
;
334357
}
335358

336359
@Test

0 commit comments

Comments
 (0)