OwnerCurator extends AbstractHibernateCurator<Owner> { public Owner getByUpstreamUuid(String upstreamUuid) { return (Owner) createSecureCriteria() .createCriteria("upstreamConsumer") .add(Restrictions.eq("uuid", upstreamUuid)) .uniqueResult(); } OwnerCurator(); Owner findOwnerById(String ownerId); @Transactional Owner replicate(Owner owner); @Transactional @Override Owner create(Owner entity); @Transactional Owner getByKeySecure(String key); Owner lockAndLoadByKey(String key); @Transactional Owner getByKey(String key); @Transactional CandlepinQuery<Owner> getByKeys(Collection<String> keys); Owner getByUpstreamUuid(String upstreamUuid); CandlepinQuery<Owner> getOwnersByActiveProduct(Collection<String> productIds); @SuppressWarnings("checkstyle:indentation") CandlepinQuery<Owner> getOwnersWithProducts(Collection<String> productIds); CandlepinQuery<String> getConsumerIds(Owner owner); @SuppressWarnings("unchecked") CandlepinQuery<String> getConsumerIds(String ownerId); CandlepinQuery<String> getConsumerUuids(Owner owner); @SuppressWarnings("unchecked") CandlepinQuery<String> getConsumerUuids(String ownerId);  }
@Test public void getByUpstreamUuid() { Owner owner = new Owner("owner1"); owner = ownerCurator.create(owner); ConsumerType type = new ConsumerType(ConsumerTypeEnum.CANDLEPIN); consumerTypeCurator.create(type); UpstreamConsumer uc = new UpstreamConsumer("test-upstream-consumer", owner, type, "someuuid"); owner.setUpstreamConsumer(uc); ownerCurator.merge(owner); Owner found = ownerCurator.getByUpstreamUuid("someuuid"); assertNotNull(found); assertEquals(owner.getId(), found.getId()); }