@SuppressWarnings("unchecked")
  public <T extends Expression> T rewrite(final T expression, final C context) {
    return (T) rewriter.process(expression, context);
  }
@Test
  public void shouldRewriteSimpleCaseExpression() {
    // Given:
    final SimpleCaseExpression parsed = parseExpression(
        "CASE COL0 WHEN 1 THEN 'ONE' WHEN 2 THEN 'TWO' ELSE 'THREE' END");
    when(processor.apply(parsed.getOperand(), context)).thenReturn(expr1);
    when(processor.apply(parsed.getWhenClauses().get(0), context)).thenReturn(when1);
    when(processor.apply(parsed.getWhenClauses().get(1), context)).thenReturn(when2);
    when(processor.apply(parsed.getDefaultValue().get(), context)).thenReturn(expr2);

    // When:
    final Expression rewritten = expressionRewriter.rewrite(parsed, context);

    // Then:
    assertThat(
        rewritten,
        equalTo(
            new SimpleCaseExpression(
                parsed.getLocation(),
                expr1,
                ImmutableList.of(when1, when2),
                Optional.of(expr2)
            )
        )
    );
  }