PersonAwardQueryBuilder extends AbstractQueryBuilder<PersonAward> { @Override protected BaseQueryBuilder build(final PersonAward context, final BaseQueryBuilder builder) { return builder .where() .openBracket() .addAndCondition(PERSON_CONDITION, context.getPerson()) .addAndCondition(PERSONPAPER_CONDITION, context.getPersonPaper()) .closeBracket(); }    }
@Test public void testBuild() throws Exception { PersonAward context = new PersonAward(); String expectedQuery = "SELECT e FROM PersonAward e WHERE e.status=:status AND e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<PersonAward> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expectedQuery, actualQuery); }
@Test public void testBuildWithDisabledSecurityConstraint() throws Exception { unit.setSecurity(false); PersonAward context = new PersonAward(); String expectedQuery = "SELECT e FROM PersonAward e WHERE e.status=:status "; MultiplePagedSearch<PersonAward> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expectedQuery, actualQuery); }
@Test public void testBuildWithDisabledStatusConstraint() throws Exception { unit.setActive(false); PersonAward context = new PersonAward(); String expectedQuery = "SELECT e FROM PersonAward e WHERE e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<PersonAward> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expectedQuery, actualQuery); }
@Test public void testBuildWithDisabledDefaultConstraints() throws Exception { unit.setActive(false); unit.setSecurity(false); PersonAward context = new PersonAward(); String expectedQuery = "SELECT e FROM PersonAward e "; MultiplePagedSearch<PersonAward> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expectedQuery, actualQuery); }
@Test public void testBuildWithParameters() throws Exception { PersonPaper personPaper = new PersonPaper(); Person person = new Person(); PersonAward context = new PersonAward(); context.setPerson(person); context.setPersonPaper(personPaper); String expectedQuery = "SELECT e FROM PersonAward e WHERE ( e.person = :person AND e.person = :person ) AND e.status=:status AND e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<PersonAward> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expectedQuery, actualQuery); }
@Test public void testBuildWithParametersAndDisabledDefaultConstraints() throws Exception { unit.setActive(false); unit.setSecurity(false); PersonPaper personPaper = new PersonPaper(); Person person = new Person(); PersonAward context = new PersonAward(); context.setPerson(person); context.setPersonPaper(personPaper); String expectedQuery = "SELECT e FROM PersonAward e WHERE ( e.person = :person AND e.person = :person ) "; MultiplePagedSearch<PersonAward> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expectedQuery, actualQuery); }