Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.iemr.common.flw</groupId>
<artifactId>flw-api</artifactId>
<version>3.8.3</version>
<version>3.11.0</version>
<packaging>war</packaging>

<name>FLW-API</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.iemr.flw.dto.iemr.FormResponseDTO;
import com.iemr.flw.repo.iemr.DynamicFormRepo;
import com.iemr.flw.service.DynamicFormResponseService;
import com.iemr.flw.service.NotificationService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
Expand Down
678 changes: 339 additions & 339 deletions src/test/java/com/iemr/flw/controller/ChildCareControllerTest.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void getPregnantWomanList_noRecordFound() throws Exception {
@Test
void saveANCVisit_success() throws Exception {
List<ANCVisitDTO> dtos = Collections.singletonList(new ANCVisitDTO());
when(maternalHealthService.saveANCVisit(any())).thenReturn("success");
// when(maternalHealthService.saveANCVisit(any())).thenReturn("success");
mockMvc.perform(post("/maternalCare/ancVisit/saveAll")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer token")
Expand Down Expand Up @@ -432,7 +432,7 @@ void getPregnantWomanList_exception() throws Exception {
@Test
void saveANCVisit_exception() throws Exception {
List<ANCVisitDTO> dtos = Collections.singletonList(new ANCVisitDTO());
when(maternalHealthService.saveANCVisit(any())).thenThrow(new RuntimeException("fail"));
// when(maternalHealthService.saveANCVisit(any())).thenThrow(new RuntimeException("fail"));
mockMvc.perform(post("/maternalCare/ancVisit/saveAll")
.contentType(MediaType.APPLICATION_JSON)
.header("Authorization", "Bearer token")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ void testGetBenData_withValidRequest_success() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

// //when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//
setupMappingDataMocks();
setupHealthDetailsMocks();

Expand Down Expand Up @@ -103,7 +103,7 @@ void testGetBenData_withDateRange_success() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataWithinDates("testUser", fromDate, toDate, pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
// //when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupMappingDataMocks();
setupHealthDetailsMocks();
Expand Down Expand Up @@ -228,7 +228,7 @@ void testGetBenData_withCompleteMapping_success() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
// //when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupCompleteEntityMocks();
setupHealthDetailsMocks();
Expand Down Expand Up @@ -259,7 +259,7 @@ void testGetBenData_ageCalculation_years() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
// //when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

// Create detail with DOB 25 years ago
RMNCHMBeneficiarydetail detail = createTestBeneficiaryDetail();
Expand Down Expand Up @@ -287,7 +287,7 @@ void testGetBenData_ageCalculation_months() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

// Create detail with DOB 6 months ago
RMNCHMBeneficiarydetail detail = createTestBeneficiaryDetail();
Expand Down Expand Up @@ -315,7 +315,7 @@ void testGetBenData_ageCalculation_days() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

// Create detail with DOB 15 days ago
RMNCHMBeneficiarydetail detail = createTestBeneficiaryDetail();
Expand Down Expand Up @@ -343,19 +343,19 @@ void testGetBenData_relatedBeneficiaryIds_parsing() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

// Create RMNCH details with related beneficiary IDs
RMNCHBeneficiaryDetailsRmnch rmnchDetails = createTestRMNCHBeneficiaryDetails();
rmnchDetails.setRelatedBeneficiaryIdsDB("123,456,789");

when(beneficiaryRepo.getDetailsByRegID(mapping.getBenRegId().longValue())).thenReturn(rmnchDetails);
//when(beneficiaryRepo.getDetailsByRegID(mapping.getBenRegId().longValue())).thenReturn(rmnchDetails);

// Setup minimal required mocks (avoid unnecessary stubbings)
when(beneficiaryRepo.getDetailsById(mapping.getBenDetailsId())).thenReturn(createTestBeneficiaryDetail());
when(beneficiaryRepo.getBenIdFromRegID(mapping.getBenRegId().longValue())).thenReturn(BigInteger.valueOf(1000L));
when(beneficiaryRepo.getBornBirthByRegID(mapping.getBenRegId().longValue())).thenReturn(createTestBornBirthDetails());
when(houseHoldRepo.getByHouseHoldID(rmnchDetails.getHouseoldId())).thenReturn(createTestHouseHoldDetails());
// when(houseHoldRepo.getByHouseHoldID(rmnchDetails.getHouseoldId())).thenReturn(createTestHouseHoldDetails());
setupHealthDetailsMocks();

// Act
Expand All @@ -375,7 +375,7 @@ void testGetBenData_withHealthIdFetch_success() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupMappingDataMocks();
setupHealthDetailsMocks();
Expand All @@ -398,7 +398,7 @@ void testGetBenData_healthIdFetchException_continuesProcessing() throws Exceptio

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupMappingDataMocks();
setupHealthDetailsMocks();
Expand All @@ -425,7 +425,7 @@ void testGetBenData_getBenHealthDetails_withValidData() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupMappingDataMocks();

Expand Down Expand Up @@ -458,7 +458,7 @@ void testGetBenData_getBenHealthDetails_emptyHealthDetails() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupMappingDataMocks();

Expand Down Expand Up @@ -486,7 +486,7 @@ void testGetBenData_getBenHealthDetails_nullHealthIdNumber() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

setupMappingDataMocks();

Expand Down Expand Up @@ -516,7 +516,7 @@ void testGetBenData_nullBenRegId_skipsHealthDetails() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(nullRegIdMapping);
// when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(nullRegIdMapping);

// Act
String result = service.getBenData(request, authorization);
Expand All @@ -543,12 +543,12 @@ void testGetBenData_partialMappingData_handlesNulls() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(partialMapping);
// when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(partialMapping);

// Setup minimal mocks for non-null IDs
when(beneficiaryRepo.getDetailsById(partialMapping.getBenDetailsId())).thenReturn(createTestBeneficiaryDetail());
when(beneficiaryRepo.getBenIdFromRegID(partialMapping.getBenRegId().longValue())).thenReturn(BigInteger.valueOf(1000L));
when(beneficiaryRepo.getDetailsByRegID(partialMapping.getBenRegId().longValue())).thenReturn(createTestRMNCHBeneficiaryDetails());
// when(beneficiaryRepo.getDetailsByRegID(partialMapping.getBenRegId().longValue())).thenReturn(createTestRMNCHBeneficiaryDetails());
when(beneficiaryRepo.getBornBirthByRegID(partialMapping.getBenRegId().longValue())).thenReturn(createTestBornBirthDetails());
setupHealthDetailsMocks();

Expand Down Expand Up @@ -576,7 +576,7 @@ void testGetBenData_addressExceptionHandling_continuesProcessing() throws Except

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
when(beneficiaryRepo.getByAddressID(problematicAddress.getId())).thenThrow(new RuntimeException("Database error"));

setupMappingDataMocks();
Expand All @@ -602,7 +602,7 @@ void testGetBenData_nullDob_skipsAgeCalculation() throws Exception {

when(beneficiaryRepo.getUserName(request.getAshaId())).thenReturn("testUser");
when(beneficiaryRepo.getBenDataByUser("testUser", pageRequest)).thenReturn(page);
when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);
//when(beneficiaryRepo.getByAddressID(address.getId())).thenReturn(mapping);

// Create detail with null DOB
RMNCHMBeneficiarydetail detail = createTestBeneficiaryDetail();
Expand Down Expand Up @@ -735,9 +735,9 @@ private void setupMappingDataMocks() {
when(beneficiaryRepo.getAddressById(mapping.getBenAddressId())).thenReturn(address);
when(beneficiaryRepo.getContactById(mapping.getBenContactsId())).thenReturn(contact);
when(beneficiaryRepo.getBenIdFromRegID(mapping.getBenRegId().longValue())).thenReturn(BigInteger.valueOf(1000L));
when(beneficiaryRepo.getDetailsByRegID(mapping.getBenRegId().longValue())).thenReturn(rmnchDetails);
//when(beneficiaryRepo.getDetailsByRegID(mapping.getBenRegId().longValue())).thenReturn(rmnchDetails);
when(beneficiaryRepo.getBornBirthByRegID(mapping.getBenRegId().longValue())).thenReturn(birthDetails);
when(houseHoldRepo.getByHouseHoldID(rmnchDetails.getHouseoldId())).thenReturn(houseHold);
// when(houseHoldRepo.getByHouseHoldID(rmnchDetails.getHouseoldId())).thenReturn(houseHold);
when(beneficiaryRepo.getUserIDByUserName("testUser")).thenReturn(123);
}

Expand All @@ -758,9 +758,9 @@ private void setupOtherEntityMocks() {
when(beneficiaryRepo.getAddressById(mapping.getBenAddressId())).thenReturn(address);
when(beneficiaryRepo.getContactById(mapping.getBenContactsId())).thenReturn(contact);
when(beneficiaryRepo.getBenIdFromRegID(mapping.getBenRegId().longValue())).thenReturn(BigInteger.valueOf(1000L));
when(beneficiaryRepo.getDetailsByRegID(mapping.getBenRegId().longValue())).thenReturn(rmnchDetails);
// //when(beneficiaryRepo.getDetailsByRegID(mapping.getBenRegId().longValue())).thenReturn(rmnchDetails);
when(beneficiaryRepo.getBornBirthByRegID(mapping.getBenRegId().longValue())).thenReturn(birthDetails);
when(houseHoldRepo.getByHouseHoldID(rmnchDetails.getHouseoldId())).thenReturn(houseHold);
// when(houseHoldRepo.getByHouseHoldID(rmnchDetails.getHouseoldId())).thenReturn(houseHold);
when(beneficiaryRepo.getUserIDByUserName("testUser")).thenReturn(123);
}

Expand Down
Loading
Loading