Skip to content

Commit

Permalink
Merge branch 'Dev-2.0-esign' into Dev-2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sriranjan-s authored Aug 30, 2024
2 parents 74e567c + 7b71ec2 commit 80a9db5
Show file tree
Hide file tree
Showing 32 changed files with 745 additions and 996 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,6 @@ public BillResponseV2 fetchBill(GenerateBillCriteria billCriteria, RequestInfoWr
log.info( "If bills are empty" +bills.size());
//if(!billCriteria.getBusinessService().equalsIgnoreCase("WS") && !billCriteria.getBusinessService().equalsIgnoreCase("SW"))
//if(!billCriteria.getBusinessService().equalsIgnoreCase("SW"))
if(!billCriteria.getBusinessService().equalsIgnoreCase("BPA.NC_SAN_FEE"))
updateDemandsForexpiredBillDetails(billCriteria.getBusinessService(), billCriteria.getConsumerCode(), billCriteria.getTenantId(), requestInfoWrapper);
return generateBill(billCriteria, requestInfo);
}
Expand Down Expand Up @@ -380,7 +379,7 @@ public BillResponseV2 generateBill(GenerateBillCriteria billCriteria, RequestInf
consumerCodes.addAll(billCriteria.getConsumerCode());

DemandCriteria demandCriteria=new DemandCriteria();
if(billCriteria.getBusinessService().equalsIgnoreCase("WS") || billCriteria.getBusinessService().equalsIgnoreCase("SW") || billCriteria.getBusinessService().equalsIgnoreCase("BPA.NC_SAN_FEE"))
if(billCriteria.getBusinessService().equalsIgnoreCase("WS") || billCriteria.getBusinessService().equalsIgnoreCase("SW"))
demandCriteria = DemandCriteria.builder()
.status(org.egov.demand.model.Demand.StatusEnum.ACTIVE.toString())
.businessService(billCriteria.getBusinessService())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
import org.springframework.jdbc.core.SingleColumnRowMapper;
import org.springframework.stereotype.Component;

import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

@Component
@Slf4j
public class EscalationRepository {


Expand Down Expand Up @@ -46,8 +43,6 @@ public List<String> getBusinessIds(EscalationSearchCriteria criteria){
else {
query = queryBuilder.getEscalationQuery(criteria, preparedStmtList);
}
log.info("query is"+query);
log.info("params are " +preparedStmtList.toString());
List<String> businessIds = jdbcTemplate.query(query, preparedStmtList.toArray(), new SingleColumnRowMapper<>(String.class));
return businessIds;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,12 @@ public String getEscalationQuery(EscalationSearchCriteria criteria, List<Object>
preparedStmtList.add(criteria.getStatus());

if(criteria.getStateSlaExceededBy() != null){
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime > ? ");
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime - wf.statesla > ? ");
preparedStmtList.add(criteria.getStateSlaExceededBy());
}

if(criteria.getBusinessSlaExceededBy() != null){
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime > ? ");
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime - wf.businessservicesla > ? ");
preparedStmtList.add(criteria.getBusinessSlaExceededBy());
}

Expand Down Expand Up @@ -92,7 +92,7 @@ public String getEscalationQueryFiltered(EscalationSearchCriteria criteria,List<
}

if(criteria.getBusinessSlaExceededBy() != null){
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime > ? ");
builder.append(" AND (select extract(epoch from current_timestamp)) * 1000 - wf.createdtime - wf.businessservicesla > ? ");
preparedStmtList.add(criteria.getBusinessSlaExceededBy());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,6 @@ private void processEscalation(RequestInfo requestInfo, Escalation escalation, L
Integer numberOfBusinessIds = businessIds.size();
Integer batchSize = config.getEscalationBatchSize();

log.info("Records to process"+numberOfBusinessIds);

for(int i = 0; i < numberOfBusinessIds; i = i + batchSize){

// Processing the businessIds in batches
Expand Down
Original file line number Diff line number Diff line change
@@ -1,96 +1,96 @@
package org.egov.wf.repository.querybuilder;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;

import org.egov.wf.web.models.EscalationSearchCriteria;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@ContextConfiguration(classes = {EscalationQueryBuilder.class})
@ExtendWith(SpringExtension.class)
class EscalationQueryBuilderTest {
@Autowired
private EscalationQueryBuilder escalationQueryBuilder;


@Test
void testGetEscalationQuery() {
EscalationSearchCriteria escalationSearchCriteria = mock(EscalationSearchCriteria.class);
when(escalationSearchCriteria.getBusinessSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getStateSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getBusinessService()).thenReturn("Business Service");
when(escalationSearchCriteria.getStatus()).thenReturn("Status");
when(escalationSearchCriteria.getTenantId()).thenReturn("42");
ArrayList<Object> objectList = new ArrayList<>();
assertEquals(
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime > ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime > ? ",
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
verify(escalationSearchCriteria, atLeast(1)).getBusinessSlaExceededBy();
verify(escalationSearchCriteria, atLeast(1)).getStateSlaExceededBy();
verify(escalationSearchCriteria).getBusinessService();
verify(escalationSearchCriteria).getStatus();
verify(escalationSearchCriteria).getTenantId();
assertEquals(5, objectList.size());
}


@Test
void testGetEscalationQuerywithstatesla() {
EscalationSearchCriteria escalationSearchCriteria = mock(EscalationSearchCriteria.class);
when(escalationSearchCriteria.getBusinessSlaExceededBy()).thenReturn(null);
when(escalationSearchCriteria.getStateSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getBusinessService()).thenReturn("Business Service");
when(escalationSearchCriteria.getStatus()).thenReturn("Status");
when(escalationSearchCriteria.getTenantId()).thenReturn("42");
ArrayList<Object> objectList = new ArrayList<>();
assertEquals(
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime > ? ",
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
verify(escalationSearchCriteria).getBusinessSlaExceededBy();
verify(escalationSearchCriteria, atLeast(1)).getStateSlaExceededBy();
verify(escalationSearchCriteria).getBusinessService();
verify(escalationSearchCriteria).getStatus();
verify(escalationSearchCriteria).getTenantId();
assertEquals(4, objectList.size());
}

@Test
void testGetEscalationQuerywithbusinessservicesla() {
EscalationSearchCriteria escalationSearchCriteria = mock(EscalationSearchCriteria.class);
when(escalationSearchCriteria.getBusinessSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getStateSlaExceededBy()).thenReturn(null);
when(escalationSearchCriteria.getBusinessService()).thenReturn("Business Service");
when(escalationSearchCriteria.getStatus()).thenReturn("Status");
when(escalationSearchCriteria.getTenantId()).thenReturn("42");
ArrayList<Object> objectList = new ArrayList<>();
assertEquals(
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime > ? ",
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
verify(escalationSearchCriteria, atLeast(1)).getBusinessSlaExceededBy();
verify(escalationSearchCriteria).getStateSlaExceededBy();
verify(escalationSearchCriteria).getBusinessService();
verify(escalationSearchCriteria).getStatus();
verify(escalationSearchCriteria).getTenantId();
assertEquals(4, objectList.size());
}
}
package org.egov.wf.repository.querybuilder;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import java.util.ArrayList;

import org.egov.wf.web.models.EscalationSearchCriteria;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;

@ContextConfiguration(classes = {EscalationQueryBuilder.class})
@ExtendWith(SpringExtension.class)
class EscalationQueryBuilderTest {
@Autowired
private EscalationQueryBuilder escalationQueryBuilder;


@Test
void testGetEscalationQuery() {
EscalationSearchCriteria escalationSearchCriteria = mock(EscalationSearchCriteria.class);
when(escalationSearchCriteria.getBusinessSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getStateSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getBusinessService()).thenReturn("Business Service");
when(escalationSearchCriteria.getStatus()).thenReturn("Status");
when(escalationSearchCriteria.getTenantId()).thenReturn("42");
ArrayList<Object> objectList = new ArrayList<>();
assertEquals(
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime - wf.statesla > ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime - wf.businessservicesla > ? ",
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
verify(escalationSearchCriteria, atLeast(1)).getBusinessSlaExceededBy();
verify(escalationSearchCriteria, atLeast(1)).getStateSlaExceededBy();
verify(escalationSearchCriteria).getBusinessService();
verify(escalationSearchCriteria).getStatus();
verify(escalationSearchCriteria).getTenantId();
assertEquals(5, objectList.size());
}


@Test
void testGetEscalationQuerywithstatesla() {
EscalationSearchCriteria escalationSearchCriteria = mock(EscalationSearchCriteria.class);
when(escalationSearchCriteria.getBusinessSlaExceededBy()).thenReturn(null);
when(escalationSearchCriteria.getStateSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getBusinessService()).thenReturn("Business Service");
when(escalationSearchCriteria.getStatus()).thenReturn("Status");
when(escalationSearchCriteria.getTenantId()).thenReturn("42");
ArrayList<Object> objectList = new ArrayList<>();
assertEquals(
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime - wf.statesla > ? ",
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
verify(escalationSearchCriteria).getBusinessSlaExceededBy();
verify(escalationSearchCriteria, atLeast(1)).getStateSlaExceededBy();
verify(escalationSearchCriteria).getBusinessService();
verify(escalationSearchCriteria).getStatus();
verify(escalationSearchCriteria).getTenantId();
assertEquals(4, objectList.size());
}

@Test
void testGetEscalationQuerywithbusinessservicesla() {
EscalationSearchCriteria escalationSearchCriteria = mock(EscalationSearchCriteria.class);
when(escalationSearchCriteria.getBusinessSlaExceededBy()).thenReturn(1L);
when(escalationSearchCriteria.getStateSlaExceededBy()).thenReturn(null);
when(escalationSearchCriteria.getBusinessService()).thenReturn("Business Service");
when(escalationSearchCriteria.getStatus()).thenReturn("Status");
when(escalationSearchCriteria.getTenantId()).thenReturn("42");
ArrayList<Object> objectList = new ArrayList<>();
assertEquals(
"select businessId from ( SELECT *,RANK () OVER (PARTITION BY businessId ORDER BY createdtime DESC)"
+ " rank_number FROM eg_wf_processinstance_v2 WHERE businessservice = ? AND tenantid= ? ) wf WHERE"
+ " rank_number = 1 AND wf.status = ? AND (select extract(epoch from current_timestamp)) * 1000 -"
+ " wf.createdtime - wf.businessservicesla > ? ",
this.escalationQueryBuilder.getEscalationQuery(escalationSearchCriteria, objectList));
verify(escalationSearchCriteria, atLeast(1)).getBusinessSlaExceededBy();
verify(escalationSearchCriteria).getStateSlaExceededBy();
verify(escalationSearchCriteria).getBusinessService();
verify(escalationSearchCriteria).getStatus();
verify(escalationSearchCriteria).getTenantId();
assertEquals(4, objectList.size());
}
}

Loading

0 comments on commit 80a9db5

Please sign in to comment.