EnvironmentCurator extends AbstractHibernateCurator<Environment> { @SuppressWarnings("unchecked") public CandlepinQuery<Environment> listForOwnerByName(Owner o, String envName) { DetachedCriteria criteria = this.createSecureDetachedCriteria() .add(Restrictions.eq("owner", o)) .add(Restrictions.eq("name", envName)); return this.cpQueryFactory.<Environment>buildQuery(this.currentSession(), criteria); } EnvironmentCurator(); Environment getConsumerEnvironment(Consumer consumer); CandlepinQuery<Consumer> getEnvironmentConsumers(Environment environment); CandlepinQuery<Consumer> getEnvironmentConsumers(String environmentId); @SuppressWarnings("unchecked") CandlepinQuery<Environment> listForOwner(Owner o); @SuppressWarnings("unchecked") CandlepinQuery<Environment> listForOwnerByName(Owner o, String envName); @SuppressWarnings("unchecked") List<Environment> listWithContent(Set<String> contentIds); int deleteEnvironmentsForOwner(Owner owner); String getEnvironmentIdByName(String ownerId, String envName);  }
@Test public void listForOwnerByName() { Environment e = envCurator.create(new Environment("env2", "Another Env", owner)); List<Environment> envs = envCurator.listForOwnerByName(owner, "Another Env").list(); assertEquals(1, envs.size()); assertEquals(e, envs.get(0)); }