Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
b0684d4
feat(test): MockMvc tests cases for controllers - CommonAPI
Zapper9982 Jul 5, 2025
4034a2c
Merge branch 'PSMRI:develop' into tests/controllers
Zapper9982 Jul 5, 2025
ba1a1e9
fix(test): springcontext overloading fixed for mockmvc
Jul 6, 2025
30423c7
fix(test): fixed according to codeRabbit suggestions
Jul 6, 2025
5c7230e
Delete .vscode/settings.json
Zapper9982 Jul 6, 2025
95e0ecd
fix(test): fixed according to codeRabbit suggestions
Jul 6, 2025
e8664a6
refactor(test):some redundant testfiles deleting
Jul 7, 2025
6e15991
refactor(test):avoiding lenient stubbing and removing unecessary stub…
Jul 7, 2025
d844d6a
misc(test): added GNU General Public license to all testfiles
Jul 7, 2025
7251bf0
fix(test): fixed according to codeRabbit suggestions
Jul 7, 2025
dcff787
coverage(test) : increase coverage for feedback controller and added …
Jul 8, 2025
9d96d04
fix(undo): undo controller change
Jul 8, 2025
17e8555
fix(test): fixed according to codeRabbit suggestions
Jul 8, 2025
e9b2853
feat(test):added new test methods completing the controllers and utils
Jul 11, 2025
3cfa664
the complete change for IEMR wasnt pushed pushing
Jul 11, 2025
a7bbce5
fixing according to coderabbit and adding License
Jul 11, 2025
57ddf11
fixing some minor test issues
Jul 11, 2025
a2997b0
fix: pom xml version change
vishwab1 Jul 31, 2025
87e6629
fix: fixed the user session not found db issue (#269)
vishwab1 Aug 1, 2025
431ee92
Production_ASSAM_Session timeout issue (#270)
vishwab1 Aug 1, 2025
c7e06f7
test(service) : Added unit tests for CommonAPI
Zapper9982 Aug 4, 2025
82e4364
test(service) : Added unit test for CTIServiceImplTest
Zapper9982 Aug 5, 2025
5692283
fix(test) : fixed CTIServiceImplTest
Zapper9982 Aug 5, 2025
c21421d
license(add) : added GNU license to all test files
Zapper9982 Aug 7, 2025
266bc3c
remove(vscode) :settings.json
Zapper9982 Aug 7, 2025
43a5470
Merge pull request #276 from PSMRI/release-3.2.1
drtechie Aug 13, 2025
0910a9b
Move code from Release 3.4.0 to main (#282)
vishwab1 Aug 25, 2025
934ee16
fix(test): Delete src/test/java/com/iemr/common/controller/carestream…
Zapper9982 Sep 1, 2025
12ff5f8
Merge branch 'PSMRI:main' into tests/services-common
Zapper9982 Sep 2, 2025
a33e2f8
test(workflow):workflow working
Zapper9982 Sep 2, 2025
5489097
test(workflow):making changes so that PR comment posted on PR's not f…
Zapper9982 Sep 3, 2025
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
44 changes: 44 additions & 0 deletions .github/workflows/testcase-coverage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: TestCase Coverage Check

on:
pull_request:
types: [opened, synchronize]

permissions: {}

jobs:
build_and_check_coverage:
runs-on: ubuntu-latest
permissions:
contents: read

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Cache Maven dependencies
uses: actions/cache@v3
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-m2-

- name: Build with Maven
run: mvn clean verify

- name: Run Coverage Check
uses: madrapps/jacoco-report@v1.7.2
with:
paths: target/site/jacoco/jacoco.xml
token: ${{ secrets.GITHUB_TOKEN }}
min-coverage-overall: 40
min-coverage-changed-files: 60
title: Code Coverage Report
comment-type: pr_comment
13 changes: 12 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.iemr.common-API</groupId>
<artifactId>common-api</artifactId>
<version>3.1.0</version>
<version>3.4.0</version>
<packaging>war</packaging>

<name>Common-API</name>
Expand Down Expand Up @@ -247,6 +247,17 @@
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/iemr/common/CommonApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.iemr.common.data.users.User;
import com.iemr.common.utils.IEMRApplBeans;

Expand Down Expand Up @@ -63,11 +66,11 @@ public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factor
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);

// Use StringRedisSerializer for keys (userId)
template.setKeySerializer(new StringRedisSerializer());

// Use Jackson2JsonRedisSerializer for values (Users objects)
Jackson2JsonRedisSerializer<User> serializer = new Jackson2JsonRedisSerializer<>(User.class);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);

return template;
Expand Down
15 changes: 9 additions & 6 deletions src/main/java/com/iemr/common/config/RedisConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
import org.springframework.data.redis.serializer.StringRedisSerializer;
import org.springframework.session.data.redis.config.ConfigureRedisAction;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.iemr.common.data.users.User;

@Configuration
Expand All @@ -40,15 +43,15 @@ public ConfigureRedisAction configureRedisAction() {
}

@Bean
public RedisTemplate<String, User> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, User> template = new RedisTemplate<>();
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);

// Use StringRedisSerializer for keys (userId)
template.setKeySerializer(new StringRedisSerializer());

// Use Jackson2JsonRedisSerializer for values (Users objects)
Jackson2JsonRedisSerializer<User> serializer = new Jackson2JsonRedisSerializer<>(User.class);
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JavaTimeModule());
mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS);
serializer.setObjectMapper(mapper);
template.setValueSerializer(serializer);

return template;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ public String getVaccinationTypeAndDoseTaken(@RequestHeader(value = "Authorizati
* @return Covid vaccination details of a beneficiary
*/
@Operation(summary = "Getting beneficiary covid vaccination details")

@PostMapping(value = { "/getCovidVaccinationDetails" })
@PostMapping(value = { "/getCovidVaccinationDetails" }, produces = MediaType.APPLICATION_JSON)
public String getCovidVaccinationDetails(
@Param(value = "{\"beneficiaryRegID\":\"Long\"}") @RequestBody CovidVaccinationStatus covidVaccinationStatus,
@RequestHeader(value = "Authorization") String Authorization) {
Expand Down Expand Up @@ -126,7 +125,7 @@ public String getCovidVaccinationDetails(
*/

@Operation(summary = "Save beneficiary covid vaccination details")
@PostMapping(value = { "/saveCovidVaccinationDetails" })
@PostMapping(value = { "/saveCovidVaccinationDetails" }, produces = MediaType.APPLICATION_JSON)
public String saveCovidVaccinationDetails(
@Param(value = "{\"covidVSID\": \"Long\",\"beneficiaryRegID\":\"Long\","
+ "\"CovidVaccineTypeID\":\"Integer\","
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@ public String getSnomedCTRecord(@Param(value = "{\"term\":\"String\"}") @Request
else
output.setResponse(new Gson().toJson(sctdescriptions));

logger.info("ggetSnomedCTRecord response: " + output);
logger.info("getSnomedCTRecord response: " + output);
} catch (Exception e) {
logger.error("ggetSnomedCTRecord failed with error " + e.getMessage(), e);
logger.error("getSnomedCTRecord failed with error " + e.getMessage(), e);
output.setError(e);
}
return output.toString();
Expand All @@ -94,9 +94,9 @@ public String getSnomedCTRecordList(@Param(value = "{\"term\":\"String\"}") @Req
else
output.setResponse("No Records Found");

logger.info("ggetSnomedCTRecord response: " + output);
logger.info("getSnomedCTRecord response: " + output);
} catch (Exception e) {
logger.error("ggetSnomedCTRecord failed with error " + e.getMessage(), e);
logger.error("getSnomedCTRecord failed with error " + e.getMessage(), e);
output.setError(e);
}
return output.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public class Language
private Set<BenDemographics> i_bendemographics;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "m_language")
@Transient
private Set<UserLangMapping> m_UserLangMappings;

@OneToMany(fetch = FetchType.LAZY, mappedBy = "language")
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/iemr/common/data/users/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.Expose;
import com.iemr.common.data.callhandling.OutboundCallRequest;
import com.iemr.common.data.feedback.FeedbackDetails;
Expand Down Expand Up @@ -76,7 +77,7 @@ public class User implements Serializable {

@Expose
// @Transient
@OneToMany(/* mappedBy = "m_user", fetch = FetchType.EAGER */)
@OneToMany(fetch = FetchType.EAGER)
@JoinColumn(updatable = false, insertable = false, name = "userID", referencedColumnName = "userID")
private Set<UserLangMapping> m_UserLangMappings;

Expand Down Expand Up @@ -134,12 +135,15 @@ public class User implements Serializable {
@Column(name = "AadhaarNo")
private String aadhaarNo;
@Expose
@JsonProperty("pan")
@Column(name = "PAN")
private String pAN;
@Expose
@JsonProperty("dob")
@Column(name = "DOB")
private Timestamp dOB;
@Expose
@JsonProperty("doj")
@Column(name = "DOJ")
private Timestamp dOJ;
@Expose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.JsonObject;
import com.google.gson.annotations.Expose;
import com.iemr.common.model.user.TitleModel;
Expand Down Expand Up @@ -211,16 +212,19 @@ public class BeneficiaryModel implements Comparable<BeneficiaryModel> {
@Expose
private Integer occupationId;
@Expose
@JsonProperty("occupationOther")
private String occupationName;
@Expose
private String occupation;
@Expose
@JsonProperty("incomeName")
private String incomeStatus;
@Expose
private BigInteger religionId;
@Expose
private String religion;
@Expose
@JsonProperty("educationQualificationName")
private String education;
@Expose
private Integer providerServiceMapID;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import com.iemr.common.data.beneficiary.Beneficiary;
import com.iemr.common.data.mctshistory.MctsOutboundCallDetail;
Expand Down Expand Up @@ -112,7 +111,6 @@ private void updateBeneficiaryID(String beneficiaryID, Long beneficiaryRegID) {
@Override
public Integer updateBenificiary(BeneficiaryModel benificiaryDetails, String auth) throws IEMRException {
Integer updatedRows = 0;

IdentityEditDTO identityEditDTO = identityBenEditMapper.BenToIdentityEditMapper(benificiaryDetails);
setDemographicDetails(identityEditDTO,benificiaryDetails);

Expand All @@ -122,11 +120,9 @@ public Integer updateBenificiary(BeneficiaryModel benificiaryDetails, String aut
benificiaryDetails.getCreatedBy()));
}
identityEditDTO.setDob(benificiaryDetails.getDOB());
// identityEditDTO.setOtherFields(benificiaryDetails.getOtherFields());
// String jsoninput=new Gson().toJson(identityEditDTO);
updatedRows = identityBeneficiaryService.editIdentityEditDTO(identityEditDTO, auth,
benificiaryDetails.getIs1097());

return updatedRows;
}

Expand All @@ -140,11 +136,22 @@ else if(null != benificiaryDetails.getI_bendemographics().getReligion())
identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligion());
else
identityEditDTO.setReligion(benificiaryDetails.getI_bendemographics().getReligionName());
if(null != benificiaryDetails.getOccupation())
identityEditDTO.setOccupationName(benificiaryDetails.getOccupation());
else
identityEditDTO.setOccupationName(benificiaryDetails.getI_bendemographics().getOccupation());
identityEditDTO.setEducation(benificiaryDetails.getI_bendemographics().getEducationName());

if (null != benificiaryDetails.getOccupation()) {
identityEditDTO.setOccupationName(benificiaryDetails.getOccupation());
} else if (null != benificiaryDetails.getI_bendemographics() &&
null != benificiaryDetails.getI_bendemographics().getOccupation()) {
identityEditDTO.setOccupationName(benificiaryDetails.getI_bendemographics().getOccupation());
} else {
identityEditDTO.setOccupationName(benificiaryDetails.getOccupationName());
}

if (null != benificiaryDetails.getEducation()) {
identityEditDTO.setEducation(benificiaryDetails.getEducation());
} else if (null != benificiaryDetails.getI_bendemographics() &&
null != benificiaryDetails.getI_bendemographics().getEducationName()) {
identityEditDTO.setEducation(benificiaryDetails.getI_bendemographics().getEducationName());
}
if(null != benificiaryDetails.getIncomeStatus())
identityEditDTO.setIncomeStatus(benificiaryDetails.getIncomeStatus());
else
Expand Down Expand Up @@ -206,12 +213,25 @@ else if(null != beneficiaryModel.getI_bendemographics().getReligion())
identityDTO.setReligion(beneficiaryModel.getI_bendemographics().getReligion());
else
identityDTO.setReligion(beneficiaryModel.getI_bendemographics().getReligionName());
if(null != beneficiaryModel.getOccupation())
identityDTO.setOccupationName(beneficiaryModel.getOccupation());
else
identityDTO.setOccupationName(beneficiaryModel.getI_bendemographics().getOccupation());
if(null != beneficiaryModel.getI_bendemographics().getEducationName())
identityDTO.setEducation(beneficiaryModel.getI_bendemographics().getEducationName());

if (null != beneficiaryModel.getOccupation()) {
identityDTO.setOccupationName(beneficiaryModel.getOccupation());
} else if (null != beneficiaryModel.getI_bendemographics() &&
null != beneficiaryModel.getI_bendemographics().getOccupation()) {
identityDTO.setOccupationName(beneficiaryModel.getI_bendemographics().getOccupation());
} else {
identityDTO.setOccupationName(beneficiaryModel.getOccupationName());
}

if (null != beneficiaryModel.getEducation()) {
identityDTO.setEducation(beneficiaryModel.getEducation());
} else if (null != beneficiaryModel.getI_bendemographics() &&
null != beneficiaryModel.getI_bendemographics().getEducationName()) {
identityDTO.setEducation(beneficiaryModel.getI_bendemographics().getEducationName());
}



if(null != beneficiaryModel.getIncomeStatus())
identityDTO.setIncomeStatus(beneficiaryModel.getIncomeStatus());
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public void setFeedbackRepository(FeedbackRepository feedbackRepository) {

@Override
public String SendEmail(String request, String authToken) throws Exception {
ObjectMapper objectMapper = new ObjectMapper();
ObjectMapper objectMapper = new ObjectMapper();
EmailNotification notification = objectMapper.readValue(request, EmailNotification.class);

FeedbackDetails feedbackDetail = feedbackRepository.getFeedback(notification.getFeedbackID());
Expand Down Expand Up @@ -154,11 +154,15 @@ public String SendEmail(String request, String authToken) throws Exception {
feedbackdescription = feedbackDetail.getFeedback();
}

// Ensure all replacements are non-null
benName = benName == null ? "" : benName;
complaintAgainst = complaintAgainst == null ? "" : complaintAgainst;
feedbackdescription = feedbackdescription == null ? "" : feedbackdescription;

emailToSend = emailTemplate.getEmailTemplate().replace("BENEFICIARY_NAME", benName)
.replace("COMPLAINT_AGAINST", complaintAgainst).replace("FEEDBACK_DESCERIPTION", feedbackdescription);

if (subDistrictName != null) {

emailToSend = emailToSend.replace("SUB_DISTRICT_NAME", subDistrictName);
} else {
emailToSend = emailToSend.replace("from SUB_DISTRICT_NAME", "");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ else if (manualOrMissed != null && manualOrMissed.equalsIgnoreCase("missed"))
}
}

count=everwellFeedbackRepo.updateDuplicateRecords(patientDetails.getId(), patientDetails.getDateOfAction());
count=everwellFeedbackRepo.updateDuplicateRecords(patientDetails.getId(), patientDetails.getDateOfAction());
} catch (Exception e) {
logger.info("Error in everwell data sync - " + e);
}
Expand Down Expand Up @@ -534,11 +534,9 @@ public ResponseEntity<String> restTemplate(MultiValueMap<String, String> request

public ResponseEntity<String> restTemplatePUT(MultiValueMap<String, String> requestObj, String url,
HttpHeaders headers) {
RestTemplate restTemplate = new RestTemplate();

// Use the injected or field RestTemplate for testability
HttpEntity<Object> request = new HttpEntity<Object>(requestObj, headers);
ResponseEntity<String> response = restTemplate.exchange(url, HttpMethod.PUT, request, String.class);

ResponseEntity<String> response = restTemplateLogin.exchange(url, HttpMethod.PUT, request, String.class);
return response;
}

Expand Down
Loading