MarkScaleExchangeQueryBuilder extends AbstractQueryBuilder<MarkScaleExchange> { @Override protected BaseQueryBuilder build(final MarkScaleExchange context, final BaseQueryBuilder builder) { return builder .where() .openBracket() .addAndCondition(MARKSCALE_CONDITION, context.getMarkScale()) .addAndCondition(MARKSCALEVALUE_CONDITION, context.getMarkScaleValue()) .addAndCondition(MARKSCALEEXCHANGE_CONDITION, context.getMarkScaleExchange()) .addAndCondition(MARKSCALEEXCHANGEVALUE_CONDITION, context.getMarkScaleExchangeValue()) .addAndCondition(MARKMIN_CONDITION, context.getMarkMin()) .addAndCondition(MARKMAX_CONDITION, context.getMarkMax()) .addAndCondition(MARKEXCHANGE_CONDITION, context.getMarkExchange()) .closeBracket(); }    }
@Test public void testBuild() throws Exception { MarkScaleExchange context = new MarkScaleExchange(); String expected = "SELECT e FROM MarkScaleExchange e WHERE e.status=:status AND e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<MarkScaleExchange> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithDisabledSecurityConstraints() throws Exception { unit.setSecurity(false); MarkScaleExchange context = new MarkScaleExchange(); String expected = "SELECT e FROM MarkScaleExchange e WHERE e.status=:status "; MultiplePagedSearch<MarkScaleExchange> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithDisabledStatusConstraint() throws Exception { unit.setActive(false); MarkScaleExchange context = new MarkScaleExchange(); String expected = "SELECT e FROM MarkScaleExchange e WHERE e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<MarkScaleExchange> 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); MarkScaleExchange context = new MarkScaleExchange(); String expected = "SELECT e FROM MarkScaleExchange e "; MultiplePagedSearch<MarkScaleExchange> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }
@Test public void testBuildWithParameters() throws Exception { Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; MarkScale markscale = new MarkScale(); markscale.setId(1L); MarkScaleValue markscaleValue = new MarkScaleValue(); markscaleValue.setId(1L); MarkScale markscaleExchange = new MarkScale(); markscaleExchange.setId(2L); MarkScaleValue markscaleExchangeValue = new MarkScaleValue(); markscaleExchangeValue.setId(2L); MarkScaleExchange context = new MarkScaleExchange(); context.setMarkMin(markMin); context.setMarkMax(markMax); context.setMarkExchange(markExchange); context.setMarkScale(markscale); context.setMarkScaleValue(markscaleValue); context.setMarkScaleExchange(markscaleExchange); context.setMarkScaleExchangeValue(markscaleExchangeValue); String expected = "SELECT e FROM MarkScaleExchange e WHERE ( e.markScale = :markScale AND e.markScaleValue = :markScaleValue AND e.markScaleExchange = :markScaleExchange AND e.markScaleExchangeValue = :markScaleExchangeValue AND e.markMin = :markMin AND e.markMax = :markMax AND e.markExchange = :markExchange ) AND e.status=:status AND e.crtUserGroup IN (:userGroups) "; MultiplePagedSearch<MarkScaleExchange> 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); Double markMin = 0.0; Double markMax = 10.0; Double markExchange = 5.0; MarkScale markscale = new MarkScale(); markscale.setId(1L); MarkScaleValue markscaleValue = new MarkScaleValue(); markscaleValue.setId(1L); MarkScale markscaleExchange = new MarkScale(); markscaleExchange.setId(2L); MarkScaleValue markscaleExchangeValue = new MarkScaleValue(); markscaleExchangeValue.setId(2L); MarkScaleExchange context = new MarkScaleExchange(); context.setMarkMin(markMin); context.setMarkMax(markMax); context.setMarkExchange(markExchange); context.setMarkScale(markscale); context.setMarkScaleValue(markscaleValue); context.setMarkScaleExchange(markscaleExchange); context.setMarkScaleExchangeValue(markscaleExchangeValue); String expected = "SELECT e FROM MarkScaleExchange e WHERE ( e.markScale = :markScale AND e.markScaleValue = :markScaleValue AND e.markScaleExchange = :markScaleExchange AND e.markScaleExchangeValue = :markScaleExchangeValue AND e.markMin = :markMin AND e.markMax = :markMax AND e.markExchange = :markExchange ) "; MultiplePagedSearch<MarkScaleExchange> pagedSearch = new MultiplePagedSearch<>(); pagedSearch.setEntity(context); String actualQuery = unit.build(pagedSearch); assertEquals(expected, actualQuery); }