@Test
public void apply() throws Exception {

  EdmProperty edmProperty = mock(EdmProperty.class);
  when(edmProperty.getName()).thenReturn("property");
  final DebugTabUri tab = new DebugTabUri(new UriInfoImpl().setKind(UriInfoKind.all)
      .setSystemQueryOption(new ApplyOptionImpl().add(new AggregateImpl().addExpression(
          new AggregateExpressionImpl()
              .setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
                  new UriResourcePrimitivePropertyImpl(edmProperty)))
              .setStandardMethod(StandardMethod.AVERAGE)
              .setAlias("average")))));
  assertEquals("{\"kind\":\"all\",\"apply\":[{\"kind\":\"AGGREGATE\",\"aggregate\":[{"
      + "\"path\":[{\"uriResourceKind\":\"primitiveProperty\",\"segment\":\"property\",\"isCollection\":false}],"
      + "\"standardMethod\":\"AVERAGE\",\"as\":\"average\"}]}]}",
      createJson(tab));
  final String html = createHtml(tab);
  assertThat(html, allOf(
      startsWith("<h2>Kind</h2>\n"
          + "<p>all</p>\n"
          + "<h2>Apply Option</h2>\n"
          + "<ul>\n"
          + "<li class=\"json\">"),
      containsString("kind"), containsString("AGGREGATE"),
      containsString("aggregate"), containsString("path")));
  assertThat(html, allOf(
      containsString("primitiveProperty"), containsString("property"),
      containsString("standardMethod"), containsString("AVERAGE")));
  assertThat(html, allOf(
      containsString("as"), containsString("average"),
      endsWith("</li>\n</ul>\n")));
  assertEquals("{\"kind\":\"all\",\"apply\":[{\"kind\":\"GROUP_BY\",\"groupBy\":[{"
      + "\"path\":[{\"uriResourceKind\":\"primitiveProperty\",\"segment\":\"property\",\"isCollection\":false}],"
      + "\"isRollupAll\":true}]}]}",
      createJson(new DebugTabUri(new UriInfoImpl().setKind(UriInfoKind.all)
          .setSystemQueryOption(new ApplyOptionImpl().add(new GroupByImpl().addGroupByItem(
              new GroupByItemImpl().setIsRollupAll()
                  .setPath(new UriInfoImpl().setKind(UriInfoKind.resource).addResourcePart(
                      new UriResourcePrimitivePropertyImpl(edmProperty)))))))));
}