@Test
public void filter() throws Exception {

  final DebugTabUri tab = new DebugTabUri(new UriInfoImpl().setKind(UriInfoKind.all)
      .setSystemQueryOption(new FilterOptionImpl().setExpression(
          new BinaryImpl(new LiteralImpl("1", EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Int64)),
              BinaryOperatorKind.GT,
              new LiteralImpl("2", EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.SByte)),
              EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Boolean)))));
  assertEquals("{\"kind\":\"all\",\"filter\":{"
      + "\"nodeType\":\"binary\",\"operator\":\"gt\",\"type\":\"Boolean\","
      + "\"left\":{\"nodeType\":\"literal\",\"type\":\"Edm.Int64\",\"value\":\"1\"},"
      + "\"right\":{\"nodeType\":\"literal\",\"type\":\"Edm.SByte\",\"value\":\"2\"}}}",
      createJson(tab));
  assertThat(createHtml(tab), allOf(
      startsWith("<h2>Kind</h2>\n"
          + "<p>all</p>\n"
          + "<h2>Filter Option</h2>\n"
          + "<ul>\n"
          + "<li class=\"json\">"),
      containsString("nodeType"), containsString("binary"),
      containsString("operator"), containsString("gt")));
  assertThat(createHtml(tab), allOf(
      containsString("literal"), containsString("Int64"),
      containsString("SByte"), containsString("2"),
      endsWith("</li>\n</ul>\n")));
  assertEquals("{\"kind\":\"all\",\"filter\":{"
      + "\"nodeType\":\"method\",\"operator\":\"ceiling\",\"type\":\"Number\","
      + "\"parameters\":[{\"nodeType\":\"literal\",\"type\":\"Edm.Decimal\",\"value\":\"1.5\"}]}}",
      createJson(new DebugTabUri(new UriInfoImpl().setKind(UriInfoKind.all)
          .setSystemQueryOption(new FilterOptionImpl().setExpression(
              new MethodImpl(MethodKind.CEILING, Arrays.asList(
                  (Expression) new LiteralImpl("1.5",
                      EdmPrimitiveTypeFactory.getInstance(EdmPrimitiveTypeKind.Decimal)))))))));
  EdmEntityType edmEntityType = mock(EdmEntityType.class);
  when(edmEntityType.getFullQualifiedName()).thenReturn(new FullQualifiedName("ns", "entityType"));
  EdmProperty edmProperty = mock(EdmProperty.class);
  when(edmProperty.getName()).thenReturn("property");
  assertEquals("{\"kind\":\"all\",\"filter\":{"
      + "\"nodeType\":\"member\",\"type\":\"unknown\",\"typeFilter\":\"ns.entityType\","
      + "\"resourceSegments\":[{\"nodeType\":\"primitiveProperty\",\"name\":\"property\",\"type\":\"unknown\"}]}}",
      createJson(new DebugTabUri(new UriInfoImpl().setKind(UriInfoKind.all)
          .setSystemQueryOption(new FilterOptionImpl().setExpression(
              new MemberImpl(new UriInfoImpl().setKind(UriInfoKind.resource)
                  .addResourcePart(new UriResourcePrimitivePropertyImpl(edmProperty)),
                  edmEntityType))))));
}