@Test public void getQueryWithTenantIdTest() { List<Object> preparedStatementValues = new ArrayList<>(); Mockito.doReturn("500").when(applicationProperties).getSearchPageSizeDefault(); String expectedQueryWithTenantId = "SELECT *," + "disposal.id as disposalId,disposal.tenantid as tenantid ,disposal.assetid as assetid,disposal.buyername as buyername ," + "disposal.buyeraddress as buyeraddress,disposal.disposalreason as disposalreason,disposal.disposaldate as disposaldate,disposal.pancardnumber as pancardnumber," + "disposal.aadharcardnumber as aadharcardnumber,disposal.assetcurrentvalue as assetcurrentvalue ,disposal.salevalue as salevalue ,disposal.transactiontype as transactiontype," + "disposal.assetsaleaccount as assetsaleaccount," + " disposal.profitlossvoucherreference as profitlossvoucherreference FROM " + " egasset_disposal as disposal WHERE disposal.tenantId = ? AND disposal.assetid IN (10,20) LIMIT ? OFFSET ?"; List<Long> assetIds = new ArrayList<>(); assetIds.add(10L); assetIds.add(20L); DisposalCriteria disposalCriteria = DisposalCriteria.builder().tenantId("ap.kurnool").assetId(assetIds).build(); assertEquals(expectedQueryWithTenantId, disposalQueryBuilder.getQuery(disposalCriteria, preparedStatementValues)); List<Object> expectedPreparedStatementValues = new ArrayList<>(); expectedPreparedStatementValues.add("ap.kurnool"); expectedPreparedStatementValues.add(Long.valueOf("500")); expectedPreparedStatementValues.add(Long.valueOf("0")); assertTrue(preparedStatementValues.equals(expectedPreparedStatementValues)); }
@SuppressWarnings("rawtypes") public String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, disposalCriteria); addPagingClause(selectQuery, preparedStatementValues, disposalCriteria); log.info("Query from asset querybuilde for search : " + selectQuery); return selectQuery.toString(); }
DisposalQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, disposalCriteria); addPagingClause(selectQuery, preparedStatementValues, disposalCriteria); log.info("Query from asset querybuilde for search : " + selectQuery); return selectQuery.toString(); } }
DisposalQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, disposalCriteria); addPagingClause(selectQuery, preparedStatementValues, disposalCriteria); log.info("Query from asset querybuilde for search : " + selectQuery); return selectQuery.toString(); }  }
DisposalQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, disposalCriteria); addPagingClause(selectQuery, preparedStatementValues, disposalCriteria); log.info("Query from asset querybuilde for search : " + selectQuery); return selectQuery.toString(); }  @SuppressWarnings("rawtypes") String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues); }
DisposalQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, disposalCriteria); addPagingClause(selectQuery, preparedStatementValues, disposalCriteria); log.info("Query from asset querybuilde for search : " + selectQuery); return selectQuery.toString(); }  @SuppressWarnings("rawtypes") String getQuery(final DisposalCriteria disposalCriteria, final List preparedStatementValues); static final String INSERT_QUERY; public String BASE_QUERY; }