MarkScaleValueQueryBuilder extends AbstractQueryBuilder<MarkScaleValue> { @Override protected BaseQueryBuilder build(final MarkScaleValue context, final BaseQueryBuilder builder) { return builder .where() .openBracket() .addAndCondition(MARKSCALE_CONDITION, context.getMarkScale()) .addAndCondition(STRVALUE_CONDITION, context.getStrValue()) .closeBracket(); }    }
@Test public void testBuild() throws Exception { MarkScaleValue context = new MarkScaleValue(); String expected = "SELECT e FROM MarkScaleValue e WHERE e.status=:status AND e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<MarkScaleValue> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithDisabledSecurityConstraints() throws Exception { unit.setSecurity(false); MarkScaleValue context = new MarkScaleValue(); String expected = "SELECT e FROM MarkScaleValue e WHERE e.status=:status "; MultiplePagedSearch<MarkScaleValue> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithDisabledStatusConstraint() throws Exception { unit.setActive(false); MarkScaleValue context = new MarkScaleValue(); String expected = "SELECT e FROM MarkScaleValue e WHERE e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<MarkScaleValue> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithDisabledDefaultConstraint() throws Exception { unit.setActive(false); unit.setSecurity(false); MarkScaleValue context = new MarkScaleValue(); String expected = "SELECT e FROM MarkScaleValue e "; MultiplePagedSearch<MarkScaleValue> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithParameters() throws Exception { String strValue = "strValue"; MarkScale markScale = new MarkScale(); markScale.setId(1L); MarkScaleValue context = new MarkScaleValue(); context.setStrValue(strValue); context.setMarkScale(markScale); String expected = "SELECT e FROM MarkScaleValue e WHERE ( e.markScale = :markScale AND e.strValue LIKE CONCAT('%',:strValue,'%') ) AND e.status=:status AND e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<MarkScaleValue> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithParametersWithDisabledDefaultConstraints() throws Exception { unit.setActive(false); unit.setSecurity(false); String strValue = "strValue"; MarkScale markScale = new MarkScale(); markScale.setId(1L); MarkScaleValue context = new MarkScaleValue(); context.setStrValue(strValue); context.setMarkScale(markScale); String expected = "SELECT e FROM MarkScaleValue e WHERE ( e.markScale = :markScale AND e.strValue LIKE CONCAT('%',:strValue,'%') ) "; MultiplePagedSearch<MarkScaleValue> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }