@Test
	public void testSaleAll() throws Exception
	{


		TestTicketPool pool = this.createTicketPool();
		
	
		int stopCount = pool.getRoute().getStops().size();
		
		TicketPoolQueryArgs query = new TicketPoolQueryArgs();
		
		query.setCount(1);
		query.setSeatType(~0);
	
		
		ArrayList<TicketPoolTicket> soldTickets = new ArrayList<TicketPoolTicket>(10000);
		
		Random random = new Random(new Date().getTime());
		
		while(!pool.getIsSoldOut())
		{
			int v1 = random.nextInt(stopCount);
			int v2 = random.nextInt(stopCount);
			
			if(v1 != v2)
			{
				int departure = Math.min(v1, v2);
				int destination = Math.max(v1, v2);
				query.setDepartureStop(departure);
				query.setDestinationStop(destination);
				
				TicketPoolTicket[] tickets = pool.book(query);
				for(TicketPoolTicket t : tickets)
				{
					soldTickets.add(t);
				}
			}
		}
		
		Iterable<IGrouping<OperatingSeat, TicketPoolTicket>> groups = Queries.query(soldTickets).groupBy(new Selector<TicketPoolTicket, OperatingSeat>(){

			@Override
			public OperatingSeat select(TicketPoolTicket item) {
				return item.getSeat();
			}});
		
		for(IGrouping<OperatingSeat, TicketPoolTicket> g : groups)
		{
			
			
			Assert.assertTrue(g.toQuery().count()> 0);
			
			int stop = 0;
			for(TicketPoolTicket t : g.toQuery().orderBy(new Selector<TicketPoolTicket, Integer>(){

				@Override
				public Integer select(TicketPoolTicket item) {
					return item.getDepartureStop();
				}}))
			{
				
				
				Assert.assertEquals(stop, t.getDepartureStop());
				stop = t.getDestinationStop();
			}
			
			Assert.assertEquals(stopCount - 1, stop);
			
			
		}
		
		
		
		
	}