Package com.gitblit.models

Examples of com.gitblit.models.TicketModel$Change


  @Test
  public void testChangeComment() throws Exception {
    // C1: create the ticket
    Change c1 = newChange("testChangeComment() " + Long.toHexString(System.currentTimeMillis()));
    TicketModel ticket = service.createTicket(getRepository(), c1);
    assertTrue(ticket.number > 0);
    assertTrue(ticket.changes.get(0).hasComment());

    ticket = service.updateComment(ticket, c1.comment.id, "E1", "I changed the comment");
    assertNotNull(ticket);
View Full Code Here


  @Test
  public void testDeleteComment() throws Exception {
    // C1: create the ticket
    Change c1 = newChange("testDeleteComment() " + Long.toHexString(System.currentTimeMillis()));
    TicketModel ticket = service.createTicket(getRepository(), c1);
    assertTrue(ticket.number > 0);
    assertTrue(ticket.changes.get(0).hasComment());

    ticket = service.deleteComment(ticket, c1.comment.id, "D1");
    assertNotNull(ticket);
View Full Code Here

    patchset.number = 1;
    patchset.rev = 25;
    patchset.tip = "50f57913f816d04a16b7407134de5d8406421f37";
    kernel.patchset = patchset;

    TicketModel ticket = service.createTicket(getRepository(), 0L, kernel);

    Change merge = new Change("james");
    merge.setField(Field.mergeSha, patchset.tip);
    merge.setField(Field.mergeTo, "master");
    merge.setField(Field.status, Status.Merged);
View Full Code Here

  }

  @Test
  public void testLifecycle() throws Exception {
    // query non-existent ticket
    TicketModel nonExistent = service.getTicket(getRepository(), 0);
    assertNull(nonExistent);
   
    // create and insert a ticket
    Change c1 = newChange("testCreation() " + Long.toHexString(System.currentTimeMillis()));
    TicketModel ticket = service.createTicket(getRepository(), c1);
    assertTrue(ticket.number > 0);

    // retrieve ticket and compare
    TicketModel constructed = service.getTicket(getRepository(), ticket.number);
    compare(ticket, constructed);

    assertEquals(1, constructed.changes.size());

    // C1: create the ticket
    int changeCount = 0;
    c1 = newChange("testUpdates() " + Long.toHexString(System.currentTimeMillis()));
    ticket = service.createTicket(getRepository(), c1);
    assertTrue(ticket.number > 0);
    changeCount++;

    constructed = service.getTicket(getRepository(), ticket.number);
    compare(ticket, constructed);
    assertEquals(1, constructed.changes.size());

    // C2: set owner
    Change c2 = new Change("C2");
    c2.comment("I'll fix this");
    c2.setField(Field.responsible, c2.author);
    constructed = service.updateTicket(getRepository(), ticket.number, c2);
    assertNotNull(constructed);
    assertEquals(2, constructed.changes.size());
    assertEquals(c2.author, constructed.responsible);
    changeCount++;

    // C3: add a note
    Change c3 = new Change("C3");
    c3.comment("yeah, this is working");
    constructed = service.updateTicket(getRepository(), ticket.number, c3);
    assertNotNull(constructed);
    assertEquals(3, constructed.changes.size());
    changeCount++;

    if (service.supportsAttachments()) {
      // C4: add attachment
      Change c4 = new Change("C4");
      Attachment a = newAttachment();
      c4.addAttachment(a);
      constructed = service.updateTicket(getRepository(), ticket.number, c4);
      assertNotNull(constructed);
      assertTrue(constructed.hasAttachments());
      Attachment a1 = service.getAttachment(getRepository(), ticket.number, a.name);
      assertEquals(a.content.length, a1.content.length);
      assertTrue(Arrays.areEqual(a.content, a1.content));
      changeCount++;
    }

    // C5: close the issue
    Change c5 = new Change("C5");
    c5.comment("closing issue");
    c5.setField(Field.status, Status.Resolved);
    constructed = service.updateTicket(getRepository(), ticket.number, c5);
    assertNotNull(constructed);
    changeCount++;
    assertTrue(constructed.isClosed());
    assertEquals(changeCount, constructed.changes.size());

    List<TicketModel> allTickets = service.getTickets(getRepository());
    List<TicketModel> openTickets = service.getTickets(getRepository(), new TicketFilter() {
      @Override
View Full Code Here

          List<Change> changes = TicketSerializer.deserializeJournal(json);
          if (ArrayUtils.isEmpty(changes)) {
            log.warn("Empty journal for {}:{}", repository, journal);
            continue;
          }
          TicketModel ticket = TicketModel.buildTicket(changes);
          ticket.project = repository.projectPath;
          ticket.repository = repository.name;
          ticket.number = ticketId;

          // add the ticket, conditionally, to the list
View Full Code Here

      List<Change> changes = getJournal(db, ticketId);
      if (ArrayUtils.isEmpty(changes)) {
        log.warn("Empty journal for {}:{}", repository, ticketId);
        return null;
      }
      TicketModel ticket = TicketModel.buildTicket(changes);
      if (ticket != null) {
        ticket.project = repository.projectPath;
        ticket.repository = repository.name;
        ticket.number = ticketId;
      }
View Full Code Here

    if (ticketId <= 0L) {
      return null;
    }

    // deserialize the ticket model so that we have the attachment metadata
    TicketModel ticket = getTicket(repository, ticketId);
    Attachment attachment = ticket.getAttachment(filename);

    // attachment not found
    if (attachment == null) {
      return null;
    }
View Full Code Here

      TicketNotifier notifier = createNotifier();
      for (QueryResult qr : milestone.tickets) {
        Change change = new Change(createdBy);
        change.setField(Field.milestone, newName);
        TicketModel ticket = updateTicket(repository, qr.number, change);
        notifier.queueMailing(ticket);
      }
      notifier.sendAll();

      return true;
View Full Code Here

   * @return a ticket, if it exists, otherwise null
   * @since 1.4.0
   */
  public final TicketModel getTicket(RepositoryModel repository, long ticketId) {
    TicketKey key = new TicketKey(repository, ticketId);
    TicketModel ticket = ticketsCache.getIfPresent(key);

    // if ticket not cached
    if (ticket == null) {
      //load ticket
      ticket = getTicketImpl(repository, ticketId);
      // if ticket exists
      if (ticket != null) {
        if (ticket.hasPatchsets()) {
          Repository r = repositoryManager.getRepository(repository.name);
          try {
            Patchset patchset = ticket.getCurrentPatchset();
            DiffStat diffStat = DiffUtils.getDiffStat(r, patchset.base, patchset.tip);
            // diffstat could be null if we have ticket data without the
            // commit objects.  e.g. ticket replication without repo
            // mirroring
            if (diffStat != null) {
View Full Code Here

    change.setField(Field.status, Status.New);

    boolean success = commitChangeImpl(repository, ticketId, change);
    if (success) {
      TicketModel ticket = getTicket(repository, ticketId);
      indexer.index(ticket);

      // call the ticket hooks
      if (pluginManager != null) {
        for (TicketHook hook : pluginManager.getExtensions(TicketHook.class)) {
View Full Code Here

TOP

Related Classes of com.gitblit.models.TicketModel$Change

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.