@Before
  public void setUp() {
    datastoreHelper.setUp();
    ObjectifyFilter.complete();

    Client.create(client);
    sgp = Group.create(client, "Singapore", User.SUPER_USER);
    assertEquals(1, sgp.groupId);

    kl = Group.create(client, "KL", User.SUPER_USER);
    assertEquals(2, kl.groupId);

    validUser = User.create(client, "*****@*****.**", sgp.groupId, User.SUPER_USER);

    userWithSendMailPermissionForSgp =
        User.create(client, "*****@*****.**", sgp.groupId, User.SUPER_USER);
    User.addGroupLevelPrivilege(
        client,
        sgp.groupId,
        userWithSendMailPermissionForSgp.email,
        GroupLevelPrivilege.SEND_EMAIL,
        User.SUPER_USER);

    sgpTeachers = List.createRestricted(client, sgp.groupId, "Sgp Teachers", null, User.SUPER_USER);

    ContactProp c = new ContactProp();
    c.email = "*****@*****.**";
    c.asOfyyyymmdd = 20141026;
    c.firstName = "Sathya";
    sathya = Member.create(client, sgp.groupId, c, false, User.SUPER_USER);

    c.firstName = "Sharmila";
    c.mobilePhone = "+6593849384";
    c.email = null;
    sharmila = Member.create(client, sgp.groupId, c, false, User.SUPER_USER);
    assertEquals("Sharmila", sharmila.contact.firstName);

    c.email = "*****@*****.**";
    murugavel = Member.create(client, sgp.groupId, c, false, User.SUPER_USER);
    assertEquals("*****@*****.**", murugavel.contact.email);

    // add sathya and sharmila to sgpTeachers
    Member.addOrDeleteList(client, sathya.memberId, sgpTeachers.listId, true, User.SUPER_USER);
    Member.addOrDeleteList(client, sharmila.memberId, sgpTeachers.listId, true, User.SUPER_USER);
    Member.subscribeGroup(client, sathya.memberId, sgp.groupId, User.SUPER_USER);
    Member.subscribeGroup(client, sharmila.memberId, sgp.groupId, User.SUPER_USER);

    ObjectifyFilter.complete();
  }
  private void queryDetailed(
      String client, String login, HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    Set<Long> groupIds = new HashSet<>();
    groupIds.add(
        Group.safeGetByIdOrName(client, ServletUtils.getStrParam(request, "group"))
            .toProp()
            .groupId);
    List<ProgramProp> programProps =
        Program.query(
            client,
            ServletUtils.getIntParam(request, "startYYYYMMDD"),
            ServletUtils.getIntParam(request, "endYYYYMMDD"),
            ServletUtils.getLongParamsAsSet(request, "programTypeId"),
            groupIds,
            null,
            null);

    for (ProgramProp programProp : programProps) {
      programProp.regSummary =
          Registration.getSummary(client, programProp.programId, User.SUPER_USER);
    }

    ServletUtils.setJson(response, new APIResponse().status(Status.SUCCESS).object(programProps));
  }
  private void create(
      String client, String login, HttpServletRequest request, HttpServletResponse response)
      throws IOException {

    long groupId =
        Group.safeGetByIdOrName(client, ServletUtils.getStrParam(request, "group"))
            .toProp()
            .groupId;

    ProgramProp programProp =
        Program.create(
            client,
            groupId,
            ServletUtils.getLongParam(request, "programTypeId"),
            ServletUtils.getLongParam(request, "venueId"),
            ServletUtils.getLongParam(request, "teacherId"),
            ServletUtils.getIntParam(request, "startYYYYMMDD"),
            ServletUtils.getIntParam(request, "endYYYYMMDD"),
            1,
            "",
            ServletUtils.getDoubleParam(request, "fee"),
            Utils.Currency.SGD,
            login);

    update(client, programProp, request, response);
  }