GuestIdCurator extends AbstractHibernateCurator<GuestId> { public CandlepinQuery<GuestId> listByConsumer(Consumer consumer) { DetachedCriteria criteria = this.createSecureDetachedCriteria() .add(Restrictions.eq("consumer", consumer)); return this.cpQueryFactory.<GuestId>buildQuery(this.currentSession(), criteria); } GuestIdCurator(); CandlepinQuery<GuestId> listByConsumer(Consumer consumer); GuestId findByConsumerAndId(Consumer consumer, String guestId); GuestId findByGuestIdAndOrg(String guestUuid, String ownerId);  }
@Test public void listByConsumerTest() { Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct); for (int i = 0; i < 5; i++) { consumer.addGuestId(new GuestId("" + i)); } consumerCurator.create(consumer); List<GuestId> result = curator.listByConsumer(consumer).list(); assertEquals(5, result.size()); for (int i = 0; i < 5; i++) { assertTrue(result.contains(new GuestId("" + i))); } }
@Test public void listByConsumerTestEmpty() { Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct); consumerCurator.create(consumer); List<GuestId> result = curator.listByConsumer(consumer).list(); assertEquals(0, result.size()); }