Skip to content

Commit

Permalink
[ Ritesh ] | BAH-3191 - PR Feedback incorporated for test
Browse files Browse the repository at this point in the history
  • Loading branch information
riteshghiya90 committed Sep 1, 2023
1 parent 00a9975 commit 28e2ced
Showing 1 changed file with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.springframework.context.ApplicationEventPublisher;

import java.lang.reflect.Method;
import java.util.Date;
Expand All @@ -37,7 +36,10 @@ public class PatientAdviceTest {
private PatientAdvice patientAdvice;

private BahmniEventPublisher bahmniEventPublisher;


private final String SAVE_PATIENT_METHOD_NAME = "savePatient";
private final String PURGE_PATIENT_METHOD_NAME = "purgePatient";

@Before
public void setUp() {
bahmniEventPublisher = mock(BahmniEventPublisher.class);
Expand All @@ -46,7 +48,7 @@ public void setUp() {

@Test
public void shouldVerifyTheEventPublishedIsNotGettingTriggeredGivenPatientNeitherCreatedNorUpdated() throws NoSuchMethodException {
Method savePatientMethod = PatientService.class.getMethod("purgePatient", Patient.class);
Method savePatientMethod = PatientService.class.getMethod(PURGE_PATIENT_METHOD_NAME, Patient.class);
Patient newPatient = getPatient();
PowerMockito.mockStatic(ConversionUtil.class);
Object[] args = {newPatient};
Expand All @@ -61,7 +63,7 @@ public void shouldVerifyTheEventPublishedIsNotGettingTriggeredGivenPatientNeithe

@Test
public void shouldVerifyTheEventPublishedIsGettingTriggeredGivenPatientIsCreated() throws NoSuchMethodException {
Method savePatientMethod = PatientService.class.getMethod("savePatient", Patient.class);
Method savePatientMethod = PatientService.class.getMethod(SAVE_PATIENT_METHOD_NAME, Patient.class);
Patient newPatient = getPatient();
PowerMockito.mockStatic(ConversionUtil.class);
Object[] args = {newPatient};
Expand All @@ -77,7 +79,7 @@ public void shouldVerifyTheEventPublishedIsGettingTriggeredGivenPatientIsCreated
@Test
public void shouldPublishCreateEventGivenPatientIsCreated() throws NoSuchMethodException {
Patient newPatient = getPatient();
Method savePatientMethod = PatientService.class.getMethod("savePatient", Patient.class);
Method savePatientMethod = PatientService.class.getMethod(SAVE_PATIENT_METHOD_NAME, Patient.class);

PowerMockito.mockStatic(ConversionUtil.class);
PowerMockito.when(ConversionUtil.convertToRepresentation(getPatient(), Representation.FULL)).thenReturn(newPatient);
Expand All @@ -97,7 +99,7 @@ public void shouldPublishCreateEventGivenPatientIsCreated() throws NoSuchMethodE
@Test
public void shouldPublishUpdateEventGivenPatientIsUpdated() throws NoSuchMethodException {
Patient newPatient = getPatient();
Method savePatientMethod = PatientService.class.getMethod("savePatient", Patient.class);
Method savePatientMethod = PatientService.class.getMethod(SAVE_PATIENT_METHOD_NAME, Patient.class);

PowerMockito.mockStatic(ConversionUtil.class);
PowerMockito.when(ConversionUtil.convertToRepresentation(getPatient(), Representation.FULL)).thenReturn(newPatient);
Expand All @@ -116,7 +118,7 @@ public void shouldPublishUpdateEventGivenPatientIsUpdated() throws NoSuchMethodE
@Test
public void shouldVerifyEventPublishedContentGivenPatientIsCreated() throws NoSuchMethodException {
Patient newPatient = getPatient();
Method savePatientMethod = PatientService.class.getMethod("savePatient", Patient.class);
Method savePatientMethod = PatientService.class.getMethod(SAVE_PATIENT_METHOD_NAME, Patient.class);

PowerMockito.mockStatic(ConversionUtil.class);
PowerMockito.when(ConversionUtil.convertToRepresentation(getPatient(), Representation.FULL)).thenReturn(newPatient);
Expand Down

0 comments on commit 28e2ced

Please sign in to comment.