コード例 #1
0
  @Before
  public void setUp() {

    controller = new DefaultTicketController();
    TicketRepository tr = new TransientTicketRepository();
    TicketTypeRepository ttr = new TransientTicketTypeRepository();
    controller.setTicketRepository(tr);
    controller.setTicketTypeRepository(ttr);
  }
コード例 #2
0
 @Test
 public void testSave() {
   User u = new User("test");
   Response<Ticket> tr = controller.createTicketSkeleton(incidentType, u);
   assertFalse(tr.hasError());
   Ticket t = tr.getPayload();
   assertEquals(-1, t.getUniqueId());
   tr = controller.saveTicket(t, u);
   assertFalse(tr.hasError());
   t = tr.getPayload();
   assertFalse(-1 == t.getUniqueId());
 }
コード例 #3
0
  @Test
  public void testAddRelationship() {

    User u = new User("test");
    Response<Ticket> tr = controller.createTicketSkeleton(incidentType, u);
    assertFalse(tr.hasError());
    Ticket t = tr.getPayload();
    t = controller.saveTicket(t, u).getPayload();

    Response<Ticket> tr2 = controller.createTicketSkeleton(incidentType, u);
    assertFalse(tr2.hasError());
    Ticket t2 = tr2.getPayload();
    t2 = controller.saveTicket(t2, u).getPayload();

    Response<Ticket> relationshipResponse =
        controller.addRelationship(t.getId(), t2.getId(), RelationshipType.PARENT_OF);

    assertResponseSuccess(relationshipResponse);

    tr = controller.getTicket(t.getId());
    tr2 = controller.getTicket(t2.getId());

    t = tr.getPayload();
    t2 = tr2.getPayload();

    assertTrue(t.isRelatedTo(t2));
    assertTrue(t2.isRelatedTo(t));

    assertEquals(t.getRelationTo(t2), RelationshipType.PARENT_OF);
    assertEquals(t2.getRelationTo(t), RelationshipType.CHILD_OF);
  }