@Test public void testCreateTestSkeleton() { User u = new User("test"); Response<Ticket> tr = controller.createTicketSkeleton(incidentType, u); assertFalse(tr.hasError()); Ticket t = tr.getPayload(); assertEquals(-1, t.getUniqueId()); }
@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); }
protected void assertResponseSuccess(Response<? extends Serializable> response) { if (response.hasError()) { fail(response.getError().toString()); } }