@Test
  public void testDefaultPlans() throws Exception {
    Gitana gitana = new Gitana();

    // authenticate
    Platform platform = gitana.authenticate("admin", "admin");

    // default registrar
    Registrar registrar = platform.readRegistrar("default");

    // query to make sure that the default plans exist

    Plan unlimited = registrar.readPlan("unlimited");
    assertNotNull(unlimited);
  }
  @Test
  public void testPlanCRUD() throws Exception {
    Gitana gitana = new Gitana();

    // authenticate
    Platform platform = gitana.authenticate("admin", "admin");

    // default registrar
    Registrar registrar = platform.readRegistrar("default");

    // count current plans
    int currentSize = registrar.listPlans().size();

    String planKey = "test-" + System.currentTimeMillis();

    try {
      Plan plan = registrar.createPlan(planKey);
      assertEquals(planKey, plan.getPlanKey());

      assertEquals(currentSize + 1, registrar.listPlans().size());

      ResultMap<Plan> plans =
          registrar.queryPlans(QueryBuilder.start(Plan.FIELD_PLAN_KEY).is(planKey).get());
      assertEquals(1, plans.size());

      plan.set("abc", "def");
      registrar.updatePlan(plan);

      Plan testPlan = registrar.readPlan(planKey);
      assertEquals("def", testPlan.getString("abc"));
    } finally {
      if (registrar.readPlan(planKey) != null) {
        registrar.deletePlan(planKey);
      }
    }
  }