GuestIdCurator extends AbstractHibernateCurator<GuestId> { public GuestId findByGuestIdAndOrg(String guestUuid, String ownerId) { return (GuestId) this.currentSession().createCriteria(GuestId.class) .add(Restrictions.eq("guestIdLower", guestUuid.toLowerCase())) .createAlias("consumer", "gconsumer") .add(Restrictions.eq("gconsumer.ownerId", ownerId)) .setMaxResults(1) .uniqueResult(); } GuestIdCurator(); CandlepinQuery<GuestId> listByConsumer(Consumer consumer); GuestId findByConsumerAndId(Consumer consumer, String guestId); GuestId findByGuestIdAndOrg(String guestUuid, String ownerId);  }
@Test public void findByGuestIdAndOrgCaseInsensitive() { String guestId = "GuEsTiD"; Consumer consumer = new Consumer("testConsumer", "testUser", owner, ct); consumer.addGuestId(new GuestId(guestId)); consumerCurator.create(consumer); GuestId result = curator.findByGuestIdAndOrg(guestId.toUpperCase(), owner.getId()); assertEquals(new GuestId(guestId), result); }