static void toJson(ViewRepresentation representation, JsonGenerator generator)
      throws IOException {
    Preconditions.checkArgument(representation != null, "Invalid view representation: null");
    switch (representation.type().toLowerCase(Locale.ENGLISH)) {
      case ViewRepresentation.Type.SQL:
        SQLViewRepresentationParser.toJson((SQLViewRepresentation) representation, generator);
        break;

      default:
        throw new UnsupportedOperationException(
            String.format(
                "Cannot serialize unsupported view representation: %s", representation.type()));
    }
  }
@Test
  public void testNullViewRepresentation() {
    assertThatThrownBy(() -> ViewRepresentationParser.toJson(null))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessage("Invalid view representation: null");
  }