/** * Test an execution of a {@link Query} with a {@link NotFilter}. The following conditions are * checked :<br> * * <ul> * <li>The list contains 2 tickets * <li>The list contains the ticket "T4" * <li>The list contains the ticket "T5" * </ul> */ @Test public void testNotFilterQuery() { Product p = productDAO.findByName("P1").get(0); query.addFilter(new NotFilter(new EqualFilter("product", p))); List<Ticket> tickets = processor.execute(query); assertEquals(2, tickets.size()); assertTrue(tickets.contains(ticketDAO.findByTitle("T4").get(0))); assertTrue(tickets.contains(ticketDAO.findByTitle("T5").get(0))); }
/** Test if the {@link NotFilter} is correct */ @Test public void testNot() { Product p = productDAO.findByName("P1").get(0); query.addFilter(new NotFilter(new EqualFilter("product", p))); List<Ticket> tickets = processor.execute(query); Query<Ticket> refQuery = new Query<Ticket>(Ticket.class); refQuery.addFilter(new EqualFilter("product", p)); List<Ticket> ticketsForProduct = processor.execute(refQuery); List<Ticket> ref = ticketDAO.findAll(); ref.removeAll(ticketsForProduct); assertEquals(ref.size(), tickets.size()); assertTrue(tickets.containsAll(ref)); }