public void testInvalidCharacters() throws Exception {
   TracTicket ticket = harness.createTicket("invalid characters");
   ticket.putBuiltinValue(Key.DESCRIPTION, "Control Character: \u0002");
   try {
     client.updateTicket(ticket, "set invalid characters in description", null);
     fail("Expected TracException");
   } catch (TracException e) {
     // expected to cause parse error
   }
 }
  public void testGetTicketActionsClosed() throws Exception {
    TracTicket ticket = harness.createTicket("getTicketActionsClosed");
    ticket.putBuiltinValue(Key.STATUS, "closed");
    ticket.putBuiltinValue(Key.RESOLUTION, "fixed");
    client.updateTicket(ticket, "", null);

    ticket = client.getTicket(ticket.getId(), null);
    TracAction[] actions = ticket.getActions();
    assertNotNull(actions);
    assertEquals(2, actions.length);
    assertEquals("leave", actions[0].getId());
    assertEquals("reopen", actions[1].getId());
  }
 public void testGetTicketActions() throws Exception {
   TracTicket ticket = harness.createTicket("getTicketActions");
   TracAction[] actions = ticket.getActions();
   assertNotNull(actions);
   assertEquals(4, actions.length);
   assertEquals("leave", actions[0].getId());
   assertEquals("resolve", actions[1].getId());
   assertEquals("resolve", actions[1].getLabel());
   assertNotNull(actions[1].getHint());
   List<TracTicketField> fields = actions[1].getFields();
   assertEquals(1, fields.size());
   assertEquals(5, fields.get(0).getOptions().length);
   assertEquals("fixed", fields.get(0).getOptions()[0]);
   assertEquals("reassign", actions[2].getId());
   fields = actions[2].getFields();
   assertEquals(1, fields.size());
   assertNull(fields.get(0).getOptions());
   assertEquals("accept", actions[3].getId());
 }
  public void testSearchValidateTicket() throws Exception {
    String uniqueTag = RandomStringUtils.randomAlphanumeric(6);
    TracTicket ticket = harness.createTicket("searchValidateTicket " + uniqueTag);
    ticket.putBuiltinValue(Key.COMPONENT, "component1");
    ticket.putBuiltinValue(Key.DESCRIPTION, "description1");
    ticket.putBuiltinValue(Key.MILESTONE, "milestone1");
    ticket.putBuiltinValue(Key.REPORTER, "anonymous");
    client.updateTicket(ticket, "", null);

    TracSearch search = new TracSearch();
    search.addFilter(new TracSearchFilter("summary", CompareOperator.CONTAINS, uniqueTag));
    List<TracTicket> result = new ArrayList<TracTicket>();
    client.search(search, result, null);
    assertEquals(1, result.size());
    // the value varies between Trac versions, e.g. "somebody", "< default >"
    ticket.putBuiltinValue(Key.OWNER, result.get(0).getValue(Key.OWNER));
    TracTestUtil.assertTicketEquals(ticket, result.get(0));
  }