@Test public void getQueryWithAssetIdsTest() { final List<Object> preparedStatementValues = new ArrayList<>(); Mockito.doReturn("500").when(applicationProperties).getSearchPageSizeDefault(); final String expectedQueryWithTenantId = "SELECT id,tenantid,assetid,currentcapitalizedvalue,typeofchange,revaluationamount,valueafterrevaluation,revaluationdate,reevaluatedby,reasonforrevaluation,fixedassetswrittenoffaccount," + "function,fund,comments,status,createdby,createddate,lastmodifiedby,lastmodifieddate,voucherreference,revaluationorderno,revaluationorderdate FROM egasset_revalution as revalution WHERE revalution.status = ? AND revalution.tenantId = ? AND revalution.assetid IN (10,20) ORDER BY revalution.revaluationdate desc LIMIT ? OFFSET ?"; final List<Long> assetIds = new ArrayList<>(); assetIds.add(10L); assetIds.add(20L); final RevaluationCriteria revaluationCriteria = RevaluationCriteria.builder().tenantId("ap.kurnool") .assetId(assetIds).build(); assertEquals(expectedQueryWithTenantId, revaluationQueryBuilder.getQuery(revaluationCriteria, preparedStatementValues)); final List<Object> expectedPreparedStatementValues = new ArrayList<>(); expectedPreparedStatementValues.add(Status.APPROVED.toString()); expectedPreparedStatementValues.add("ap.kurnool"); expectedPreparedStatementValues.add(Long.valueOf("500")); expectedPreparedStatementValues.add(Long.valueOf("0")); assertTrue(preparedStatementValues.equals(expectedPreparedStatementValues)); }
@SuppressWarnings("rawtypes") public String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, revaluationCriteria); addPagingClause(selectQuery, preparedStatementValues, revaluationCriteria); log.info("Query from asset revaluation search : " + selectQuery); return selectQuery.toString(); }
RevaluationQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, revaluationCriteria); addPagingClause(selectQuery, preparedStatementValues, revaluationCriteria); log.info("Query from asset revaluation search : " + selectQuery); return selectQuery.toString(); } }
RevaluationQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, revaluationCriteria); addPagingClause(selectQuery, preparedStatementValues, revaluationCriteria); log.info("Query from asset revaluation search : " + selectQuery); return selectQuery.toString(); }  }
RevaluationQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, revaluationCriteria); addPagingClause(selectQuery, preparedStatementValues, revaluationCriteria); log.info("Query from asset revaluation search : " + selectQuery); return selectQuery.toString(); }  @SuppressWarnings("rawtypes") String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues); }
RevaluationQueryBuilder { @SuppressWarnings("rawtypes") public String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues) { final StringBuilder selectQuery = new StringBuilder(BASE_QUERY); log.info("get query"); addWhereClause(selectQuery, preparedStatementValues, revaluationCriteria); addPagingClause(selectQuery, preparedStatementValues, revaluationCriteria); log.info("Query from asset revaluation search : " + selectQuery); return selectQuery.toString(); }  @SuppressWarnings("rawtypes") String getQuery(final RevaluationCriteria revaluationCriteria, final List preparedStatementValues); static final String INSERT_QUERY; public String BASE_QUERY; }