PC06-L03 · independent challenge

Service request triage

Order four priority levels so that a stronger rule runs first.

Practical CEL4 test casesDocumented
What will I practise?

You can build a multi-level decision and test overlapping conditions.

How is it checked?

Your one expression must produce the expected result for all four JSON inputs.

When am I done?

When all tests pass and you can explain every condition in your expression.

Word problem

Classify a service request as critical for security impact, high when at least 10 users are blocked, medium when at least one user is blocked, and low otherwise.

Exact requirements

  1. Security impact always wins.
  2. Exactly 10 users belongs to high.
  3. Positive counts below 10 are medium.
  4. Zero is low.

Required result

Write one CEL expression. It must return the expected value and type for all four prepared JSON inputs. Do not change the inputs to make an incomplete expression pass.

Recommended procedure

  1. Translate each numbered requirement into one small boolean condition.
  2. Run the starter expression and inspect which cases fail.
  3. Add one condition at a time and run the complete suite again.
  4. Mark the challenge complete only when you can explain every operator and every boundary.

Solve the challenge · browser test suite

Write one expression that passes every case

Edit the CEL expression, then run it against all prepared JSON inputs. A solution is complete only when every case passes.

4 test cases

Hint: Security impact outranks user count; then test 10, followed by values above zero.

Tip: press Ctrl/⌘ + Enter to run all tests.
Security impactNot run yet
Expected: "critical" · string
Show JSON input
{
  "request": {
    "securityImpact": true,
    "blockingUsers": 0
  }
}
Ten usersNot run yet
Expected: "high" · string
Show JSON input
{
  "request": {
    "securityImpact": false,
    "blockingUsers": 10
  }
}
One userNot run yet
Expected: "medium" · string
Show JSON input
{
  "request": {
    "securityImpact": false,
    "blockingUsers": 1
  }
}
No blocked usersNot run yet
Expected: "low" · string
Show JSON input
{
  "request": {
    "securityImpact": false,
    "blockingUsers": 0
  }
}
Test result

Not run yet

The same expression runs against every case. Test data is fixed so that boundary and failure scenarios cannot be skipped.

Explained solution

Show the complete expression
request.securityImpact ? 'critical' : request.blockingUsers >= 10.0 ? 'high' : request.blockingUsers > 0.0 ? 'medium' : 'low'

Why the solution works

  1. The outer condition handles the strongest priority.
  2. The next condition uses >= 10.0 for the high boundary.
  3. The third condition uses > 0.0 for medium.
  4. The final branch handles the only remaining value range.

What the test cases prove

  • Security impact: expected "critical" (string).
  • Ten users: expected "high" (string).
  • One user: expected "medium" (string).
  • No blocked users: expected "low" (string).

The cases are intentionally different. A solution that passes only the first case has not yet implemented the complete rule.

Common mistake

Do not optimise the expression for the first successful input. A requirement is implemented only when its positive case, negative case, and boundary case all produce the stated result.

Knowledge check

Can you point to the exact part of the solution that makes each false test case fail? If two different failures depend on the same condition, explain why.

Key takeaway

You can build a multi-level decision and test overlapping conditions.

Sources

  • CEL-DEV — official CEL overview.
  • CEL-LANG — official CEL language definition for operators, types, macros, presence, strings, and time values used in this challenge.