Skip to content
Open
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
11 changes: 11 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
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
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
Empty file.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.common.config.quartz;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.iemr.common.service.ctiCall.CallCentreDataSync;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

@ExtendWith(MockitoExtension.class)
class ScheduleForCallCentreTest {

@Mock
private CallCentreDataSync callCentreDataSync;

@Mock
private JobExecutionContext jobExecutionContext;

@InjectMocks
private ScheduleForCallCentre scheduleForCallCentre;

@Test
void testExecute_CallsCtiDataSync() throws JobExecutionException {
// When
scheduleForCallCentre.execute(jobExecutionContext);

// Then
verify(callCentreDataSync, times(1)).ctiDataSync();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.common.config.quartz;

import com.iemr.common.service.everwell.EverwellDataSync;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import static org.mockito.Mockito.verify;

class ScheduleForEverwellDataSyncTest {

@Mock
private EverwellDataSync everwellDataSync;

@Mock
private JobExecutionContext jobExecutionContext;

@InjectMocks
private ScheduleForEverwellDataSync scheduleForEverwellDataSync;

@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
}

@Test
void testExecute() throws JobExecutionException {
// Call the method under test
scheduleForEverwellDataSync.execute(jobExecutionContext);

// Verify that dataSyncToEverwell method was called on everwellDataSync
verify(everwellDataSync).dataSyncToEverwell();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.common.config.quartz;

import com.iemr.common.service.everwell.EverwellRegistrationService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;

class ScheduleForEverwellRegistrationTest {

@Mock
private EverwellRegistrationService registrationService;

@Mock
private JobExecutionContext jobExecutionContext; // Mock the JobExecutionContext passed to execute method

@InjectMocks
private ScheduleForEverwellRegistration scheduleForEverwellRegistration;

@BeforeEach
void setUp() {
MockitoAnnotations.openMocks(this);
}

@Test
void testExecute() throws JobExecutionException {
// Call the execute method
scheduleForEverwellRegistration.execute(jobExecutionContext);

// Verify that the registerBeneficiary method of registrationService was called exactly once
verify(registrationService, times(1)).registerBeneficiary();

// No need to mock or verify the behavior of jobExecutionContext.getClass().getName()
// as it's used for logging and doesn't affect the core logic being tested.
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*
* AMRIT – Accessible Medical Records via Integrated Technology
* Integrated EHR (Electronic Health Records) Solution
*
* Copyright (C) "Piramal Swasthya Management and Research Institute"
*
* This file is part of AMRIT.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
package com.iemr.common.config.quartz;

import com.iemr.common.service.nhm_dashboard.NHM_DashboardService;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import static org.mockito.Mockito.*;

@ExtendWith(MockitoExtension.class)
class ScheduleJobForNHMDashboardDataTest {

@Mock
private NHM_DashboardService nhmDashboardService;

@Mock
private JobExecutionContext jobExecutionContext; // Mock JobExecutionContext as it's an input parameter

@InjectMocks
private ScheduleJobForNHMDashboardData scheduleJobForNHMDashboardData;

@BeforeEach
void setUp() {
// No specific setup needed for mocks beyond @Mock and @InjectMocks
// For jobExecutionContext.getClass().getName(), we can just return a dummy string.
// However, since it's only used for logging and we're not verifying logging behavior directly,
// it's not strictly necessary to stub it unless it causes a NullPointerException.
// In this case, getClass().getName() on a mock object will just return the mock class name, which is fine.
}

@Test
void testExecute_Success() throws JobExecutionException, Exception {
// Arrange
String expectedServiceResult = "Data pull successful";
when(nhmDashboardService.pull_NHM_Data_CTI()).thenReturn(expectedServiceResult);

// Act
scheduleJobForNHMDashboardData.execute(jobExecutionContext);

// Assert
verify(nhmDashboardService, times(1)).pull_NHM_Data_CTI();
// No direct assertion on logger output as per instructions to avoid unnecessary mocking.
}

@Test
void testExecute_ExceptionDuringDataPull() throws JobExecutionException, Exception {
// Arrange
String errorMessage = "Failed to pull data";
when(nhmDashboardService.pull_NHM_Data_CTI()).thenThrow(new RuntimeException(errorMessage));

// Act
scheduleJobForNHMDashboardData.execute(jobExecutionContext);

// Assert
verify(nhmDashboardService, times(1)).pull_NHM_Data_CTI();
// No direct assertion on logger output as per instructions to avoid unnecessary mocking.
// The method catches the exception and logs it, it does not rethrow JobExecutionException.
}
}
Loading